diff options
author | Karl Berry <karl@freefriends.org> | 2014-04-28 21:51:56 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2014-04-28 21:51:56 +0000 |
commit | c7f6b488255524d08fa08d46b801f39bfc25ad84 (patch) | |
tree | ec36575a0545fb574da6957e7e802576804e64fb /Master/texmf-dist/doc/latex/scanpages/replicate.plist | |
parent | 95b0a9a7bb820384823756857933ba28501c1f31 (diff) |
scanpages (28apr14)
git-svn-id: svn://tug.org/texlive/trunk@33732 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/doc/latex/scanpages/replicate.plist')
-rw-r--r-- | Master/texmf-dist/doc/latex/scanpages/replicate.plist | 72 |
1 files changed, 38 insertions, 34 deletions
diff --git a/Master/texmf-dist/doc/latex/scanpages/replicate.plist b/Master/texmf-dist/doc/latex/scanpages/replicate.plist index dea502e0e06..04beb49b623 100644 --- a/Master/texmf-dist/doc/latex/scanpages/replicate.plist +++ b/Master/texmf-dist/doc/latex/scanpages/replicate.plist @@ -9,46 +9,42 @@ <dict> <key>content</key> <string>--applescript direct ---Michael Sharpe, 20140106 +--Michael Sharpe, 20140424 --This is free software, but Copyright (c) Michael Sharpe, 2014 --and subject to the LATEX Project Public License. --This allows replication of a commented block of text as many times as specified, substituting --values for 'variables' in the process -property trimitems : {" ", tab, ASCII character 10} +property trimitems : {" ", tab, linefeed, return} -set lf to (ASCII character 10) -tell application "TeXShop" to set s to content of selection of document 1 - -set oldtid to AppleScript's text item delimiters -set AppleScript's text item delimiters to "%Repetitions=" -set tmp to (text items of s) -set AppleScript's text item delimiters to oldtid +set lf to linefeed +set cr to return +set crlf to cr & lf +
set oldtid to text item delimiters
tell application "TeXShop" to set s to content of selection of document 1
set tmp to (paragraphs of s) +set text item delimiters to {lf} +set s to (tmp as text)
set text item delimiters to "%Repetitions="
set tmp to (text items of s) +set text item delimiters to oldtid if not ((count of tmp) = 2) then display dialog "Bailing! The selection does not contain exactly one '%Repetitions='" return end if -set AppleScript's text item delimiters to {lf} set ss to (item 2 of tmp) -set tmp2 to (text items of ss) -set AppleScript's text item delimiters to oldtid +set tmp2 to (paragraphs of ss) set numrep to (item 1 of tmp2) as integer --next get variable names -set AppleScript's text item delimiters to {"%Variables="} +set text item delimiters to {"%Variables="} set tmp to (text items of s) -set AppleScript's text item delimiters to oldtid +set text item delimiters to oldtid if not ((count of tmp) = 2) then display dialog "Bailing! The selection does not contain exactly one '%Variables='" return end if set ss to (item 2 of tmp) -set AppleScript's text item delimiters to {lf} -set tmp2 to (text items of ss) -set AppleScript's text item delimiters to oldtid +set tmp2 to (paragraphs of ss) set vbllst to (item 1 of tmp2) --like {nnn,0:1+1,1:3+-2} set vbllst2 to trim(vbllst) set vbllst3 to (text 2 thru -2 of vbllst2) -set AppleScript's text item delimiters to {" , ", " ,", " ,", ","} +set text item delimiters to {" , ", " ,", " ,", ","} set vbles to (text items of vbllst3) -- line {nnn,0:1+1,1:3+-2} --display dialog "vbles=" & (vbles as text) set n to (count of vbles) @@ -57,12 +53,12 @@ set vlst to {} set vinit to {} set vinc to {} set valt to {} -set AppleScript's text item delimiters to {":", "+"} +set text item delimiters to {":", "+"} repeat with j from 2 to n set x to (text items of (item j of vbles)) if not ((count of x) = 3) then display dialog "Bad variable descriptor-- " & item j of vbles - set AppleScript's text item delimiters to oldtid + set text item delimiters to oldtid return end if set end of vlst to (item 1 of x) @@ -93,7 +89,7 @@ repeat with j from 2 to n end if end repeat -set AppleScript's text item delimiters to oldtid +set text item delimiters to oldtid set viniti to {} set vinci to {} set kk to (count of vinit) @@ -109,9 +105,7 @@ repeat with j from 1 to kk set end of vinci to 0 end try end repeat -set AppleScript's text item delimiters to {lf} -set tmp to (text items of s) -set AppleScript's text item delimiters to oldtid +set tmp to (paragraphs of s) set m to (count of tmp) set tmp2 to {} repeat with j from 3 to m @@ -123,9 +117,9 @@ repeat with j from 3 to m end if set end of tmp2 to t end repeat -set AppleScript's text item delimiters to {lf} +set text item delimiters to {lf} set body to (tmp2 as text) -set AppleScript's text item delimiters to oldtid +set text item delimiters to oldtid set repl to {s} set newbody to body repeat with p from 1 to numrep @@ -156,7 +150,7 @@ repeat with p from 1 to numrep end repeat set end of repl to newbody end repeat -set AppleScript's text item delimiters to lf +set text item delimiters to lf tell application "TeXShop" to set selection of document 1 to (repl as text) set AppleScript's text item delimiters to oldtid @@ -177,17 +171,27 @@ to switchText of t from s to r end switchText on trim(someText) - repeat until first character of someText is not in trimitems - set someText to text 2 thru -1 of someText - end repeat - - repeat until last character of someText is not in trimitems - set someText to text 1 thru -2 of someText - end repeat + try + repeat until first character of someText is not in trimitems + set someText to text 2 thru -1 of someText + end repeat + on error + set someText to "" + end try + + try + repeat until last character of someText is not in trimitems + set someText to text 1 thru -2 of someText + end repeat + on error + set someText to "" + end try return someText end trim </string> + <key>key</key> + <string></string> <key>name</key> <string>Replicate</string> </dict> |