« PDFlib FontReporter | トップページ | iL Giovane Montalbano(ヤング・モンタルバーノ) »

[正規表現]Quotationクォテーションの置き換え

めったに無い英語系
慣れないので、戸惑う事が多い
『幸い』大量ページ物では無かったので、短時間で済んだが
用紙サイズはまだしも
禁則に関しては『何が正解』なんだか?状態で非常に難儀した

クオテーションの直しがあり
Jedit Xの複数置換で対応したが…
校正も初めての業者さんで、慣れないのもあり
ホント難儀した…

Website_image00280312_222409

上のような原稿を
下のように置き換えます。

こんな感じです。

Website_image00280312_222401

Jedit Xの置換ファイル
「ReplaceQuotation.txt」をダウンロード

実際には
赤字の部分のPRIME関連の置き換えは実施せずに
検索かけながらの手作業にした(結局は1カ所だけだった)

Website_image00280312_222812


---
一応お約束でAppleScriptも作ったが
ファイル数が多くないならJedit Xの置換の方が堅い



set theText to "I'm \"NO, the is the 'Right Way!'\" she replied. 6' 2\" tall"





set theDoneReplace to doReplace(theText, " ", " ") as text
set theDoneReplace to doReplace(theText, "\\", "") as text
-----Apostrophe
set theDoneReplace to doReplace(theDoneReplace, "′", "'") as text

-----DoubleQuotation
set theDoneReplace to doReplace(theDoneReplace, " \"", " “") as text
set theDoneReplace to doReplace(theDoneReplace, "\" ", "” ") as text
set theDoneReplace to doReplace(theDoneReplace, "\"", "\\\"") as text
set theDoneReplace to do shell script "echo \"" & theDoneReplace & "\" | awk 'gsub(/(\"$)/, \"”\") \"\"'"
set theDoneReplace to doReplace(theDoneReplace, "\"", "\\\"") as text
set theDoneReplace to do shell script "echo \"" & theDoneReplace & "\" | awk 'gsub(/(^\")/, \"“\") \"\"'"

-----SingleQuotation

set theDoneReplace to doReplace(theDoneReplace, " '", " ‘") as text
set theDoneReplace to doReplace(theDoneReplace, "' ", "’ ") as text
set theDoneReplace to doReplace(theDoneReplace, "“'", "“‘") as text
set theDoneReplace to doReplace(theDoneReplace, "'“", "‘“") as text
set theDoneReplace to doReplace(theDoneReplace, "”'", "”’") as text
set theDoneReplace to doReplace(theDoneReplace, "'”", "’”") as text
set theDoneReplace to doReplace(theDoneReplace, "\"", "\\\"") as text
set theDoneReplace to do shell script "echo \"" & theDoneReplace & "\"| awk 'gsub(/'\\''$/, \"’\" ) \"\"'"
set theDoneReplace to doReplace(theDoneReplace, "\"", "\\\"") as text
set theDoneReplace to do shell script "echo \"" & theDoneReplace & "\" | awk 'gsub(/^'\\''/, \"‘\" ) \"\"'"

-----Prime
set theDoneReplace to doReplace(theDoneReplace, "\"", "\\\"") as text
set theDoneReplace to do shell script "echo \"" & theDoneReplace & "\"| sed -e 's/\\([0-9]\\)\\(’\\)\\( \\)/\\1′\\3/g'"
set theDoneReplace to doReplace(theDoneReplace, "\"", "\\\"") as text
set theDoneReplace to do shell script "echo \"" & theDoneReplace & "\"| sed -e 's/\\([0-9]\\)\\(”\\)\\( \\)/\\1′\\3/g'"




tell application "TextEdit" to launch
tell application "TextEdit"
make new document with properties {text:theDoneReplace}
tell document 1
properties
set font to "Georgia"
set size to 48
end tell

end tell
tell application "TextEdit" to activate



--------////////文字の置き換えのサブルーチン
to doReplace(theText, orgStr, newStr)
set oldDelim to AppleScript's text item delimiters
set AppleScript's text item delimiters to orgStr
set tmpList to every text item of theText
set AppleScript's text item delimiters to newStr
set tmpStr to tmpList as text
set AppleScript's text item delimiters to oldDelim
return tmpStr
end doReplace

「ReplaceQuotation.scpt.zip」をダウンロード

|

« PDFlib FontReporter | トップページ | iL Giovane Montalbano(ヤング・モンタルバーノ) »

JeditX Regexp」カテゴリの記事