diff options
author | Karl Berry <karl@freefriends.org> | 2011-11-23 01:49:43 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2011-11-23 01:49:43 +0000 |
commit | afcf9657fc327b8852f9a39feebb0fd00fb3a33c (patch) | |
tree | fddc458a5ea10157c05e32c0c961b0efb1758490 | |
parent | b39338a5f1024304ab706fb8d4d59cfc24ba4b8a (diff) |
jvlisting 0.7 (18nov11)
git-svn-id: svn://tug.org/texlive/trunk@24638 c570f23f-e606-0410-a88d-b1316a301751
-rw-r--r-- | Master/texmf-dist/doc/latex/jvlisting/examples.tex | 4 | ||||
-rw-r--r-- | Master/texmf-dist/doc/latex/jvlisting/jvlisting.pdf | bin | 192993 -> 193906 bytes | |||
-rw-r--r-- | Master/texmf-dist/doc/latex/jvlisting/test.tex | 36 | ||||
-rw-r--r-- | Master/texmf-dist/source/latex/jvlisting/jvlisting.dtx | 36 | ||||
-rw-r--r-- | Master/texmf-dist/tex/latex/jvlisting/jvlisting.sty | 10 |
5 files changed, 67 insertions, 19 deletions
diff --git a/Master/texmf-dist/doc/latex/jvlisting/examples.tex b/Master/texmf-dist/doc/latex/jvlisting/examples.tex index 6c7e759a2e6..218780eeaf4 100644 --- a/Master/texmf-dist/doc/latex/jvlisting/examples.tex +++ b/Master/texmf-dist/doc/latex/jvlisting/examples.tex @@ -50,8 +50,8 @@ \end{nlisting} \newwrite\outfile -\newcommand{\copytypeset}[1]{\immediate\write\outfile{#1}% - \ListingTypesetLine{#1}} +\newcommand{\copytypeset}[1]{\ListingTypesetLine{#1}% + {\DisableLigatureFix\immediate\write\outfile{#1}}} \NewListingEnvironment{copylisting}{1}{\prelistingskip}% {\immediate\openout\outfile=#1\listingfont}{\copytypeset}% {\immediate\closeout\outfile\postlistingskip} diff --git a/Master/texmf-dist/doc/latex/jvlisting/jvlisting.pdf b/Master/texmf-dist/doc/latex/jvlisting/jvlisting.pdf Binary files differindex 423cdbd8d71..4a160aaa047 100644 --- a/Master/texmf-dist/doc/latex/jvlisting/jvlisting.pdf +++ b/Master/texmf-dist/doc/latex/jvlisting/jvlisting.pdf diff --git a/Master/texmf-dist/doc/latex/jvlisting/test.tex b/Master/texmf-dist/doc/latex/jvlisting/test.tex index 6f70c19f988..ffa59a95f5d 100644 --- a/Master/texmf-dist/doc/latex/jvlisting/test.tex +++ b/Master/texmf-dist/doc/latex/jvlisting/test.tex @@ -15,6 +15,8 @@ \parindent0pt \parskip1ex +\newwrite\outfile + \begin{document} \begin{center} @@ -239,7 +241,6 @@ The column break should {\em not} be immediately after \verb|line3|. \begin{test}{5} (\verb|\filelisting|) The following two listings should look the same. -\newwrite\outfile \immediate\openout\outfile=tmp.txt \immediate\write\outfile{line1} \immediate\write\outfile{line2} @@ -321,4 +322,37 @@ line3 \end{listing} \end{test} +\newcommand{\writetofile}[1]{\immediate\write\outfile{#1}} +\NewListingEnvironment{filetestlisting}{0}{}% + {\immediate\openout\outfile=tmp.txt}{\writetofile}% + {\immediate\closeout\outfile} + +\begin{test}{7.1} (writing listings to file) + The following two lines should be the same. + \setlength{\listingskipamount}{0pt}% + \begin{listing} + a line with ``quotes'', \slashes and potential ligatures: ` ?` !` ' + \end{listing} + \begin{filetestlisting} + a line with ``quotes'', \slashes and potential ligatures: ` ?` !` ' + \end{filetestlisting} + \filelisting{tmp.txt} +\end{test} + +\newcommand{\copytypeset}[1]{\ListingTypesetLine{#1}% + {\DisableLigatureFix\immediate\write\outfile{#1}}} +\NewListingEnvironment{copylisting}{0}{\prelistingskip}% + {\immediate\openout\outfile=tmp.txt\listingfont}{\copytypeset}% + {\immediate\closeout\outfile\postlistingskip} + +\begin{test}{7.2} (simultaneously typesetting and writing to a file) + The following four lines should be the same. + \setlength{\listingskipamount}{0pt}% + \begin{copylisting} + a line with ``quotes'', \slashes and potential ligatures: ` ?` !` ' + a line with ``quotes'', \slashes and potential ligatures: ` ?` !` ' + \end{copylisting} + \filelisting{tmp.txt} +\end{test} + \end{document} diff --git a/Master/texmf-dist/source/latex/jvlisting/jvlisting.dtx b/Master/texmf-dist/source/latex/jvlisting/jvlisting.dtx index d269491bb57..c1f038906a9 100644 --- a/Master/texmf-dist/source/latex/jvlisting/jvlisting.dtx +++ b/Master/texmf-dist/source/latex/jvlisting/jvlisting.dtx @@ -269,9 +269,16 @@ listings with additional line numbers can be defined as follows: \medbreak -\textbf{Example.} The following code defines a new -\verb|copylisting| environment which does not only typeset the source -code, but also saves a copy in an external file. +\textbf{Example.} The following code defines a new \verb|copylisting| +environment which does not only typeset the source code, but also +saves a copy in an external file. Here we need to be careful in case +the quote character \verb|`| can be present in the listing: by +default, \verb|\listingfont| makes \verb|`| an active character in +order to prevent problems with ligatures, but this fix causes damage +to the output of the \verb|\write| command. To work around this +problem, we can use \verb|\DisableLigatureFix| (defined by the +\verb|jvlisting| package for just this purpose) to temporarily disable +the ligature fix. % \iffalse %</usage> %<*examples|usage> @@ -279,8 +286,8 @@ code, but also saves a copy in an external file. % \begin{macrocode} \newwrite\outfile -\newcommand{\copytypeset}[1]{\immediate\write\outfile{#1}% - \ListingTypesetLine{#1}} +\newcommand{\copytypeset}[1]{\ListingTypesetLine{#1}% + {\DisableLigatureFix\immediate\write\outfile{#1}}} \NewListingEnvironment{copylisting}{1}{\prelistingskip}% {\immediate\openout\outfile=#1\listingfont}{\copytypeset}% {\immediate\closeout\outfile\postlistingskip} @@ -391,7 +398,7 @@ string. % for the package file. % \begin{macrocode} \NeedsTeXFormat{LaTeX2e} -\ProvidesPackage{jvlisting}[2011/10/28 v0.6 Formatted Program Listings] +\ProvidesPackage{jvlisting}[2011/11/17 v0.7 Formatted Program Listings] % \end{macrocode} % \subsection{Processing the Lines of Input} @@ -499,14 +506,12 @@ string. % In order to allow for verbatim printing, the macro % \verb|jvl@fixparsing| switches off the special meaning of most % characters. Some care is needed to avoid problems with spaces and -% ligatures like \verb|?`|. +% hyphenation. % \begin{macrocode} {\catcode`\ =\active% \gdef\jvl@obeyspaces{\frenchspacing\catcode`\ =\active\let \space}} -{\catcode`\`=\active\gdef`{\relax\lq}} -\gdef\jvl@noligs{\catcode`\`=\active} \def\jvl@fixparsing{\let\do\@makeother\dospecials\catcode`\^^I=12 - \jvl@obeyspaces\jvl@noligs\hyphenchar\font\m@ne} + \jvl@obeyspaces\hyphenchar\font\m@ne} % \end{macrocode} % Since the \verb|\hyphenchar| setting is global, we save save the @@ -595,7 +600,16 @@ string. \newcount\prelistingpenalty \prelistingpenalty=100 \newcount\listingpenalty \listingpenalty=500 \newcount\postlistingpenalty \postlistingpenalty=-50 -\def\normallistingfont{\normalfont\ttfamily} +% \end{macrocode} +% Finally, we define the default font for use in listings. Some care +% is needed to avoid problems with ligatures like \verb|?`|. We break +% such ligatures by making \verb|`| and active character. For use in +% file listings we also provide \verb|\DisableLigatureFix| to +% (temporarily) disable this fix. +% \begin{macrocode} +{\catcode`\`=\active\gdef`{\relax\lq}% +\gdef\DisableLigatureFix{\def`{\lq}}} +\def\normallistingfont{\normalfont\ttfamily\catcode`\`=\active} % \end{macrocode} % \iffalse %</package> diff --git a/Master/texmf-dist/tex/latex/jvlisting/jvlisting.sty b/Master/texmf-dist/tex/latex/jvlisting/jvlisting.sty index 89f9ce7cb97..526d3ad1e8c 100644 --- a/Master/texmf-dist/tex/latex/jvlisting/jvlisting.sty +++ b/Master/texmf-dist/tex/latex/jvlisting/jvlisting.sty @@ -26,7 +26,7 @@ %% derived files jvlisting.sty, jvlisting.ins and examples.tex. \NeedsTeXFormat{LaTeX2e} -\ProvidesPackage{jvlisting}[2011/10/28 v0.6 Formatted Program Listings] +\ProvidesPackage{jvlisting}[2011/11/17 v0.7 Formatted Program Listings] \def\jvl@iterlines#1{\expandafter\jvl@iterla\expandafter{#1}{\jvl@dropempty}} {\obeylines\gdef\jvl@iterla#1#2#3 @@ -92,10 +92,8 @@ {\catcode`\ =\active% \gdef\jvl@obeyspaces{\frenchspacing\catcode`\ =\active\let \space}} -{\catcode`\`=\active\gdef`{\relax\lq}} -\gdef\jvl@noligs{\catcode`\`=\active} \def\jvl@fixparsing{\let\do\@makeother\dospecials\catcode`\^^I=12 - \jvl@obeyspaces\jvl@noligs\hyphenchar\font\m@ne} + \jvl@obeyspaces\hyphenchar\font\m@ne} \newcount\jvl@tmphyphenchar \def\jvl@begingroup{\jvl@tmphyphenchar=\hyphenchar\font @@ -153,7 +151,9 @@ \newcount\prelistingpenalty \prelistingpenalty=100 \newcount\listingpenalty \listingpenalty=500 \newcount\postlistingpenalty \postlistingpenalty=-50 -\def\normallistingfont{\normalfont\ttfamily} +{\catcode`\`=\active\gdef`{\relax\lq}% +\gdef\DisableLigatureFix{\def`{\lq}}} +\def\normallistingfont{\normalfont\ttfamily\catcode`\`=\active} \let\listingfont=\normallistingfont \newcommand{\ListingTypesetLine}[1]{\ifvmode\penalty\listingpenalty\noindent\fi |