001 | #!/usr/bin/env osascript |
002 | ----+----1----+----2----+-----3----+----4----+----5----+----6----+----7 |
003 | (* |
004 | スクリプトメニュー用 |
005 | スクリプトエディタの前面ドキュメントで |
006 | 投稿用のHTMLを生成する |
007 |
|
008 | v0 テスト中 |
009 | v0.1 コピーボタンにCSS追加 |
010 | v1 20250420 特に治すところも無くなったのでこれでOKにする |
011 |
|
012 | com.cocolog-nifty.quicktimer.icefloe *) |
013 | ----+----1----+----2----+-----3----+----4----+----5----+----6----+----7 |
014 | use AppleScript version "2.8" |
015 | use framework "Foundation" |
016 | use framework "AppKit" |
017 | use scripting additions |
018 | global argFileName |
019 | property refMe : a reference to current application |
020 |
|
021 | set appFileManager to refMe's NSFileManager's defaultManager() |
022 |
|
023 | ########################################## |
024 | ###起動時に削除するフォルダ |
025 | ########################################## |
026 | set ocidDirPathURL to appFileManager's temporaryDirectory() |
027 | ###ディレクトリ |
028 | set appFileManager to refMe's NSFileManager's defaultManager() |
029 | set ocidTempDirURL to appFileManager's temporaryDirectory() |
030 | set ocidUUID to refMe's NSUUID's alloc()'s init() |
031 | set ocidUUIDString to ocidUUID's UUIDString |
032 | set ocidSaveDirPathURL to ocidTempDirURL's URLByAppendingPathComponent:(ocidUUIDString) isDirectory:(true) |
033 |
|
034 | ####アクセス権777で作成 |
035 | set ocidAttrDict to refMe's NSMutableDictionary's alloc()'s initWithCapacity:0 |
036 | ocidAttrDict's setValue:511 forKey:(refMe's NSFilePosixPermissions) |
037 | appFileManager's createDirectoryAtURL:(ocidSaveDirPathURL) withIntermediateDirectories:true attributes:ocidAttrDict |error|:(reference) |
038 |
|
039 |
|
040 | ########################################## |
041 | ###ファイル名とパス |
042 | ########################################## |
043 | tell application "Script Editor" |
044 | tell front document |
045 | tell application "System Events" |
046 | key code 0 using command down |
047 | delay 0.2 |
048 | key code 8 using command down |
049 | delay 0.2 |
050 | key code 0 using control down |
051 | end tell |
052 | end tell |
053 | end tell |
054 |
|
055 |
|
056 | tell application "Script Editor" |
057 | tell front document |
058 | set strScriptFileName to name as text |
059 | set strScriptSource to contents as text |
060 | end tell |
061 | end tell |
062 | set argFileName to strScriptFileName as text |
063 | ###中間ファイルの名前は全部日付 |
064 | set strTime to doGetDateNo("yyyyMMddhhmmss") as text |
065 | ####ファイル名 |
066 | set strHtmlFileName to ("" & strScriptFileName & ".html") as text |
067 | set strTextFileName to ("" & strScriptFileName & ".txt") as text |
068 | ###HTMLへのURL |
069 | set ocidFilePathURL to ocidSaveDirPathURL's URLByAppendingPathComponent:(strHtmlFileName) isDirectory:false |
070 | set ocidTextFilePathURL to ocidSaveDirPathURL's URLByAppendingPathComponent:(strTextFileName) isDirectory:false |
071 | ########################################## |
072 | ###HTML Entity |
073 | ########################################## |
074 | set recordEntityMap to {|&|:"&", |<|:"<", |>|:">", |"|:""", |'|:"'", |=|:"=", |+|:"+", |\\|:"\", |$|:"$", |\||:"|"} as record |
075 | set ocidEntityMap to refMe's NSDictionary's alloc()'s initWithDictionary:(recordEntityMap) |
076 | set ocidAllKeys to ocidEntityMap's allKeys() |
077 | set ocidTextToEncode to refMe's NSMutableString's alloc()'s init() |
078 | ocidTextToEncode's setString:(strScriptSource) |
079 | repeat with itemAllKey in ocidAllKeys |
080 | ##キーの値を取り出して |
081 | set ocidMapValue to (ocidEntityMap's valueForKey:itemAllKey) |
082 | ##置換 |
083 | set ocidEncodedText to (ocidTextToEncode's stringByReplacingOccurrencesOfString:(itemAllKey) withString:(ocidMapValue)) |
084 | ##次の変換に備える |
085 | set ocidTextToEncode to ocidEncodedText |
086 | end repeat |
087 | ### |
088 | set ocidTextToEncode to (ocidTextToEncode's stringByReplacingOccurrencesOfString:("\t") withString:(" ")) |
089 | set ocidTextToEncode to (ocidTextToEncode's stringByReplacingOccurrencesOfString:("\r") withString:("\n")) |
090 |
|
091 | ### |
092 | set strSetPattern to ("\\u00A0") as text |
093 | set ocidOption to (refMe's NSRegularExpressionAnchorsMatchLines) |
094 | set listResponse to (refMe's NSRegularExpression's regularExpressionWithPattern:(strSetPattern) options:(ocidOption) |error|:(reference)) |
095 | set appRegex to (item 1 of listResponse) |
096 | set ocidLegth to ocidTextToEncode's |length|() |
097 | set ocidRange to refMe's NSRange's NSMakeRange(0, ocidLegth) |
098 | set ocidTextToEncode to (appRegex's stringByReplacingMatchesInString:(ocidTextToEncode) options:0 range:(ocidRange) withTemplate:(" ")) |
099 |
|
100 | set strEncodedText to ocidTextToEncode as text |
101 |
|
102 |
|
103 | ########################################## |
104 | ###コピーボタン |
105 | ########################################## |
106 |
|
107 | ###HTMLのエレメントID用のランダム番号5桁 |
108 | set num5Digit to random number from 10000 to 99999 |
109 | #このランダム値でクラス名を決める |
110 | set strDivClassName to ("sourcecode" & num5Digit & "") |
111 | ###JAVAASCRIPT整形 |
112 | set strJsText to ("<script>const elmentButtonCopy" & num5Digit & " = document.getElementById('buttonCopy" & num5Digit & "');const elmentInputText" & num5Digit & " = document.getElementById('inputText" & num5Digit & "');elmentButtonCopy" & num5Digit & ".addEventListener('click', () => {const strInputTextValue = elmentInputText" & num5Digit & ".value;return navigator.clipboard.writeText(strInputTextValue);})</script>") as text |
113 | set strCopyHTML to ("<textarea id=\"inputText" & num5Digit & "\" type=\"text\" hidden readonly>" & strEncodedText & "</textarea>") as text |
114 | ###ボタン用CSS |
115 | set strCopyBottonCSS to ("#buttonCopy" & num5Digit & "{background-color:#569cd6;border:none;color:white;padding:15px32px;text-align:center;text-decoration:none;display:inline-block;font-size:16px;margin:4px2px;cursor:pointer;border-radius:10px;}") as text |
116 | ###出来上がり |
117 | set strCopyLinkText to (strCopyHTML & "<button id=\"buttonCopy" & num5Digit & "\" style=\"display: inline-block;border:none;padding: 7px 14px;background-color: #fdb200;color: white;text-decoration: none;border-radius: 6px;font-weight: bold;text-align: center;transition: background 0.3s;font-size:16px;\" onmousedown=\"this.style.transform='translateY(2px)'; this.style.boxShadow='inset 0 2px 4px rgba(0,0,0,0.2)'\" onmouseup=\"this.style.transform='none'; this.style.boxShadow='none'\" onmouseleave=\"this.style.transform='none'; this.style.boxShadow='none'\">【クリップボードへコピー】</button>" & strJsText) as text |
118 | set strJsLinkText to ("<span class=\"javascript_botton\">" & strCopyLinkText & "</span>") as text |
119 |
|
120 | ########################################## |
121 | ###スクリプトリンクの作成 |
122 | ########################################## |
123 | set ocidScriptSource to refMe's NSString's stringWithString:(strScriptSource) |
124 | ##キャラクタセットを指定 |
125 | set ocidChrSet to refMe's NSCharacterSet's URLQueryAllowedCharacterSet |
126 | ###ペーストボードの内容をキャラクタセットで変換 |
127 | set ocidTextEncodeAS to ocidScriptSource's stringByAddingPercentEncodingWithAllowedCharacters:(ocidChrSet) |
128 | ###可変テキストに格納しておく |
129 | set ocidEncodedText to refMe's NSMutableString's alloc()'s init() |
130 | ocidEncodedText's setString:(ocidTextEncodeAS) |
131 | ######## 置換 %エンコードの追加処理 |
132 | ###置換レコード |
133 | set recordPercentMap to {|+|:"%2B", |=|:"%3D", |&|:"%26", |$|:"%24"} as record |
134 | ###ディクショナリにして |
135 | set ocidPercentMap to refMe's NSDictionary's alloc()'s initWithDictionary:(recordPercentMap) |
136 | ###キーの一覧を取り出します |
137 | set ocidAllKeys to ocidPercentMap's allKeys() |
138 | ###取り出したキー一覧を順番に処理 |
139 | repeat with itemAllKey in ocidAllKeys |
140 | ##キーの値を取り出して |
141 | set ocidMapValue to (ocidPercentMap's valueForKey:itemAllKey) |
142 | ##置換 |
143 | set ocidEncodedText to (ocidEncodedText's stringByReplacingOccurrencesOfString:(itemAllKey) withString:(ocidMapValue)) |
144 | ##次の変換に備える |
145 | set ocidTextToEncode to ocidEncodedText |
146 | end repeat |
147 | ### |
148 | set strSetPattern to ("\\u00A0") as text |
149 | set ocidOption to (refMe's NSRegularExpressionAnchorsMatchLines) |
150 | set listResponse to (refMe's NSRegularExpression's regularExpressionWithPattern:(strSetPattern) options:(ocidOption) |error|:(reference)) |
151 | set appRegex to (item 1 of listResponse) |
152 | set ocidLegth to ocidTextToEncode's |length|() |
153 | set ocidRange to refMe's NSRange's NSMakeRange(0, ocidLegth) |
154 | set ocidTextToEncode to (appRegex's stringByReplacingMatchesInString:(ocidTextToEncode) options:0 range:(ocidRange) withTemplate:(" ")) |
155 |
|
156 |
|
157 | set strEncodedText to ocidTextToEncode as text |
158 | ### |
159 | set ocidURLComponents to refMe's NSURLComponents's alloc()'s init() |
160 | ocidURLComponents's setScheme:("applescript") |
161 | ocidURLComponents's setHost:("com.apple.scripteditor") |
162 | ##クエリー部 |
163 | set ocidQueryItems to refMe's NSMutableArray's alloc()'s init() |
164 | ocidQueryItems's addObject:(refMe's NSURLQueryItem's alloc()'s initWithName:("action") value:("new")) |
165 | ocidQueryItems's addObject:(refMe's NSURLQueryItem's alloc()'s initWithName:("name") value:(strScriptFileName)) |
166 | #ocidQueryItems's addObject:(refMe's NSURLQueryItem's alloc()'s initWithName:("script") value:(ocidScriptSource)) |
167 | ##クエリーをセットする |
168 | ocidURLComponents's setQueryItems:(ocidQueryItems) |
169 | ##URLに戻して テキストにしておく |
170 | set ocidOpenURL to ocidURLComponents's |URL|() |
171 | set strURL to ocidOpenURL's absoluteString() as text |
172 | log strURL |
173 | set strSetStyle to ("display: inline-block;padding: 7px 14px;background-color: #fdb200;color: white;text-decoration: none;border-radius: 6px;font-weight: bold;text-align: center;transition: background 0.3s;") as text |
174 |
|
175 |
|
176 | set strAsLinkText to "<span class=\"openscript\"><a href=\"" & strURL & "&script=" & strEncodedText & "\" title=\"Open in Script Editor\" class=\"open-script-editor\" style=\"" & strSetStyle & "\">【スクリプトエディタで開く】</a></span>" as text |
177 | set strLinkBotton to ("<p class=\"script-copy-botton\">" & strAsLinkText & " | " & strJsLinkText & "</p>") as text |
178 |
|
179 |
|
180 |
|
181 |
|
182 | ########################################## |
183 | ###ペーストボード |
184 | ########################################## |
185 | ####ペーストボード宣言 |
186 | set ocidPasteboard to refMe's NSPasteboard's generalPasteboard() |
187 | ####中に格納されているデータタイプを取得 |
188 | set ocidPastBoardTypeArray to ocidPasteboard's types |
189 | log ocidPastBoardTypeArray as list |
190 |
|
191 |
|
192 | if (ocidPastBoardTypeArray's containsObject:"public.rtf") is true then |
193 | ###ペーストボードの内容をタイプ指定で受け取るdataForTypeで受け取る |
194 | set ocidPublicRTF to ocidPasteboard's dataForType:(refMe's NSPasteboardTypeRTF) |
195 | ###NSAttributedStringに変換して |
196 | set ocidAttributedString to refMe's NSAttributedString's alloc()'s initWithRTF:(ocidPublicRTF) documentAttributes:(missing value) |
197 | ###文字数を数えてレンジを生成 |
198 | set numStringLenge to ocidAttributedString's |length|() as integer |
199 | set ocidRange to refMe's NSMakeRange(0, numStringLenge) |
200 | ####オプション指定 |
201 | set ocidAttributedDict to refMe's NSDictionary's dictionaryWithObject:(refMe's NSHTMLTextDocumentType) forKey:(refMe's NSDocumentTypeDocumentAttribute) |
202 | ##オプション指定でHTMLデータに変換 |
203 | set listAttributedString to ocidAttributedString's dataFromRange:(ocidRange) documentAttributes:(ocidAttributedDict) |error|:(reference) |
204 | set ocidHTMLDATA to item 1 of listAttributedString |
205 | ###HTMLデータをHTMLテキストに戻して |
206 | set ocidPublicHTML to refMe's NSString's alloc()'s initWithData:(ocidHTMLDATA) encoding:(refMe's NSUTF8StringEncoding) |
207 | # |
208 | set ocidPublicHTML to (ocidPublicHTML's stringByReplacingOccurrencesOfString:("\n\n") withString:("\n")) |
209 | set ocidPublicHTML to (ocidPublicHTML's stringByReplacingOccurrencesOfString:("\r\r") withString:("\r")) |
210 | |
211 | set ocidPublicHTML to (ocidPublicHTML's stringByReplacingOccurrencesOfString:("</head>\n<body>") withString:("<div id=\"" & strDivClassName & "\">" & strLinkBotton & "<table>")) |
212 | |
213 | |
214 | ############# |
215 | # |
216 | set ocidPublicHTML to doMakePostHTML(ocidPublicHTML, strDivClassName) |
217 | ############# |
218 | # |
219 | set ocidPublicHTML to doReplacingString(ocidPublicHTML) |
220 | |
221 | ############# |
222 | # |
223 | set ocidPublicHTML to doAddCss(ocidPublicHTML, num5Digit) |
224 | |
225 | ###ファイルに書き込む |
226 | ocidPublicHTML's writeToURL:(ocidFilePathURL) atomically:true encoding:(refMe's NSUTF8StringEncoding) |error|:(reference) |
227 | else |
228 | return "HTMLに変換出来ません" |
229 | end if |
230 |
|
231 | ###HTML表示で開く |
232 | tell application "TextEdit" |
233 | open (ocidFilePathURL as alias) |
234 | end tell |
235 |
|
236 | ###拡張子をtxtにしたソース閲覧用のファイルを作る |
237 | appFileManager's copyItemAtURL:(ocidFilePathURL) toURL:(ocidTextFilePathURL) |error|:(reference) |
238 | ###ソーステキストで開く |
239 | tell application "TextEdit" |
240 | open (ocidTextFilePathURL as alias) |
241 | end tell |
242 |
|
243 |
|
244 | to doAddCss(argHTMLString, argNum5Digit) |
245 | |
246 | set strCSS to ("<hr><style type=\"text/css\">#sourcecode" & argNum5Digit & " div{margin: 5px;padding: 10px;max-width: 680px;}#sourcecode" & argNum5Digit & " table {border-spacing: 0;caption-side: top;}#sourcecode" & argNum5Digit & " table thead th {border: solid 1px #666666;padding: .5ch 1ch;border-block-width: 1px 1px;border-inline-width: 1px 0;-webkit-user-select: none;user-select: none;font-weight: normal;font-size: 10pt;&:first-of-type {border-start-start-radius: .5em}&:last-of-type {border-start-end-radius: .5em;border-inline-end-width: 1px}} #sourcecode" & argNum5Digit & " table tbody th {border-spacing: 0;border-top: none;border-bottom: solid 1px #666666;border-left: solid 1px #666666;border-right: solid 1px #666666;padding: .5ch 1ch;font-weight: normal;border-block-width: 1px 0;border-inline-width: 1px 0;-webkit-user-select: none;user-select: none;font-size: 10pt;}#sourcecode" & argNum5Digit & " table tbody td {max-width: 580px;word-wrap: break-word;border-spacing: 0;border-top: none;border-bottom: solid 1px #666666;border-left: solid 1px #666666;border-right: solid 1px #666666;padding-left: .5ch;padding-right: 1ch;border-block-width: 1px 0;border-inline-width: 1px 0;&:last-of-type {border-inline-end-width: 1px}}#sourcecode" & argNum5Digit & " table tbody td span {font-size: 12pt;line-height: 14pt;}kind_string {font-size: 0.75em;}.date_string {font-size: 0.5em;}#sourcecode" & argNum5Digit & " table tfoot th {border: solid 1px #666666;padding: .5ch 1ch;-webkit-user-select: none;user-select: none;font-weight: normal;&:first-of-type {border-end-start-radius: .5em}&:last-of-type {border-end-end-radius: .5em;border-inline-end-width: 1px}}</style>") as text |
247 | |
248 | set ocidReturnString to refMe's NSMutableString's alloc()'s init() |
249 | ocidReturnString's setString:(strCSS) |
250 | ocidReturnString's appendString:(argHTMLString) |
251 | # |
252 | (* |
253 | set ocidReturnString to (ocidReturnString's stringByReplacingOccurrencesOfString:("<table>") withString:("<table><thead><tr><th>行番号</th><th>ソース</th></tr></thead><tbody>")) |
254 | set ocidReturnString to (ocidReturnString's stringByReplacingOccurrencesOfString:("</table>") withString:("</tbody><tfoot><tr><th colspan=\"2\"></a></th></tr></tfoot></table>")) |
255 | *) |
256 | |
257 | return ocidReturnString |
258 | end doAddCss |
259 |
|
260 | ########################################## |
261 | ###日付時間番号 |
262 | ########################################## |
263 | to doGetDateNo(strDateFormat) |
264 | ####日付情報の取得 |
265 | set ocidDate to refMe's NSDate's |date|() |
266 | ###日付のフォーマットを定義 |
267 | set ocidNSDateFormatter to refMe's NSDateFormatter's alloc()'s init() |
268 | ocidNSDateFormatter's setLocale:(refMe's NSLocale's localeWithLocaleIdentifier:"en_US") |
269 | ocidNSDateFormatter's setDateFormat:(strDateFormat) |
270 | ###日付情報にフォーマットを適応 |
271 | set ocidDateAndTime to ocidNSDateFormatter's stringFromDate:(ocidDate) |
272 | ###テキストに確定させて |
273 | set strDateAndTime to ocidDateAndTime as text |
274 | ###戻す |
275 | return strDateAndTime |
276 | end doGetDateNo |
277 |
|
278 |
|
279 | to doReplacingString(argHTMLString) |
280 | |
281 | set ocidLineArray to argHTMLString's componentsSeparatedByString:("\n") |
282 | |
283 | set ocidReturnArray to refMe's NSMutableArray's alloc()'s init() |
284 | set numCntArray to ocidLineArray's |count|() |
285 | set numLineNO to 1 as number |
286 | repeat with itemIntNo from 0 to (numCntArray - 1) by 1 |
287 | set itemLineSting to (ocidLineArray's objectAtIndex:(itemIntNo)) |
288 | set boolPreFix to (itemLineSting's hasPrefix:("td.p")) |
289 | if boolPreFix is true then |
290 | set numLength to itemLineSting's |length|() |
291 | set ocidRange to refMe's NSRange's NSMakeRange(0, numLength) |
292 | set strRefPattern to ("(?:margin:\\s*[^;]+;\\s*|text-indent:\\s*[^;]+;\\s*)") as text |
293 | set ocidRefPattern to (refMe's NSString's stringWithString:(strRefPattern)) |
294 | |
295 | set listResponse to (refMe's NSRegularExpression's regularExpressionWithPattern:(ocidRefPattern) options:(0) |error|:(reference)) |
296 | set appRegex to (item 1 of listResponse) |
297 | set ocidLineString to (appRegex's stringByReplacingMatchesInString:(itemLineSting) options:0 range:(ocidRange) withTemplate:("")) |
298 | else |
299 | set ocidLineString to itemLineSting |
300 | end if |
301 | ## |
302 | set boolPreFix to (ocidLineString's hasPrefix:("<p ")) |
303 | if boolPreFix is true then |
304 | set strLineNO to doZeroPad(numLineNO, 3) as text |
305 | set ocidLineString to (ocidLineString's stringByReplacingOccurrencesOfString:("<p ") withString:("<tr><td class=\"lineno\">" & strLineNO & "</td><td ")) |
306 | set numLineNO to (numLineNO + 1) as integer |
307 | end if |
308 | set boolMeta to (ocidLineString's hasPrefix:("<meta")) |
309 | if boolMeta is false then |
310 | (ocidReturnArray's addObject:(ocidLineString)) |
311 | end if |
312 | |
313 | end repeat |
314 | |
315 | set ocidReturnString to ocidReturnArray's componentsJoinedByString:("\n") |
316 | set ocidReturnString to (ocidReturnString's stringByReplacingOccurrencesOfString:("\n\n") withString:("\n")) |
317 | set ocidReturnString to (ocidReturnString's stringByReplacingOccurrencesOfString:("\n\n") withString:("\n")) |
318 | set ocidReturnString to (ocidReturnString's stringByReplacingOccurrencesOfString:("</script></span></td></tr>") withString:("</script></span></p>")) |
319 | # |
320 | set ocidReturnString to (ocidReturnString's stringByReplacingOccurrencesOfString:("<table>") withString:("<table><caption>" & argFileName & "</caption><colgroup><col title=\"LineNo\"></col><col title=\"Source\"></col></colgroup><thead><tr><th title=\"lineNo\" class=\"lineNo\" scope=\"col\"></th><th title=\"Source\" class=\"Source\" scope=\"col\">ソース</th></tr></thead><tbody>")) |
321 | |
322 | set ocidReturnString to (ocidReturnString's stringByReplacingOccurrencesOfString:("</table>") withString:("</tbody><tfoot><tr><th title=\"テーブルの終わり\" colspan=\"2\" scope=\"row\"><a href=\"https://quicktimer.cocolog-nifty.com/icefloe/2025/04/post-b26aa5.html\" target=\"_blank\">AppleScriptで生成しました</a></th></tr></tfoot></table>")) |
323 | set ocidReturnString to (ocidReturnString's stringByReplacingOccurrencesOfString:("table {margin: 0;padding: 0;width: 100%;} ") withString:("table {margin: 0;padding: 0;width: 100%;} ")) |
324 | set ocidReturnString to (ocidReturnString's stringByReplacingOccurrencesOfString:("th {margin: 0;padding: 0;}") withString:("th {margin: 0;padding: 0;}")) |
325 | |
326 | |
327 | |
328 | return ocidReturnString |
329 | |
330 | end doReplacingString |
331 |
|
332 |
|
333 | to doMakePostHTML(argHTMLString, argDivClassName) |
334 | set argHTMLString to (argHTMLString's stringByReplacingOccurrencesOfString:("<!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 4.01//EN\" \"http://www.w3.org/TR/html4/strict.dtd\">") withString:("")) |
335 | set argHTMLString to (argHTMLString's stringByReplacingOccurrencesOfString:("<html>\n<head>") withString:("")) |
336 | set argHTMLString to (argHTMLString's stringByReplacingOccurrencesOfString:("<title></title>") withString:("")) |
337 | set argHTMLString to (argHTMLString's stringByReplacingOccurrencesOfString:("</body>\n</html>") withString:("</table></div><hr>")) |
338 | set argHTMLString to (argHTMLString's stringByReplacingOccurrencesOfString:("\t") withString:(" ")) |
339 | set argHTMLString to (argHTMLString's stringByReplacingOccurrencesOfString:("</p>") withString:("</td></tr>")) |
340 | |
341 | #日本語の場合 |
342 | set argHTMLString to (argHTMLString's stringByReplacingOccurrencesOfString:("<style type=\"text/css\">") withString:("<style type=\"text/css\">#" & argDivClassName & " table tr:nth-child(odd) { background-color: #f9f9f9; }#" & argDivClassName & " table tr:nth-child(even) {background-color: #ffffff;}#" & argDivClassName & " table {margin: 0;padding: 0;width: 100%;} #" & argDivClassName & " td, #" & argDivClassName & " th {margin: 0;padding: 0;}")) |
343 | |
344 | set argHTMLString to (argHTMLString's stringByReplacingOccurrencesOfString:("#sourcecode44530 td.p") withString:("#" & argDivClassName & " td.p")) |
345 | set argHTMLString to (argHTMLString's stringByReplacingOccurrencesOfString:("</style>") withString:("td.lineno{width:36px;font: 10px monospace; color: #707070;-webkit-user-select: none;user-select: none;}#" & argDivClassName & " td {text-indent: 0 !important;}#" & argDivClassName & " span {text-indent: 0 !important;}</style>")) |
346 | set argHTMLString to (argHTMLString's stringByReplacingOccurrencesOfString:(";font-family: system-ui, -apple-system, BlinkMacSystemFont,sans-serif;") withString:(";font-family: system-ui, -apple-system, BlinkMacSystemFont,sans-serif;")) |
347 | set argHTMLString to (argHTMLString's stringByReplacingOccurrencesOfString:(";font-family: system-ui, -apple-system, BlinkMacSystemFont,sans-serif;") withString:(";font-family: system-ui, -apple-system, BlinkMacSystemFont,sans-serif;")) |
348 | set argHTMLString to (argHTMLString's stringByReplacingOccurrencesOfString:("#sourcecode44530 span.s") withString:("#" & argDivClassName & " #sourcecode44530 span.s")) |
349 | set argHTMLString to (argHTMLString's stringByReplacingOccurrencesOfString:("<span class=\"Apple-tab-span\">") withString:("")) |
350 | set argHTMLString to (argHTMLString's stringByReplacingOccurrencesOfString:(" </span>") withString:(" ")) |
351 | |
352 | |
353 | return argHTMLString |
354 | |
355 | |
356 | end doMakePostHTML |
357 |
|
358 |
|
359 | ###doZeroPad(値, 桁数) |
360 | to doZeroPad(numZero, numDigits2Pad) |
361 | set theZeroDig to "" as text |
362 | repeat (numDigits2Pad - 1) times |
363 | set theZeroDig to (theZeroDig & "0") as text |
364 | end repeat |
365 | set theZeroMax to 1 |
366 | set theZeroMax to (theZeroMax & theZeroDig) as text |
367 | if numZero < theZeroMax then |
368 | return text -numDigits2Pad through -1 of (theZeroDig & numZero) |
369 | else |
370 | return numZero as text |
371 | end if |
372 | end doZeroPad |