summaryrefslogtreecommitdiff
path: root/Master/texmf-dist
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2014-04-28 21:51:56 +0000
committerKarl Berry <karl@freefriends.org>2014-04-28 21:51:56 +0000
commitc7f6b488255524d08fa08d46b801f39bfc25ad84 (patch)
treeec36575a0545fb574da6957e7e802576804e64fb /Master/texmf-dist
parent95b0a9a7bb820384823756857933ba28501c1f31 (diff)
scanpages (28apr14)
git-svn-id: svn://tug.org/texlive/trunk@33732 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist')
-rw-r--r--Master/texmf-dist/doc/latex/scanpages/README5
-rw-r--r--Master/texmf-dist/doc/latex/scanpages/replicate.plist72
-rwxr-xr-xMaster/texmf-dist/doc/latex/scanpages/replicate.py7
-rw-r--r--Master/texmf-dist/doc/latex/scanpages/scanpages-doc.pdfbin50347 -> 52107 bytes
-rw-r--r--Master/texmf-dist/doc/latex/scanpages/scanpages-doc.tex12
-rw-r--r--Master/texmf-dist/tex/latex/scanpages/scanpages.sty4
6 files changed, 54 insertions, 46 deletions
diff --git a/Master/texmf-dist/doc/latex/scanpages/README b/Master/texmf-dist/doc/latex/scanpages/README
index 5ae9426e0d3..a852ce319d0 100644
--- a/Master/texmf-dist/doc/latex/scanpages/README
+++ b/Master/texmf-dist/doc/latex/scanpages/README
@@ -16,7 +16,10 @@ LaTeX package scanpages
#
# This work consists of the files scanpages.sty, replicate.py and replicate.plist.
-Version: 1.01
+Version: 1.02
+Changes in version 1.01
+Corrected documentation and modified the scripts to handle text documents using carriage return for end-of-line.
+
Changes in version 1.01
AppleScript modified to remove dependence on external library TSLib. It is now self-contained.
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 &amp; 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=" &amp; (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-- " &amp; 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>
diff --git a/Master/texmf-dist/doc/latex/scanpages/replicate.py b/Master/texmf-dist/doc/latex/scanpages/replicate.py
index 99f0395da35..57a59782a75 100755
--- a/Master/texmf-dist/doc/latex/scanpages/replicate.py
+++ b/Master/texmf-dist/doc/latex/scanpages/replicate.py
@@ -6,7 +6,8 @@ import sys
filename=sys.argv[1]
with open(filename,'r') as f:
- s=f.read()
+ tmp=f.read().splitlines()
+s='\n'.join(tmp)
tmp=s.split("%Repetitions=")
if len(tmp) != 2:
print "Bailing! The file does not contain exactly one '%Repetitions='"
@@ -106,8 +107,8 @@ for p in range(numrep):
newbody=newbody.replace(root+vlst[k],v)
viniti[k] =int(viniti[k]) + vinci[k]
repl.append(newbody)
-
+
with open(filename,'w') as f:
for j in range(len(repl)):
- f.write(repl[j]+'\n')
+ f.write(repl[j]+'\n\n')
diff --git a/Master/texmf-dist/doc/latex/scanpages/scanpages-doc.pdf b/Master/texmf-dist/doc/latex/scanpages/scanpages-doc.pdf
index 3d7487e303b..b6c8a4d806d 100644
--- a/Master/texmf-dist/doc/latex/scanpages/scanpages-doc.pdf
+++ b/Master/texmf-dist/doc/latex/scanpages/scanpages-doc.pdf
Binary files differ
diff --git a/Master/texmf-dist/doc/latex/scanpages/scanpages-doc.tex b/Master/texmf-dist/doc/latex/scanpages/scanpages-doc.tex
index 7563f11a066..403ae840c71 100644
--- a/Master/texmf-dist/doc/latex/scanpages/scanpages-doc.tex
+++ b/Master/texmf-dist/doc/latex/scanpages/scanpages-doc.tex
@@ -49,7 +49,7 @@ The package creates then a destination box centered horizontally and vertically
\begin{verbatim}
\scanpage[rot=-1,page=1,dx=20,dy=15]{scan-0}
%\index{}
-%\rput(450,250){Is this assertion correct?}
+%\put(450,250){Is this assertion correct?}
\endpicture
\newpage
\end{verbatim}
@@ -57,13 +57,13 @@ which it interprets as follows:
\begin{itemize}
\item
{\tt rot} is an angle of rotation (degrees) in the mathematically positive sense (counter-clockwise) about the center. You may find it easier to enter {\tt tanrot=0.175}, the tangent of the rotation, as this is more easily estimated from the picture.
-{\tt page=1} selects the first page of the file {\tt scan-0.pdf}. This option may be omitted is the file contains only one page.
+\item {\tt page=1} selects the first page of the file {\tt scan-0.pdf}. This option may be omitted if the file contains only one page.
\item {\tt dx} nudges the resulting picture to the right by {\tt 20bp}, and similarly for {\tt dy}. (Actually, {\tt dx} nudges the {\tt viewport} to the left by {\tt 20bp/scale}.) If no unit is provided, {\tt bp} is assumed.
\item Any material following the \verb|\scanpage| line and before \verb|\endpicture| can be used for index entries, table of contents entries, footnotes and the like. As the action is all taking place within a \LaTeX\ {\tt picture} environment, each visible item must be placed in an instruction of the form
\begin{verbatim}
-\rput(x,y){...}
+\put(x,y){...}
\end{verbatim}
-where {\tt x} and {\tt y} are the purely numeric coordinates with implied unit {\tt 1bp}, which matches that required for dimensions in \verb|\includegraphics|.
+where {\tt x} and {\tt y} are the purely numeric coordinates with implied unit {\tt 1bp}, which matches that required for dimensions in \verb|\includegraphics|. For example, \verb|\put(10,20){Text and $x$}| makes an L-R box (no line breaks) from the content \verb|Text and $x$| with reference point at is left baseline and translates that reference point to {\tt (10,20)}, which is {\tt 10bp} to the right and {\tt 20bp} above the lower left corner of the picture. You may also use other \LaTeX\ constructs in place of an L-R box---a minipage, a parbox, a makebox or a graphic.
\end{itemize}
The page it produces contains, in addition to the scan material and other embellishments, a superimposed grid with unit {\tt 1bp} and a black box marking the edge of outline of the destination box. After all adjustments are complete, the grid may be suppressed by adding the option {\tt nogrid} to the package option list.
@@ -112,7 +112,7 @@ The fragment \verb|{NNN,0:1+1,1:2+-2,2:[-200+300],3:1+1(3)}| means that variable
Two other special forms are available.
\begin{itemize}
\item
-Scanning software often places each scanned page in a separate file with names like {\tt scan-001.jpg}, {\tt scan-002.jpg}. In cover this case you need an integer variable padded to three places, which could be produced by the descriptor of the form {\tt 4:1+1(3)} and a pattern like:
+Scanning software often places each scanned page in a separate file with names like {\tt scan-001.jpg}, {\tt scan-002.jpg}. To cover this case you need an integer variable padded to three places, which could be produced by the descriptor of the form {\tt 4:1+1(3)} and a pattern like:
\begin{verbatim}
%Repetitions=100
%Variables={NNN,0:1+1,1:2+-2,2:[-200+300],4:1+1(3)}
@@ -138,7 +138,7 @@ The AppleScript is meant to work within TeXShop after installation in the TeXSho
\begin{verbatim}
replicate.py myfile.txt
\end{verbatim}
-would read input from and write output to {\tt myfile.txt}. (The script has been tested with \textsf{python} {\tt2.7.4} under MacOS 10.9.1. It should work without modification under Linux but may require some minor changes in Windows using a \textsf{python} from {\tt activestate.com}.)
+would read input from and write output to {\tt myfile.txt}. (The script has been tested with \textsf{python} {\tt2.7.4} under MacOS 10.9.2. It should work without modification under Linux but may require some minor changes in Windows using a \textsf{python} from {\tt activestate.com}.)
The two scripts give the same output provided you use variable names that are identical in case to those the one in the \verb|%Variables=|
line. (In the examples above, this was always {\tt NNN}.) The \textsf{python} script is case sensitive, but the AppleScript is not---it will act on any variant like {\tt nnn0} or {\tt NnN1} as well.
\subsection{Installation in TeXShop's Macros Menu}
diff --git a/Master/texmf-dist/tex/latex/scanpages/scanpages.sty b/Master/texmf-dist/tex/latex/scanpages/scanpages.sty
index 3747250e5e9..edda1901709 100644
--- a/Master/texmf-dist/tex/latex/scanpages/scanpages.sty
+++ b/Master/texmf-dist/tex/latex/scanpages/scanpages.sty
@@ -5,8 +5,8 @@
% Copyright (c) 2014 by Michael Sharpe, msharpe at ucsd dot edu;
% This is free software, subject to the LATEX Project Public License.
-\def\fileversion{1.01}
-\def\filedate{2014/01/08}
+\def\fileversion{1.02}
+\def\filedate{2014/04/24}
\ProvidesPackage{scanpages.sty}[\filedate\space v\fileversion]
\message{`scanpages' v\fileversion, \filedate\space Macros to help create documents from scanned pages(msharpe)}