Skip to content

Instantly share code, notes, and snippets.

@Etclsc
Created September 22, 2016 17:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Etclsc/1050ee5497abba8f3c6b583edcc6b51d to your computer and use it in GitHub Desktop.
Save Etclsc/1050ee5497abba8f3c6b583edcc6b51d to your computer and use it in GitHub Desktop.
英文をコピーしたときに翻訳にかけやすい形式に変換 (Meryマクロ)
// 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