Created
September 22, 2016 17:17
-
-
Save Etclsc/1050ee5497abba8f3c6b583edcc6b51d to your computer and use it in GitHub Desktop.
英文をコピーしたときに翻訳にかけやすい形式に変換 (Meryマクロ)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// replaceSkip.js | |
// 翻訳に投げやすい形式に変換するスクリプト | |
// 選択されていなければ文章全体を対象 | |
if(document.selection.IsEmpty) { | |
document.selection.SelectAll(); | |
} | |
var orgText = document.selection.Text; | |
var repText = ""; | |
for (var index = 0; index < orgText.length-1; index++) { | |
// 改行を半角スペースに置換 | |
if(orgText.charAt(index) == "\n") { | |
repText += " "; | |
} | |
// 文章の最後で改行 | |
else if(orgText.charAt(index) == "." && orgText.charAt(index+1) == " ") { | |
repText += ".\n"; index++; | |
} else { | |
repText += orgText.charAt(index); | |
} | |
} | |
repText += orgText.slice(-1); | |
document.selection.Text = repText; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment