diff options
Diffstat (limited to 'Master/texmf-dist/doc/support')
40 files changed, 2416 insertions, 881 deletions
diff --git a/Master/texmf-dist/doc/support/crossrefware/Makefile b/Master/texmf-dist/doc/support/crossrefware/Makefile index c8caf35d606..fb54525cbaf 100644 --- a/Master/texmf-dist/doc/support/crossrefware/Makefile +++ b/Master/texmf-dist/doc/support/crossrefware/Makefile @@ -25,6 +25,11 @@ check: pod2man -c "LATEX CROSSREFWARE" -n $* -s 1 -r "" $< > $@ +lastrel = /home/ftp/tex-archive/support/crossrefware +reldiff: + diff -u0r $(lastrel) . +gitdiff: + git diff clean: $(RM) *.aux *.toc *.log *.tex *.idx *.ilg *.ind *.out *.zip *.tgz *~ diff --git a/Master/texmf-dist/doc/support/crossrefware/README b/Master/texmf-dist/doc/support/crossrefware/README index 05d375253e9..d2de384b799 100644 --- a/Master/texmf-dist/doc/support/crossrefware/README +++ b/Master/texmf-dist/doc/support/crossrefware/README @@ -1,5 +1,5 @@ Crossrefware Bundle - version 2024-01-31 + version 2024-08-27 Scripts useful for working with Crossref, MathSciNet and Zentralblatt MATH. @@ -30,9 +30,14 @@ Princeton University (Mathematics Department). Thank you! Changes: +2024-08-27 - output crossref schema 5.3.1: + https://www.crossref.org/documentation/schema-library/schema-versions/ + (and update various doc urls that crossref broke.) + - more documentation on the bib*add scripts. + 2024-01-31 - exit with bad status if no \end{thebibliography}. -2022-09-11 - add "***" prefix to bib warnings. +2022-09-11 - add "*** " prefix to bib warnings. 2022-07-28 - find dev checkout of bibtexperllibs. diff --git a/Master/texmf-dist/doc/support/crossrefware/crossrefware.pdf b/Master/texmf-dist/doc/support/crossrefware/crossrefware.pdf Binary files differindex 83b8d3e8a38..18c39074d50 100644 --- a/Master/texmf-dist/doc/support/crossrefware/crossrefware.pdf +++ b/Master/texmf-dist/doc/support/crossrefware/crossrefware.pdf diff --git a/Master/texmf-dist/doc/support/crossrefware/head.ltx b/Master/texmf-dist/doc/support/crossrefware/head.ltx index 72ae89028e6..21d2b2d9bb1 100644 --- a/Master/texmf-dist/doc/support/crossrefware/head.ltx +++ b/Master/texmf-dist/doc/support/crossrefware/head.ltx @@ -30,13 +30,15 @@ upload the submission, just outputs XML. This \path{.rpi} file is a plain text representation of the metadata for one article. It is written by the \path{resphilosophica} package -(\url{https://ctan.org/pkg/resphilosophica}). It can also be created by -hand. +(\url{https://ctan.org/pkg/resphilosophica}) and the TUGboat publication +procedure (\url{https://tug.org/TUGboat/repository.html}). It can also +be created by hand. Several scripts, \path{bibdoiadd}, \path{bibmradd} and \path{bibzbladd} take a \path{bib} file, and add to each entry a DOI, MR or ZBL number correspondingly, if they can find this entry in the corresponding -database. +database. The output of these scripts reformats the BibTeX entries +where the respective fields were not already present. The \path{bbl2bib} script tries to reconstruct a \path{bib} file from the corresponding \path{thebibliography} environment. One can argue that @@ -44,7 +46,10 @@ this operation is akin to reconstructing the cow from a steak. The way the script does it is by searching for the entry in the MR database, and creating the corresponding Bib\TeX\ fields. -I am grateful to Josko Plazonic from Princeton Math Dept whose -(unpublished) Python script was an inspiration for this suite. +I am grateful to Josko Plazonic from the Princeton mathematics +department whose (unpublished) Python script was an inspiration for this +suite. -Following are manual pages for these scripts. +Following are manual pages for these scripts. See also the +\texttt{BibTeX::Parser} package +(\url{https://ctan.org/pkg/bibtexperllibs}). diff --git a/Master/texmf-dist/doc/support/digestif/INSTALL.md b/Master/texmf-dist/doc/support/digestif/INSTALL.md index f99f4b286ae..ff4ac037e0a 100644 --- a/Master/texmf-dist/doc/support/digestif/INSTALL.md +++ b/Master/texmf-dist/doc/support/digestif/INSTALL.md @@ -59,12 +59,12 @@ Packaging for a TeX distribution -------------------------------- For an installation depending only on the `texlua` interpreter from -LuaTeX (which already includes all other dependencies except cjson), +LuaTeX (which bundles all dependencies except the optional cjson), create a zip file containing `digestif/*.lua` and `data/*.tags` (no subdirectories), place it anywhere kpathsearch will find it and use the `bin/digestif.texlua` executable script. For instance: - zip -j digestif.zip digestif/*.lua tags/*.tags + zip -j digestif.zip digestif/*.lua data/*.tags install -Dt $TEXMF/scripts digestif.zip install bin/digestif.texlua $PREFIX/bin/digestif diff --git a/Master/texmf-dist/doc/support/digestif/LICENSE.md b/Master/texmf-dist/doc/support/digestif/LICENSE.md index 55165a272d6..2b19eb74af7 100644 --- a/Master/texmf-dist/doc/support/digestif/LICENSE.md +++ b/Master/texmf-dist/doc/support/digestif/LICENSE.md @@ -119,6 +119,20 @@ latex.tags: Adapted from the LaTeX2e Unofficial Reference Manual, which can be found at https://latexref.xyz/. +natbib.sty.tags: + + Copyright 1993-2010 Patrick W Daly + + This file may be distributed and/or modified under the conditions of the + LaTeX Project Public License, either version 1.3 of this license or (at + your option) any later version. The latest version of this license is in + http://www.latex-project.org/lppl.txt + and version 1.3 or later is part of all distributions of LaTeX version + 2005/12/01 or later. + + Adapted from the natbib package documentation, which can be found at + https://ctan.org/pkg/natbib + pgf.tags: Copyright 2007-2013 Till Tantau diff --git a/Master/texmf-dist/doc/support/digestif/README.md b/Master/texmf-dist/doc/support/digestif/README.md index a7528020ece..25b4fe49209 100644 --- a/Master/texmf-dist/doc/support/digestif/README.md +++ b/Master/texmf-dist/doc/support/digestif/README.md @@ -2,7 +2,7 @@ Digestif ======== <p align="center"> -<a href="https://app.travis-ci.com/astoff/digestif"><img src="https://app.travis-ci.com/astoff/digestif.svg?branch=main" alt="Build Status"></a> +<a href="https://github.com/astoff/digestif/actions/workflows/test.yml"><img src="https://github.com/astoff/digestif/actions/workflows/test.yml/badge.svg"></a> <a href="https://ctan.org/pkg/digestif"><img alt="CTAN" src="https://img.shields.io/ctan/v/digestif?color=blue"></a> <a href="https://luarocks.org/modules/astoff/digestif"><img alt="LuaRocks" src="https://img.shields.io/luarocks/v/astoff/digestif?color=blue"></a> </p> @@ -12,18 +12,20 @@ ConTeXt et caterva. It provides context-sensitive completion, documentation, code navigation, and related functionality to any text editor that speaks the LSP protocol. -<p align="center"><img src="https://raw.githubusercontent.com/astoff/digestif/images/screenshot.gif" alt="Madatory GIF"></p> - Features -------- - Completion for commands, environments, key-value options (for instance, TikZ options), cross-references and citations. + <p align="center"><img src="https://raw.githubusercontent.com/astoff/digestif/images/completion.png"></p> + - Popup help messages, including command signature and documentation. For the best results, make sure you have the [LaTeX reference manual][latexref] installed as an [info node][info-issues]. + <p align="center"><img src="https://raw.githubusercontent.com/astoff/digestif/images/help.png"></p> + - Find definition and references to labels and citations. - Document outline. @@ -37,12 +39,16 @@ Features - Digestif is fuzzy! For citations, it tries an exact match against the BibTeX identifier and a fuzzy match against author and title. - In the GIF above, the user types `groalhom`, which matches + In the picture below, the user typed `groalhom`, which matches **Gro**thendieck's “Sur quelques points d'**al**gébre **hom**ologique”; selecting this inserts the BibTeX identifier - `Tohoku`. Similarly, for cross-references, Digestif tries an exact - match against the label and a fuzzy match against the text around - the label. + `Tohoku`. + + <p align="center"><img src="https://raw.githubusercontent.com/astoff/digestif/images/cite.png"></p> + + Similarly, for cross-references, Digestif tries an exact match + against the label and a fuzzy match against the text around the + label. - Support for LaTeX, ConTeXt, plain TeX, DocTeX (`.dtx` files) and Texinfo. @@ -112,6 +118,10 @@ To ensure that Digestif is used, add the following to your init file: See instructions [here](https://github.com/neoclide/coc.nvim/wiki/Language-servers#latex). +### Sublime Text with the [LSP](https://packagecontrol.io/packages/LSP) package + +See instructions [here](https://lsp.sublimetext.io/language_servers/#digestif). + ### Other editors It shouldn't be hard to set up other editors to use Digestif. Please diff --git a/Master/texmf-dist/doc/support/digestif/bin/digestif b/Master/texmf-dist/doc/support/digestif/bin/digestif index 818d5b355ac..73b51457b46 100755 --- a/Master/texmf-dist/doc/support/digestif/bin/digestif +++ b/Master/texmf-dist/doc/support/digestif/bin/digestif @@ -1,2 +1,5 @@ #!/usr/bin/env lua +-- Remove relative directories from package path +package.path = package.path:gsub("%f[^\0;]%.[^;]*", ""):gsub(";+", ";"):gsub("^;", ""):gsub(";$", "") +package.cpath = package.cpath:gsub("%f[^\0;]%.[^;]*", ""):gsub(";+", ";"):gsub("^;", ""):gsub(";$", "") require "digestif.langserver".main(arg) diff --git a/Master/texmf-dist/doc/support/latexdiff/README b/Master/texmf-dist/doc/support/latexdiff/README index 6f4d1a280a8..f0310ce32db 100644 --- a/Master/texmf-dist/doc/support/latexdiff/README +++ b/Master/texmf-dist/doc/support/latexdiff/README @@ -1,4 +1,13 @@ +latexdiff +========= + +Compares two latex files and marks up significant differences between them. Releases on https://ctan.org/pkg/latexdiff and mirrors. + +Link to full manual: http://mirrors.ctan.org/support/latexdiff/doc/latexdiff-man.pdf + + INTRODUCTION +------------ latexdiff is a Perl script, which compares two latex files and marks up significant differences between them (i.e. a diff for latex files). @@ -16,11 +25,9 @@ behaviour and accept or reject selected changes only. The author is F Tilmann. -Project webpage: https://github.com/ftilmann/latexdiff/ -CTAN page: http://www.ctan.org/pkg/latexdiff - REQUIREMENTS +------------ Perl 5.8 or higher must be installed. The latexdiff script makes use of the Perl package Algorithm::Diff (available @@ -38,6 +45,7 @@ UNIX-diff mean that the resulting set of differences will generally not be the s for the standard latexdiff. In most practical cases, these differences are minor, though. INSTALLATION UNIX/LINUX +----------------------- The basic installation procedure is almost trivial: @@ -53,34 +61,40 @@ The basic installation procedure is almost trivial: The attached trivial Makefile contains example commands to carry out above steps as root for a typical UNIX installation. Type - make install (for the stand alone version) + `make install` (for the stand alone version) + or - make install-ext (for the version using the external Algorithm::Diff) + + `make install-ext` (for the version using the external Algorithm::Diff) + or - make install-fast (for the version using the UNIX 'diff' function for fast differencing) + + `make install-fast` (for the version using the UNIX 'diff' function for fast differencing) to get it rolling. You can type - make test -or - make test-ext -or - make test-fast + `make test` or + + `make test-ext` or + + `make test-fast` to test the respective versions on a brief example before installation. It will often be as easy to carry out these steps manually instead of using the Makefile. -DOCUMENTATION: +DOCUMENTATION +------------- Usage instructions are in the manual latexdiff-man.pdf as well as the man pages. -CHANGELOGS: - +CHANGELOGS +---------- Check out the comment lines at the beginning of the perl scripts (latexdiff, latexdiff-vc, latexrevise) CONTRIBUTIONS +------------- The directory contrib contains code written by others relating to latexdiff. Currently this directory contains: @@ -97,15 +111,19 @@ Contributions by the following authors were incorporated into the latexdiff code extend latexdiff in a similar way: J. Paisley, N. Becker, K. Huebner EXTERNAL LATEXDIFF SUPPORT PROGRAMS +----------------------------------- + +LATEXDIDFFR (Author: David Hugh-Jones) is a small library that uses the latexdiff command to create a diff of two Rmarkdown, .Rnw or TeX files. +https://github.com/hughjonesd/latexdiffr LATEXDIFFCITE (Author: Christer van der Meeren) is a wrapper around latexdiff to make citations diff properly. It works by expanding \cite type commands using the bbl or bib file, such that citations are treated just like normal text rather than as atomic in the plain latexdiff. -https://latexdiffcite.readthedocs.org +https://github.com/twilsonco/latexdiffcite GIT-LATEXDIFF (lead author: Matthieu Moy) is a wrapper (bash script) around latexdiff that allows using it to diff two revisions of a LaTeX file under git revision control (similar functionality is provided by latexdiff-vc --git with --flatten option included with this distribution but git-latexdiff allows more fine-grained control on (not to be confused with latexdiff-git, which is normally installed as a soft link to latexdiff-vc) https://gitorious.org/git-latexdiff/ -LICENSE (also see file COPYING) - +LICENSE +------- This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License Version 3 as published by the Free Software Foundation. @@ -116,3 +134,6 @@ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details (file LICENSE in the distribution). + + + diff --git a/Master/texmf-dist/doc/support/latexdiff/doc/example-diff.tex b/Master/texmf-dist/doc/support/latexdiff/doc/example-diff.tex index 8eda2a43aa8..b68c11aff9f 100644 --- a/Master/texmf-dist/doc/support/latexdiff/doc/example-diff.tex +++ b/Master/texmf-dist/doc/support/latexdiff/doc/example-diff.tex @@ -22,7 +22,7 @@ \RequirePackage[normalem]{ulem} %DIF PREAMBLE \RequirePackage{color}\definecolor{RED}{rgb}{1,0,0}\definecolor{BLUE}{rgb}{0,0,1} %DIF PREAMBLE \providecommand{\DIFadd}[1]{{\protect\color{blue}\uwave{#1}}} %DIF PREAMBLE -\providecommand{\DIFdel}[1]{{\protect\color{red}\sout{#1}}} %DIF PREAMBLE +\providecommand{\DIFdel}[1]{{\protect\color{red}\sout{#1}}} %DIF PREAMBLE %DIF SAFE PREAMBLE %DIF PREAMBLE \providecommand{\DIFaddbegin}{} %DIF PREAMBLE \providecommand{\DIFaddend}{} %DIF PREAMBLE @@ -53,6 +53,8 @@ } %DIF PREAMBLE \lstnewenvironment{DIFverbatim}{\lstset{style=DIFverbatimstyle}}{} %DIF PREAMBLE \lstnewenvironment{DIFverbatim*}{\lstset{style=DIFverbatimstyle,showspaces=true}}{} %DIF PREAMBLE +\lstset{extendedchars=\true,inputencoding=utf8} + %DIF END PREAMBLE EXTENSION ADDED BY LATEXDIFF \begin{document} diff --git a/Master/texmf-dist/doc/support/latexdiff/doc/latexdiff-man.pdf b/Master/texmf-dist/doc/support/latexdiff/doc/latexdiff-man.pdf Binary files differindex 2ea00571b30..d0e57ad5c96 100644 --- a/Master/texmf-dist/doc/support/latexdiff/doc/latexdiff-man.pdf +++ b/Master/texmf-dist/doc/support/latexdiff/doc/latexdiff-man.pdf diff --git a/Master/texmf-dist/doc/support/latexdiff/latexdiff b/Master/texmf-dist/doc/support/latexdiff/latexdiff index a032ae23b53..5df02b753f6 100755 --- a/Master/texmf-dist/doc/support/latexdiff/latexdiff +++ b/Master/texmf-dist/doc/support/latexdiff/latexdiff @@ -25,6 +25,21 @@ # # Note references to issue numbers are for the github repository of latexdiff: https://github.com/ftilmann/latexdiff # +# Version 1.3.4: +# New features: +# - Option to use lua-ul instead of ulem (for use with LuaLaTeX) (fix #17, #60, #188, #255, #270) +# Enhancement +# - If amsmath is detected as one of the included (based on idea in PR #263 contributed by github user xlucn +# Bug fix +# - sometimes the introduction of aux commands to show deleted lists or descriptions leaves in place empty auxiliary +# list environments, which would cause error messages (though skipping messages would result in a correct output pdf). +# These are now removed. +# - add more mboxsafecmd and safecmd commands for SIunitx to stay compatible with newer versionsof SIunitx (PR #283, fixing issue #282, contributed by github user joe6302413) +# - File added via --preamble option is no longer assumed to be ASCII, but read either with encoding as defined by --encoding option or using the encoding of the LOCALE (fixes issue #285 ) +# - multicolumn argument is now treated as text +# - when tikz-dependency package is used, \& is no longer a safe command as it has special meaning inside dependency environment. The fix is a little of a hack as really it should only be considered unsafe within dependency environment (fixes (mostly) issue #303 ) +# - listings package had trouble with non-ASCII chars. The encoding is now set (thanks to github user anka-213 for finding this). Fixes #304 +# # Version 1.3.3: # New features: # - Option --no-del to remove all deleted text (merge contributed by github user tdegeus PR #252, fixing issue #66 @@ -33,22 +48,22 @@ # - Abbreviations involving punctuations within them. They need special treatment because otherwise in some # circumstances the gnoring of white space differences in conjunction with merging according to MINWORDSBLOCK rule # could turn 'i.e.' into 'i.\PAR e.' (see https://github.com/ftilmann/latexdiff/issues/269). A few abbreviations -# are now hard-coded and treated as atomic: +# are now hard-coded and treated as atomic: # English: i.e., e.g. Deutsch: z.B. # (fixes issue #269) # - In WHOLE and COARSE math modes, now properly treat math environments with arguments such as \alignat. Fixes #251 -# - For FINE math mode, multiple improvments to the processing work flow yield more robust outcomes. In particular, changes -# to the equation type, e.g. \begin{displaymath} -> \begin{equation} without modifications now usually no longer result -# in errors. (Partially) fixes issues #235 and #244. -# - When encountering deleted math array environments such as align or eqnarray, rather than replacing them with a -# fixed replacement environment (e.g. align* or eqnarray*), an asterisk is now added to the original command, which +# - For FINE math mode, multiple improvments to the processing work flow yield more robust outcomes. In particular, changes +# to the equation type, e.g. \begin{displaymath} -> \begin{equation} without modifications now usually no longer result +# in errors. (Partially) fixes issues #235 and #244. +# - When encountering deleted math array environments such as align or eqnarray, rather than replacing them with a +# fixed replacement environment (e.g. align* or eqnarray*), an asterisk is now added to the original command, which # in amsmath (and with eqnarray) will result in the same environment but without line numbers. Config variable MATHARRREPL # is therefore (nearly) redundant, and a depracation warning is given when it is set. Reference to MATHARRREPL are have # been removed from the manual (there is one exception, when it's still being used: sometimes latexdiff can figure out # that there is a deleted array environment, but does not know which one. In this case, MATHARRREPL is still being used -# to encapsulate these parts of the source, and therefore it is still set internally. But this is a quite rare situation). +# to encapsulate these parts of the source, and therefore it is still set internally. But this is a quite rare situation). # Fixes issue #216 -# - Unlike 'array' environment, 'split' (amsmath) does not work in argument of \DIFadd or \DIFdl in UNDERLINE modes; therefore remove it from ARRENV configuration variable. +# - Unlike 'array' environment, 'split' (amsmath) does not work in argument of \DIFadd or \DIFdl in UNDERLINE modes; therefore remove it from ARRENV configuration variable. # Exclude \begin and \end in math environments in COARSE and WHOLE modes. Fixes #258. Fixes #109 # - --flatten now works for empty files. Fixes issue #242 # - improved processing of Chinese and Japanese texts in that splitting is done based on characters. Thanks to LuXu (Oliver Lew) in git for working this out. Fixes #229, fixes #145 @@ -65,7 +80,7 @@ # Bug fixes: # - fix issue #206 affecting proper markup of text commands which are not also safe cmd's and have multiple arguments # - fix issue #210 by adding \eqref (amsmath package) to the list of safe commands -# - fix bug reported in issue #168 mangled verbatim line environment +# - fix bug reported in issue #168 mangled verbatim line environment # - fix bug reported in issue #218 by replacing \hspace{0pt} after \mbox{..} auxiliary commands with \hskip0pt. # - more ways to process \frac correctly with atomic arguments (committed by julianuu PR #246 # - fix a bug in biblatex mode, which prevented proper processing of modified \textcite (see: https://tex.stackexchange.com/questions/555157/latexdiff-and-biblatex-citation-commands) @@ -74,10 +89,10 @@ # Version 1.3.1.1 # - remove spurious \n to fix error: Unknown regexp modifier "/n" at .../latexdiff line 1974, near "=~ " (see github issue #201) # -# Version 1.3.1 +# Version 1.3.1 # Bug fixes: # - remove some uninitialised variable $2 warnings in string substitution in flatten function in case included file is not found -# - add minimal postprocessing to diff processing of preamble commands (replace \RIGHTBRACE by \} ) +# - add minimal postprocessing to diff processing of preamble commands (replace \RIGHTBRACE by \} ) # - pre-processing: replace (contributed) routine take_comments_and_enter_from_frac() with take_comments_and_newline_from_frac(), which does the same thing # (remove whitespace characters and comments between the argument of \frac commands) in an easier and more robust way. In addition, it # will replace commands like \frac12 with \frac{1}{2} as pre-processing step. Fixes issue #184 @@ -95,15 +110,15 @@ # Version 1.3.0 (7 October 2018): # - treat options to \documentclass as potential package names (some packages allow implicit loading of or imply selected packages # - improved pattern matching: now allows nested angular brackets, and is no longer confused by escaped curly braces -# - improved pattern matching in COARSE mode: occasionally, the closing bracket or some other elements would be matched in an 'unnatural' way due to another sequence being more minimal in the computational sense, sometimes even causing errors due to tokens moving in or out of the scope of math environments. This is now discouraged by adding internal \DIFANCHOR commands (which are removed again in post-processing) (fixes issues reported via email by li_ruomeng . +# - improved pattern matching in COARSE mode: occasionally, the closing bracket or some other elements would be matched in an 'unnatural' way due to another sequence being more minimal in the computational sense, sometimes even causing errors due to tokens moving in or out of the scope of math environments. This is now discouraged by adding internal \DIFANCHOR commands (which are removed again in post-processing) (fixes issues reported via email by li_ruomeng . # - verbatim and lstlisting environments are marked-up with line-by-line in a similar style to non-verbatim text (requires the listing package to be installed) # (see new configuration variable VERBATIMLINEENV) (several issues and pull requests by jprotze) -# - --flatten: now supports \verbatiminput and \lstlistinput +# - --flatten: now supports \verbatiminput and \lstlistinput # - --flatten: if file is not found, do not fail, simply warn and leave command unexpanded (inspired by issue #112). Don't warn if file name contains #[0-9] as it is then most likely an argument within a command definition rather than an actual file (applies to \input, \subfile, \include commands) # - added to textcmds: \intertext # - new config variable CUSTOMDIFCMD to allow defining special versions of commands in added or deleted blocks (Pull request by github user jprotze) # - added option -no-links (mostly for use by latexdiff-vc in only-changes modes) (Pull request by github user jprotze) -# - new option --filter-script to run both input through a pre-processing script (PR jasonmccsmith #167) +# - new option --filter-script to run both input through a pre-processing script (PR jasonmccsmith #167) # new option --no-filter-stderr to hide stderr output from filter-script (potentially dangerous, as this might hide malfunctioning of filter scripts) # - --flatten now can deal with imports made using the import package {PR jasonmccsmith #173) # Bug fixes: @@ -122,12 +137,12 @@ # make environments that are treated like verbatim environments configurable (config variable VERBATIMENV) # treat lstinlne as equivalent to verb command # partially addresses issue #38 -# - refactoring: set default configuration variables in a hash, and those that correspond to lists +# - refactoring: set default configuration variables in a hash, and those that correspond to lists # - feature: option --add-to-config used to amend configuration variables, which are regex pattern lists # - bug fix: deleted figures when endfloat package is activated # - bug fix: alignat environment now always processed correctly (fix issues #65) # - bug fix: avoid processing of commands as potential files in routine init_regex_arr (fix issue #70 ) -# - minimal feature enhancement: treat '@' as allowed character in commands (strictly speaking requires prior \makeatletter statement, but always assuming it to be +# - minimal feature enhancement: treat '@' as allowed character in commands (strictly speaking requires prior \makeatletter statement, but always assuming it to be # @ a letter if it is part of a command name will usually lead to the correct behaviour (see http://tex.stackexchange.com/questions/346651/latexdiff-and-let) # - new feature/bug fix: --flatten option \endinput in included files now respected but only if \endinput stands right at the beginning of the line (issue #77) # - bug fix: flatten would incorrectly attempt to process commented out \include commands (from discussion in issue #77 ) @@ -165,7 +180,7 @@ # - introduce list UNSAFEMATHCMD, which holds list of commands which cannot be marked up with \DIFadd or \DIFdel commands (only relevant for WHOLE and COARSE math markup modes) # - new subtype LABEL which gives each change a label. This can later be used to only display pages where changes # have been made (instructions for that are put as comments into the diff'ed file) inspired by answer on http://tex.stackexchange.com/questions/166049/invisible-markers-in-pdfs-using-pdflatex -# - Configuration variables take into accout some commands from additional packages: +# - Configuration variables take into accout some commands from additional packages: # tikzpicture environment now treated as PICTUREENV, and \smallmatrix in ARRENV (amsmath) # - --flatten: support for \subfile command (subfiles package) (in response to http://tex.stackexchange.com/questions/167620/latexdiff-with-subfiles ) # - --flatten: \bibliography commands expand if corresponding bbl file present @@ -179,11 +194,11 @@ # - \% in one-letter sub/Superscripts was not converted correctly # # Version 1.0.3 -# - fix bug in add_safe_commands that made latexdiff hang on DeclareMathOperator +# - fix bug in add_safe_commands that made latexdiff hang on DeclareMathOperator # command in preamble # - \(..\) inline math expressions were not parsed correctly, if they contained a linebreak # - applied patch contributed by tomflannaghan via Berlios: [ Patch #3431 ] Adds correct handling of \left< and \right> -# - \$ is treated correctly as a literal dollar sign (thanks to Reed Cartwright and Joshua Miller for reporting this bug +# - \$ is treated correctly as a literal dollar sign (thanks to Reed Cartwright and Joshua Miller for reporting this bug # and sketching out the solution) # - \^ and \_ are correctly interpreted as accent and underlined space, respectively, not as superscript of subscript # (thanks to Wail Yahyaoui for pointing out this bug) @@ -191,19 +206,19 @@ # Version 1.0.1 - treat \big,\bigg etc. equivalently to \left and # \right - include starred version in MATHENV - apply # - flatten recursively and --flatten expansion is now -# aware of comments (thanks to Tim Connors for patch) +# aware of comments (thanks to Tim Connors for patch) # - Change to post-processing for more reliability for # deleted math environments -# - On linux systems, recognise and remove DOS style newlines +# - On linux systems, recognise and remove DOS style newlines # - Provide markup for some special preamble commands (\title, -# \author,\date, -# - configurable by setting context2cmd +# \author,\date, +# - configurable by setting context2cmd # - for styles using ulem package, remove \emph and \text.. from list of # safe commands in order to allow linebreaks within the -# highlighted sections. -# - for ulem style, now show citations by enclosing them in \mbox commands. -# This unfortunately implies linebreaks within citations no longer function, -# so this functionality can be turned off (Option --disable-citation-markup). +# highlighted sections. +# - for ulem style, now show citations by enclosing them in \mbox commands. +# This unfortunately implies linebreaks within citations no longer function, +# so this functionality can be turned off (Option --disable-citation-markup). # With --enable-citation-markup, the mbox markup is forced for other styles) # - new substyle COLOR. This is particularly useful for marking up citations # and some special post-processing is implemented to retain cite @@ -211,11 +226,11 @@ # - four different levels of math-markup # - Option --driver for choosing driver for modes employing changebar package # - accept \\* as valid command (and other commands of form \.*). Also accept -# \<nl> (backslashed newline) +# \<nl> (backslashed newline) # - some typo fixes, include commands defined in preamble as safe commands -# (Sebastian Gouezel) +# (Sebastian Gouezel) # - include compared filenames as comments as line 2 and 3 of -# the preamble (can be modified with option --label, and suppressed with +# the preamble (can be modified with option --label, and suppressed with # --no-label), option --visible-label to show files in generated pdf or dvi # at the beginning of main document # @@ -231,7 +246,7 @@ # # Version 0.4 March 06 option for fast differencing using UNIX diff command, several minor bug fixes (\par bug, improved highlighting of textcmds) # -# Version 0.3 August 05 improved parsing of displayed math, --allow-spaces +# Version 0.3 August 05 improved parsing of displayed math, --allow-spaces # option, several minor bug fixes # # Version 0.25 October 04 Fix bug with deleted equations, add math mode commands to safecmd, add | to allowed interpunctuation signs @@ -247,12 +262,13 @@ use utf8 ; use File::Spec ; + my ($algodiffversion)=split(/ /,$Algorithm::Diff::VERSION); my ($versionstring)=<<EOF ; -This is LATEXDIFF 1.3.3 (Algorithm::Diff $Algorithm::Diff::VERSION, Perl $^V) - (c) 2004-2022 F J Tilmann +This is LATEXDIFF 1.3.4 (Algorithm::Diff $Algorithm::Diff::VERSION, Perl $^V) + (c) 2004-2024 F J Tilmann EOF # Hash with defaults for configuration variables. These marked undef have default values constructed from list defined in the DATA block @@ -343,9 +359,9 @@ my $DELCMDOPEN='%DIFDELCMD < '; # To mark begin of deleted commands (must begin my $DELCMDCLOSE="%%%\n"; # To mark end of deleted commands (must end with a new line) my $AUXCMD='%DIFAUXCMD' ; # follows auxiliary commands put in by latexdiff to make difference file legal # auxiliary commands must be on a line of their own - # Note that for verbatim environment openings the %DIFAUXCMD cannot be placed in + # Note that for verbatim environment openings the %DIFAUXCMD cannot be placed in # the same line as this would mean they are shown - # so the special form "%DIFAUXCMD NEXT" is used to indicate that the next line + # so the special form "%DIFAUXCMD NEXT" is used to indicate that the next line # is an auxiliary command # Similarly "%DIFAUXCMD LAST" would indicate the auxiliary command is in previous line (not currently used) my $DELCOMMENT='DIF < '; # To mark deleted comment line @@ -356,21 +372,21 @@ my @TEXTCMDLIST=(); # array containing patterns of commands with text arguments my @TEXTCMDEXCL=(); # array containing patterns of commands without text arguments (if a pattern # matches both TEXTCMDLIST and TEXTCMDEXCL it is excluded) my @CONTEXT1CMDLIST=(); # array containing patterns of commands with text arguments (subset of text commands), - # but which cause confusion if used out of context (e.g. \caption). + # but which cause confusion if used out of context (e.g. \caption). # In deleted passages, the command will be disabled but its argument is marked up - # Otherwise they behave exactly like TEXTCMD's + # Otherwise they behave exactly like TEXTCMD's my @CONTEXT1CMDEXCL=(); # exclude list for above, but always empty my @CONTEXT2CMDLIST=(); # array containing patterns of commands with text arguments, but which fail or cause confusion # if used out of context (e.g. \title). They and their arguments will be disabled in deleted # passages my @CONTEXT2CMDEXCL=(); # exclude list for above, but always empty my @MATHTEXTCMDLIST=(); # treat like textcmd. If a textcmd is in deleted or added block, just wrap the - # whole content with \DIFadd or \DIFdel irrespective of content. This functionality + # whole content with \DIFadd or \DIFdel irrespective of content. This functionality # is useful for pseudo commands \MATHBLOCK.. into which math environments are being - # transformed -my @MATHTEXTCMDEXCL=(); # + # transformed +my @MATHTEXTCMDEXCL=(); # -# Note I need to declare this with "our" instead of "my" because later in the code I have to "local"ise these +# Note I need to declare this with "our" instead of "my" because later in the code I have to "local"ise these our @SAFECMDLIST=(); # array containing patterns of safe commands (which do not break when in the argument of DIFadd or DIFDEL) our @SAFECMDEXCL=(); my @MBOXCMDLIST=(); # patterns for commands which are in principle safe but which need to be surrounded by an \mbox @@ -435,7 +451,7 @@ $mathmarkup=COARSE; $verbose=0; $onlyadditions=0; # output debug and intermediate files, set to 0 in final distribution -$debug=0; +$debug=0; # insert preamble directly after documentclass - experimental feature, set to 0 in final distribution # Note that this failed with mini example (or other files, where packages used in latexdiff preamble # are called again with incompatible options in preamble of resulting file) @@ -458,9 +474,9 @@ END my %verbhash; Getopt::Long::Configure('bundling'); -GetOptions('type|t=s' => \$type, - 'subtype|s=s' => \$subtype, - 'floattype|f=s' => \$floattype, +GetOptions('type|t=s' => \$type, + 'subtype|s=s' => \$subtype, + 'floattype|f=s' => \$floattype, 'config|c=s' => \@configlist, 'add-to-config=s' => \@addtoconfiglist, 'preamble|p=s' => \$preamblefile, @@ -509,11 +525,11 @@ if ( $help ) { if ( $version ) { - print STDERR $versionstring ; + print STDERR $versionstring ; exit 0; } -print STDERR $versionstring if $verbose; +print STDERR $versionstring if $verbose; if (defined($showall)){ $showpreamble=$showsafe=$showtext=$showconfig=1; @@ -531,7 +547,7 @@ if (defined($mathmarkup)) { $mathmarkup=~tr/a-z/A-Z/; if ( $mathmarkup eq 'OFF' ){ $mathmarkup=OFF; - } elsif ( $mathmarkup eq 'WHOLE' ){ + } elsif ( $mathmarkup eq 'WHOLE' ){ $mathmarkup=WHOLE; } elsif ( $mathmarkup eq 'COARSE' ){ $mathmarkup=COARSE; @@ -634,7 +650,7 @@ foreach $config ( @configlist ) { } } foreach $assign ( @config ) { - $assign=~ m/\s*(\w*)\s*=\s*(\S*)\s*$/ or die "Illegal assignment $assign in configuration list (must be variable=value)"; + $assign=~ m/\s*(\w*)\s*=\s*(\S*)\s*$/ or die "Illegal assignment $assign in configuration list (must be variable=value)"; exists $CONFIG{$1} or die "Unknown configuration variable $1."; $CONFIG{$1}=$2; } @@ -671,7 +687,7 @@ foreach $key ( keys(%CONFIG) ) { foreach $assign ( @addtoconfig ) { ###print STDERR "assign:|$assign|\n"; - $assign=~ m/\s*(\w*)\s*=\s*(\S*)\s*$/ or die "Illegal assignment $assign in configuration list (must be variable=value)"; + $assign=~ m/\s*(\w*)\s*=\s*(\S*)\s*$/ or die "Illegal assignment $assign in configuration list (must be variable=value)"; exists $CONFIG{$1} or die "Unknown configuration variable $1."; $CONFIG{$1}.=";$2"; } @@ -686,8 +702,8 @@ foreach ( keys(%CONFIG) ) { elsif ( $_ eq "MATHENV" ) { $MATHENV = liststringtoregex($CONFIG{$_}) ; } elsif ( $_ eq "MATHREPL" ) { $MATHREPL = $CONFIG{$_} ; } elsif ( $_ eq "MATHARRENV" ) { $MATHARRENV = liststringtoregex($CONFIG{$_}) ; } - elsif ( $_ eq "MATHARRREPL" ) { $MATHARRREPL = $CONFIG{$_} ; - print STDERR "WARNING: Setting MATHARRREPL is depracated. Generally deleted math array environments will be set to their starred varieties and the setting of MATHARREPL is ignored.\n\n" unless $MATHARRREPL =~ /eqnarray\*/ ; + elsif ( $_ eq "MATHARRREPL" ) { $MATHARRREPL = $CONFIG{$_} ; + print STDERR "WARNING: Setting MATHARRREPL is depracated. Generally deleted math array environments will be set to their starred varieties and the setting of MATHARREPL is ignored.\n\n" unless $MATHARRREPL =~ /eqnarray\*/ ; } elsif ( $_ eq "ARRENV" ) { $ARRENV = liststringtoregex($CONFIG{$_}) ; } elsif ( $_ eq "VERBATIMENV" ) { $VERBATIMENV = liststringtoregex($CONFIG{$_}) ; } @@ -714,11 +730,11 @@ foreach $pkg ( @packagelist ) { if ($showconfig || $showtext || $showsafe || $showpreamble) { show_configuration(); - exit 0; + exit 0; } -if ( @ARGV != 2 ) { +if ( @ARGV != 2 ) { print STDERR "2 and only 2 non-option arguments required. Write latexdiff -h to get help\n"; exit(2); } @@ -726,7 +742,7 @@ if ( @ARGV != 2 ) { # Are extra spaces between command arguments permissible? my $extraspace; if ($allowspaces) { - $extraspace='\s*'; + $extraspace='\s*'; } else { $extraspace=''; } @@ -749,14 +765,14 @@ push(@SAFECMDLIST, qr/^QLEFTBRACE$/, qr/^QRIGHTBRACE$/); # if you get "undefined control sequence MATHBLOCKmath" error, increase the maximum value in this loop for (my $i_pat = 0; $i_pat < 20; ++$i_pat){ $pat_n = '(?:[^{}]|\{'.$pat_n.'\}|\\\\\{|\\\\\})*'; - # Actually within the text body, quoted braces are replaced in pre-processing. The only place where + # Actually within the text body, quoted braces are replaced in pre-processing. The only place where # the last part of the pattern matters is when processing the arguments of context2cmds in the preamble # and these contain a \{ or \} combination, probably rare. # It should thus be fine to use the simpler version below. ### $pat_n = '(?:[^{}]|\{'.$pat_n.'\})*'; } - my $brat0 = '(?:[^\[\]]|\\\[|\\\])*'; + my $brat0 = '(?:[^\[\]]|\\\[|\\\])*'; my $brat_n = $brat0; for (my $i_pat = 0; $i_pat < 4; ++$i_pat){ $brat_n = '(?:[^\[\]]|\['.$brat_n.'\]|\\\[|\\\])*'; @@ -773,7 +789,7 @@ push(@SAFECMDLIST, qr/^QLEFTBRACE$/, qr/^QRIGHTBRACE$/); # could turn 'i.e.' into 'i.\PAR e.' (see https://github.com/ftilmann/latexdiff/issues/269) # English: i.e., e.g. Deutsch: z.B. my $abbreviation='(?:i\. ?e\.|e\. ?g\.|z\. ?B\.)' ; - my $number='-?\d*\.\d*'; + my $number='-?\d*\.\d*'; # word: sequence of letters or accents followed by letter my $word_cj='\p{Han}|\p{InHiragana}|\p{InKatakana}'; @@ -801,7 +817,7 @@ push(@SAFECMDLIST, qr/^QLEFTBRACE$/, qr/^QRIGHTBRACE$/); # inline math $....$ or \(..\) ### the commented out version is simpler but for some reason cannot cope with newline (in spite of s option) - need to include \newline explicitly ### my $math='\$(?:[^$]|\\\$)*?\$|\\\\[(].*?\\\\[)]'; - my $math='\$(?:[^$]|\\\$)*?\$|\\\\[(](?:.|\n)*?\\\\[)]'; + my $math='\$(?:[^$]|\\\$)*?\$|\\\\[(](?:.|\n)*?\\\\[)]'; ### test version (this seems to give the same results as version above) ## the current maths command cannot cope with newline within the math expression ### my $math='\$(?:[^$]|\\\$)*?\$|\\[(].*?\\[)]'; @@ -819,7 +835,7 @@ push(@SAFECMDLIST, qr/^QLEFTBRACE$/, qr/^QRIGHTBRACE$/); -# now we are done setting up and can start working +# now we are done setting up and can start working my ($oldfile, $newfile) = @ARGV; # check for existence of input files if ( ! -e $oldfile ) { @@ -847,7 +863,7 @@ my ($oldtime,$newtime,$oldlabel,$newlabel); if (defined($labels[0])) { $oldlabel=$labels[0] ; } else { - $oldtime=localtime((stat($oldfile))[9]); + $oldtime=localtime((stat($oldfile))[9]); $oldlabel="$oldfile " . " "x($oldlabel_n_spaces) . $oldtime; } if (defined($labels[1])) { @@ -860,6 +876,7 @@ if (defined($labels[1])) { $encoding=guess_encoding($newfile) unless defined($encoding); $encoding = "utf8" if $encoding =~ m/^utf8/i ; +print STDERR "Encoding $encoding\n" if $verbose; if (lc($encoding) eq "utf8" ) { binmode(STDOUT, ":utf8"); binmode(STDERR, ":utf8"); @@ -943,7 +960,7 @@ my @auxlines; my ($ulem)=0; if ( length $oldpreamble && length $newpreamble ) { - # pre-process preamble by looking for commands used in \maketitle (title, author, date etc commands) + # pre-process preamble by looking for commands used in \maketitle (title, author, date etc commands) # and marking up content with latexdiff markup @auxlines=preprocess_preamble($oldpreamble,$newpreamble); @@ -975,7 +992,7 @@ if (defined($graphicsmarkup)) { } else { # Default: no explicit setting in menu if ( defined $packages{"graphicx"} or defined $packages{"graphics"} ) { - $graphicsmarkup=NEWONLY; + $graphicsmarkup=NEWONLY; } else { $graphicsmarkup=NONE; } @@ -1008,7 +1025,7 @@ if ($graphicsmarkup != NONE ) { @matches=( $latexdiffpreamble =~ m/command\{\\DIFaddbeginFL}\{($pat_n)}/sg ) ; # we look at the last one of the list to take into account possible redefinition but almost always matches should have exactly one element if ( $matches[$#matches] =~ m/\\DIFaddbegin/ ) { - die "Cannot combine graphics markup with float styles defining \\DIFaddbeginFL in terms of \\DIFaddbegin. Use --graphics-markup=none option or choose a different float style."; + die "Cannot combine graphics markup with float styles defining \\DIFaddbeginFL in terms of \\DIFaddbegin. Use --graphics-markup=none option or choose a different float style."; exit 10; } ###} @@ -1022,6 +1039,11 @@ if ($graphicsmarkup != NONE ) { $ulem = ($latexdiffpreamble =~ /\\RequirePackage(?:\[$brat_n\])?\{ulem\}/ || defined $packages{"ulem"}); +# If amsmath is defined and $ulem is used for markup, redefine the \sout command to also work (mostly) in math mode +# See stack exchange https://tex.stackexchange.com/questions/20609/strikeout-in-math-mode/308647#308647 based on comment by Taylor Raine +if ( defined($packages{'amsmath'}) and $ulem ) { + $latexdiffpreamble .= join "\n",(extrapream('AMSMATHULEM'),""); +} # If listings is being used or can be found in the latexdiff search path, add to the preamble auxiliary code to enable line-by-line markup if ( defined($packages{"listings"}) or `kpsewhich listings.sty` ne "" ) { @@ -1031,7 +1053,7 @@ if ( defined($packages{"listings"}) or `kpsewhich listings.sty` ne "" ) { } my @listingDIFcode=(); my $replaced; - # note that in case user supplies preamblefile the type might not reflect well the + # note that in case user supplies preamblefile the type might not reflect well the actual markup style @listingDIFcode=extrapream("-nofail","DIFCODE_" . $type) unless defined($preamblefile); if (!(@listingDIFcode)) { # if listingDIFcode is empty try to guess a suitable one from the preamble @@ -1045,13 +1067,17 @@ if ( defined($packages{"listings"}) or `kpsewhich listings.sty` ne "" ) { @listingDIFcode=extrapream("DIFCODE_BOLD"); } } - # now splice it in + # add configuration so that listings work with utf-8 + push @listingpreamble, '\lstset{extendedchars=\true,inputencoding='.$encoding."}\n"; + + + # now splice it in $replaced=0; ###print STDERR "DEBUG: listingDIFcode: ",join("\n",@listingDIFcode),"|||\n" if $debug; - @listingpreamble=grep { + @listingpreamble=grep { # only replace if this has not been done already (use short-circuit property of and) - if (!$replaced and $_ =~ s/^.*%DIFCODE TEMPLATE.*$/join("\n",@listingDIFcode)/e ) { + if (!$replaced and $_ =~ s/^.*%DIFCODE TEMPLATE.*$/join("\n",@listingDIFcode)/e ) { ###print STDERR "DEBUG: Replaced text $_\n" if $debug; $replaced=1; 1; @@ -1081,7 +1107,7 @@ if ( length $oldpreamble && length $newpreamble ) { unshift @oldpreamble,''; @diffpreamble = linediff(\@oldpreamble, \@newpreamble); # remove dummy line again - shift @diffpreamble; + shift @diffpreamble; # add filenames, modification time and latexdiff mark defined($nolabel) or splice @diffpreamble,1,0, "%DIF LATEXDIFF DIFFERENCE FILE", @@ -1130,8 +1156,8 @@ if (defined $packages{"siunitx"} ) { # protect SI command by surrounding them with an \mbox # this is done to get around an incompatibility between the ulem and siunitx package print STDERR "siunitx package detected.\n" if $verbose ; - my $mboxcmds='SI,ang,numlist,numrange,SIlist,SIrange'; - init_regex_arr_list(\@SAFECMDLIST,'num,si'); + my $mboxcmds='SI,ang,numlist,numrange,SIlist,SIrange,qty,qtylist,qtyproduct,qtyrange,complexqty'; + init_regex_arr_list(\@SAFECMDLIST,'num,si,numproduct,unit,complexnum'); if ( $enablecitmark || ( $ulem && ! $disablecitmark )) { init_regex_arr_list(\@MBOXCMDLIST,$mboxcmds); } else { @@ -1153,7 +1179,7 @@ if (defined $packages{"cleveref"} ) { if (defined $packages{"glossaries"} ) { # protect selected command by surrounding them with an \mbox - # this is done to get around an incompatibility between ulem and glossaries package + # this is done to get around an incompatibility between ulem and glossaries package print STDERR "glossaries package detected.\n" if $verbose ; my $mboxcmds='[gG][lL][sS](?:|pl|disp|link|first|firstplural|desc|user[iv][iv]?[iv]?),[aA][cC][rR](?:long|longpl|full|fullpl),[aA][cC][lfp]?[lfp]?'; init_regex_arr_list(\@SAFECMDLIST,'[gG][lL][sS](?:(?:entry)?(?:text|plural|name|symbol)|displaynumberlist|entryfirst|entryfirstplural|entrydesc|entrydescplural|entrysymbolplural|entryuser[iv][iv]?[iv]?|entrynumberlist|entrydisplaynumberlist|entrylong|entrylongpl|entryshort|entryshortpl|entryfull|entryfullpl),[gG]lossentry(?:name|desc|symbol),[aA][cC][rR](?:short|shortpl),[aA]csp?'); @@ -1182,6 +1208,10 @@ if (defined $packages{"mhchem"} ) { # push(@MATHTEXTCMDLIST,'cee'); } +if ( defined $packages{"tikz-dependency"} ) { + init_regex_arr_ext(\@SAFECMDEXCL, 'AMPERSAND'); +} + my ( $citpat); @@ -1269,7 +1299,7 @@ print STDERR "(",exetime()," s)\n","Done.\n" if $verbose; # liststringtoregex(liststring) -# expands string with semi-colon separated list into a regular expression corresponding +# expands string with semi-colon separated list into a regular expression corresponding # matching any of the elements sub liststringtoregex { my ($liststring)=@_; @@ -1282,7 +1312,7 @@ sub liststringtoregex { } # show_configuration -# note that this is not encapsulated but uses variables from the main program +# note that this is not encapsulated but uses variables from the main program # It is provided for convenience because in the future it is planned to allow output # to be modified based on what packages are read etc - this works only if the input files are actually read # whether or not additional files are provided @@ -1309,7 +1339,7 @@ sub show_configuration { print "\nContext1 commands (last argument textual, command will be disabled in deleted passages, last argument will be shown as plain text):\n"; print_regex_arr(@CONTEXT1CMDLIST); print "\nContext2 commands (last argument textual, command and its argument will be disabled in deleted passages):\n"; - print_regex_arr(@CONTEXT2CMDLIST); + print_regex_arr(@CONTEXT2CMDLIST); print "\nExclude list of Commands with last argument not textual (overrides patterns above):\n"; print_regex_arr(@TEXTCMDEXCL); } @@ -1417,7 +1447,7 @@ sub list_packages { my %packages=(); my $pkg; - # remove comments + # remove comments $preamble=~s/(?<!\\)%.*$//mg ; while ( $preamble =~ m/\\(?:documentclass|usepackage|RequirePackage)(?:\[($brat_n)\])?\{(.*?)\}/gs ) { @@ -1522,7 +1552,7 @@ sub flatten { my ($includeonly,$dirname,$fname,$newpage,$fullfile,$filecontent,$replacement,$begline,$inputcmd,$bblfile,$subfile,$command,$verbenv,$verboptions,$ignore,$fileonly); my ($subpreamble,$subbody,$subpost); my ($subdir,$subdirfull,$importfilepath); - require File::Basename ; + require File::Basename ; ### require File::Spec ; # now this is needed even if flatten option not given $filename = File::Spec->rel2abs( $filename ) ; ($ignore, $dirname, $fileonly) = File::Spec->splitpath($filename) ; @@ -1562,15 +1592,15 @@ sub flatten { $subdirfull = (defined($3) ? File::Spec->catdir($dirname,$subdir) : $subdir); $importfilepath = File::Spec->catfile($subdirfull, $fname); - + print STDERR "importing importfilepath:", $importfilepath,"\n" if $verbose; if ( -f $importfilepath ) { # If file exists, replace input or include command with expanded input #TODO: need remove_endinput & newpage similar to other replacements inside flatten - $replacement=flatten(read_file_with_encoding($importfilepath, $encoding), $preamble,$importfilepath,$encoding); + $replacement=flatten(read_file_with_encoding($importfilepath, $encoding), $preamble,$importfilepath,$encoding); } else { # if file does not exist, do not expand include or input command (do not warn if fname contains #[0-9] as it is then likely part of a command definition - # and is not meant to be expanded directly + # and is not meant to be expanded directly print STDERR "WARNING: Could not find included file ",$importfilepath,". I will continue but not expand |$2|\n"; $replacement = $2; $replacement .= "{$subdir}{$fname} % Processed"; @@ -1579,13 +1609,13 @@ sub flatten { }/exgm; # recursively replace \\input and \\include files - $text =~ s/(^(?:[^%\n]|\\%)*)(\\input\{(.*?)\}|\\include\{(${includeonly}(?:\.tex)?)\})/{ + $text =~ s/(^(?:[^%\n]|\\%)*)(\\input\{(.*?)\}|\\include\{(${includeonly}(?:\.tex)?)\})/{ $begline=(defined($1)? $1 : "") ; $inputcmd=$2; $fname = $3 if defined($3) ; $fname = $4 if defined($4) ; $newpage=(defined($4)? " \\newpage " : "") ; - # # add tex extension unless there is a three or four letter extension already + # # add tex extension unless there is a three or four letter extension already $fname .= ".tex" unless $fname =~ m|\.\w{3,4}$|; $fullfile = File::Spec->catfile($dirname,$fname); print STDERR "DEBUG Beg of line match |$1|\n" if defined($1) && $debug ; @@ -1594,12 +1624,12 @@ sub flatten { # content of file becomes replacement value (use recursion), add \newpage if the command was include if ( -f $fullfile ) { # If file exists, replace input or include command with expanded input - $replacement=flatten(read_file_with_encoding($fullfile, $encoding), $preamble,$filename,$encoding); - $replacement = remove_endinput($replacement); + $replacement=flatten(read_file_with_encoding($fullfile, $encoding), $preamble,$filename,$encoding); + $replacement = remove_endinput($replacement); # \include always starts a new page; use explicit \newpage command to simulate this } else { # if file does not exist, do not expand include or input command (do not warn if fname contains #[0-9] as it is then likely part of a command definition - # and is not meant to be expanded directly + # and is not meant to be expanded directly print STDERR "WARNING: Could not find included file ",$fullfile,". I will continue but not expand |$inputcmd|\n" unless $fname =~ m(#[0-9]) ; $replacement = $inputcmd ; # i.e. just the original command again -> make no change file does not exist $newpage=""; @@ -1608,7 +1638,7 @@ sub flatten { }/exgm; # replace bibliography with bbl file if it exists - $text=~s/(^(?:[^%\n]|\\%)*)\\bibliography\{(.*?)\}/{ + $text=~s/(^(?:[^%\n]|\\%)*)\\bibliography\{(.*?)\}/{ if ( -f $bblfile ){ $replacement=read_file_with_encoding(File::Spec->catfile($bblfile), $encoding); } else { @@ -1620,10 +1650,10 @@ sub flatten { }/exgm; # replace subfile with contents (subfile package) - $text=~s/(^(?:[^%\n]|\\%)*)\\subfile\{(.*?)\}/{ + $text=~s/(^(?:[^%\n]|\\%)*)\\subfile\{(.*?)\}/{ $begline=(defined($1)? $1 : "") ; - $fname = $2; - # # add tex extension unless there is a three or four letter extension already + $fname = $2; + # # add tex extension unless there is a three or four letter extension already $fname .= ".tex" unless $fname =~ m|\.\w{3,4}|; print STDERR "Include file as subfile $fname\n" if $verbose; # content of file becomes replacement value (use recursion) @@ -1634,10 +1664,10 @@ sub flatten { # if file exists, expand \subfile command by contents of file $subfile=read_file_with_encoding($fullfile,$encoding) or die "Could not open included subfile ",$fullfile,": $!"; ($subpreamble,$subbody,$subpost)=splitdoc($subfile,'\\\\begin\{document\}','\\\\end\{document\}'); - ### $subfile=~s|^.*\\begin{document}||s; + ### $subfile=~s|^.*\\begin{document}||s; ### $subfile=~s|\\end{document}.*$||s; $replacement=flatten($subbody, $preamble,$fullfile,$encoding); - ### $replacement = remove_endinput($replacement); + ### $replacement = remove_endinput($replacement); } else { # if file does not exist, do not expand subfile print STDERR "WARNING: Could not find subfile ",$fullfile,". I will continue but not expand |$2|\n" unless $fname =~ m(#[0-9]) ; @@ -1648,11 +1678,11 @@ sub flatten { }/exgm; # replace \verbatiminput and \lstlistinginput - $text=~s/(^(?:[^%\n]|\\%)*)\\(verbatiminput\*?|lstinputlisting)$extraspace(\[$brat_n\])?$extraspace\{(.*?)\}/{ + $text=~s/(^(?:[^%\n]|\\%)*)\\(verbatiminput\*?|lstinputlisting)$extraspace(\[$brat_n\])?$extraspace\{(.*?)\}/{ $begline=(defined($1)? $1 : "") ; $command = $2 ; $fname = $4 ; - $verboptions = defined($3)? $3 : "" ; + $verboptions = defined($3)? $3 : "" ; if ($command eq 'verbatiminput' ) { $verbenv = "verbatim" ; } elsif ($command eq 'verbatiminput*' ) { @@ -1661,7 +1691,7 @@ sub flatten { $verbenv = "lstlisting" ; } else { die "Internal errorL Unexpected verbatim input type $command.\n"; - } + } print STDERR "DEBUG Beg of line match |$begline|\n" if $debug ; print STDERR "Include file $fname verbatim\n" if $verbose; print STDERR "DEBUG looking for file ",File::Spec->catfile($dirname,$fname), "\n" if $debug; @@ -1693,8 +1723,8 @@ sub print_regex_arr { # if $type is a filename, it will read the file instead of reading from the appendix # otherwise it will screen appendix for line "%DIF $TYPE" and copy everything up to line # '%DIF END $TYPE' (where $TYPE is upcased version of $type) -# extrapream('-nofail',$type) will---instead of failing---simply return nothing if -# it does not find the matching line in a appendix (do not use -nofail option with multiple types!) +# extrapream('-nofail',$type) will---instead of failing---simply return nothing if +# it does not find the matching line in appendix (do not use -nofail option with multiple types!) sub extrapream { my @types=@_; my ($type,$arg); @@ -1711,14 +1741,20 @@ sub extrapream { $type=$arg; $copy=0; if ( -f $type || lc $type eq '/dev/null' ) { - open (FILE,$type) or die "Cannot open preamble file $type: $!"; print STDERR "Reading preamble file $type\n" if $verbose ; + open (FILE,$type) or die "Cannot open preamble file $type: $!"; + if (defined($encoding)) { + binmode(FILE,":encoding($encoding)"); + } else { + require Encode::Locale; + binmode(FILE,":encoding(locale)"); + } while (<FILE>) { chomp ; if ( $_ =~ m/%DIF PREAMBLE/ ) { - push (@retval,"$_"); + push (@retval,"$_"); } else { - push (@retval,"$_ %DIF PREAMBLE"); + push (@retval,"$_ %DIF PREAMBLE"); } } } else { # not (-f $type) @@ -1730,9 +1766,9 @@ sub extrapream { my $data_start = tell DATA; while (<DATA>) { if ( m/^%DIF $type/ ) { - $copy=1; + $copy=1; } elsif ( m/^%DIF END $type/ ) { - last; + last; } chomp; push (@retval,"$_ %DIF PREAMBLE") if $copy; @@ -1772,7 +1808,7 @@ sub splitdoc { $pos=pos $rest; $part2=substr($rest,0,$pos-length($2)); $part3=substr($rest,$pos); - } + } else { die "$word1 and $word2 not in the correct order or not present as a pair." ; } @@ -1844,7 +1880,7 @@ sub splitlatex { my $leadin=$1; length($string)>0 or return ($leadin); - my @retval=($string =~ m/$pat/osg); + my @retval=($string =~ m/$pat/osg); if (length($string) != length(join("",@retval))) { print STDERR "\nWARNING: Inconsistency in length of input string and parsed string:\n This often indicates faulty or non-standard latex code.\n In many cases you can ignore this and the following warning messages.\n Note that character numbers in the following are counted beginning after \\begin{document} and are only approximate." unless $ignorewarnings; @@ -1888,17 +1924,17 @@ sub splitlatex { # pass1( \@seq1,\@seq2) # Look for differences between seq1 and seq2. -# Where an common-subsequence block is flanked by deleted or appended blocks, +# Where an common-subsequence block is flanked by deleted or appended blocks, # and is shorter than $MINWORDSBLOCK words it is appended -# to the last deleted or appended word. If the block contains tokens other than words +# to the last deleted or appended word. If the block contains tokens other than words # or punctuation it is not merged. # Deleted or appended block consisting of words and safe commands only are # also merged, to prevent break-up in pass2 (after previous isolated words have been removed) -# If there are commands with textual arguments (e.g. \caption) both in corresponding -# appended and deleted blocks split them such that the command and opening bracket -# are one token, then the rest is split up following standard rules, and the closing +# If there are commands with textual arguments (e.g. \caption) both in corresponding +# appended and deleted blocks split them such that the command and opening bracket +# are one token, then the rest is split up following standard rules, and the closing # bracket is a separate token, ie. turn -# "\caption{This is a textual argument}" into +# "\caption{This is a textual argument}" into # ("\caption{","This ","is ","a ","textual ","argument","}") # No return value. Destructively changes sequences sub pass1 { @@ -1927,15 +1963,15 @@ sub pass1 { my $adddiscard = sub { if ($cnt > 0 ) { $matblkcnt++; - # just after an unchanged block + # just after an unchanged block # print STDERR "Unchanged block $cnt, $last1,$last2 \n"; - if ($cnt < $MINWORDSBLOCK + if ($cnt < $MINWORDSBLOCK && $cnt==scalar ( - grep { /^$wpat/ || ( /^\\((?:[`'^"~=.]|[\w\d@*]+))((?:\[$brat_n\]|\{$pat_n\})*)/o - && iscmd($1,\@SAFECMDLIST,\@SAFECMDEXCL) + grep { /^$wpat/ || ( /^\\((?:[`'^"~=.]|[\w\d@*]+))((?:\[$brat_n\]|\{$pat_n\})*)/o + && iscmd($1,\@SAFECMDLIST,\@SAFECMDEXCL) && scalar(@dummy=split(" ",$2))<3 ) } @$block) ) { - # merge identical blocks shorter than $MINWORDSBLOCK + # merge identical blocks shorter than $MINWORDSBLOCK # and only containing ordinary words # with preceding different word # We cannot carry out this merging immediately as this @@ -1943,23 +1979,23 @@ sub pass1 { # the algorithm, instead we store in @$todo where we have to merge push(@$todo, [ $last1,$last2,$cnt,@$block ]); } - $block = []; + $block = []; $cnt=0; $last1=-1; $last2=-1; } }; my $discard=sub { $deltokcnt++; &$adddiscard; #($_[0],$_[1]); push(@$delblock,[ $seq1->[$_[0]],$_[0] ]); - $last1=$_[0] }; + $last1=$_[0] }; my $add = sub { $addtokcnt++; &$adddiscard; #($_[0],$_[1]); push(@$addblock,[ $seq2->[$_[1]],$_[1] ]); - $last2=$_[1] }; + $last2=$_[1] }; my $match = sub { $mattokcnt++; if ($cnt==0) { # first word of matching sequence after changed sequence or at beginning of word sequence - $deltextblocks = extracttextblocks($delblock); + $deltextblocks = extracttextblocks($delblock); $delblkcnt++ if scalar @$delblock; $addtextblocks = extracttextblocks($addblock); $addblkcnt++ if scalar @$addblock; @@ -1975,7 +2011,7 @@ sub pass1 { ### Algorithm::Diff 1.19 $matchindex=Algorithm::Diff::_longestCommonSubsequence($delcmds,$addcmds, 0, sub { $_[0]->[0] } ); } else { - ### Algorithm::Diff 1.15 + ### Algorithm::Diff 1.15 $matchindex=Algorithm::Diff::_longestCommonSubsequence($delcmds,$addcmds, sub { $_[0]->[0] } ); } @@ -2006,11 +2042,11 @@ sub pass1 { my ($index,$block,$cnt)=@{ shift(@$addtextblocks) }; push(@$todo, [-1,$index,$cnt,@$block]); } - + $addblock=[]; $delblock=[]; } - push(@$block,$seq2->[$_[1]]); + push(@$block,$seq2->[$_[1]]); $cnt++ }; my $keyfunc = sub { join(" ",split(" ",shift())) }; @@ -2018,7 +2054,7 @@ sub pass1 { traverse_sequences($seq1,$seq2, { MATCH=>$match, DISCARD_A=>$discard, DISCARD_B=>$add }, $keyfunc ); - # now carry out the merging/splitting. Refer to elements relative from + # now carry out the merging/splitting. Refer to elements relative from # the end (with negative indices) as these offsets don't change before the instruction is executed # cnt>0: merged small unchanged groups with previous changed blocks # cnt==-1: split textual commands into components @@ -2033,7 +2069,7 @@ sub pass1 { } } - if ($verbose) { + if ($verbose) { print STDERR "\n"; print STDERR " $mattokcnt matching tokens in $matblkcnt blocks.\n"; print STDERR " $deltokcnt discarded tokens in $delblkcnt blocks.\n"; @@ -2043,10 +2079,10 @@ sub pass1 { # extracttextblocks(\@blockindex) -# $blockindex has the following format -# [ [ token1, index1 ], [token2, index2],.. ] -# where index refers to the index in the original old or new word sequence -# Returns: reference to an array of the form +# $blockindex has the following format +# [ [ token1, index1 ], [token2, index2],.. ] +# where index refers to the index in the original old or new word sequence +# Returns: reference to an array of the form # [[ $index, $textblock, $cnt ], .. # where $index index of block to be merged # $textblock contains all the words to be merged with the word at $index (but does not contain this word) @@ -2054,7 +2090,7 @@ sub pass1 { # # requires: iscmd # -sub extracttextblocks { +sub extracttextblocks { my $block=shift; my ($i,$token,$index); my $textblock=[]; @@ -2064,13 +2100,13 @@ sub extracttextblocks { # we redefine locally $extraspace (shadowing the global definition) to capture command sequences with intervening spaces no matter what the global setting # this is done so we can capture those commands with a predefined number of arguments without having to introduce them again explicitly here - my $extraspace='\s*'; + my $extraspace='\s*'; for ($i=0;$i< scalar @$block;$i++) { ($token,$index)=@{ $block->[$i] }; # store pure text blocks - if ($token =~ /$wpat/ || ( $token =~/^\\((?:[`'^"~=.]|[\w\d@\*]+))((?:${extraspace}\[$brat_n\]${extraspace}|${extraspace}\{$pat_n\})*)/ - && iscmd($1,\@SAFECMDLIST,\@SAFECMDEXCL) + if ($token =~ /$wpat/ || ( $token =~/^\\((?:[`'^"~=.]|[\w\d@\*]+))((?:${extraspace}\[$brat_n\]${extraspace}|${extraspace}\{$pat_n\})*)/ + && iscmd($1,\@SAFECMDLIST,\@SAFECMDEXCL) && !iscmd($1,\@TEXTCMDLIST,\@TEXTCMDEXCL))) { # we have text or a command which can be treated as text if ($last<0) { @@ -2078,7 +2114,7 @@ sub extracttextblocks { $last=$index; } else { # add to pure-text block - push(@$textblock, $token); + push(@$textblock, $token); } } else { # it is not text @@ -2099,29 +2135,29 @@ sub extracttextblocks { # extractcommands( \@blockindex ) -# $blockindex has the following format -# [ [ token1, index1 ], [token2, index2],.. ] -# where index refers to the index in the original old or new word sequence -# Returns: reference to an array of the form -# [ [ "\cmd1", index, "\cmd1[optarg]{arg1}{", "arg2" ,"} " ],.. -# where index is just taken from input array -# command must have a textual argument as last argument -# -# requires: iscmd -# -sub extractcommands { +# $blockindex has the following format +# [ [ token1, index1 ], [token2, index2],.. ] +# where index refers to the index in the original old or new word sequence +# Returns: reference to an array of the form +# [ [ "\cmd1", index, "\cmd1[optarg]{arg1}{", "arg2" ,"} " ],.. +# where index is just taken from input array +# command must have a textual argument as last argument +# +# requires: iscmd +# +sub extractcommands { my $block=shift; my ($i,$token,$index,$cmd,$open,$mid,$closing); my $retval=[]; # we redefine locally $extraspace (shadowing the global definition) to capture command sequences with intervening spaces no matter what the global setting # this is done so we can capture those commands with a predefined number of arguments without having to introduce them again explicitly here - my $extraspace='\s*'; + my $extraspace='\s*'; for ($i=0;$i< scalar @$block;$i++) { ($token,$index)=@{ $block->[$i] }; # check if token is an alphanumeric command sequence with at least one non-optional argument - # \cmd[...]{...}{last argument} + # \cmd[...]{...}{last argument} # Capturing in the following results in these associations # $1: \cmd[...]{...}{ # $2: \cmd @@ -2129,7 +2165,7 @@ sub extractcommands { # $4: } + trailing spaces if ( ( $token =~ m/^(\\([\w\d\*]+)(?:${extraspace}\[$brat_n\]|${extraspace}\{$pat_n\})*${extraspace}\{)($pat_n)(\}\s*)$/so ) && iscmd($2,\@TEXTCMDLIST,\@TEXTCMDEXCL) ) { - print STDERR "DEBUG EXTRACTCOMMANDS Match |$1|$2|$3|$4|$index \n" if $debug; + print STDERR "DEBUG EXTRACTCOMMANDS Match |$1|$2|$3|$4|$index \n" if $debug; # push(@$retval,[ $2,$index,$1,$3,$4 ]); ($cmd,$open,$mid,$closing) = ($2,$1,$3,$4) ; $closing =~ s/\}/\\RIGHTBRACE/ ; @@ -2140,7 +2176,7 @@ sub extractcommands { } # iscmd($cmd,\@regexarray,\@regexexcl) checks -# return 1 if $cmd matches any of the patterns in the +# return 1 if $cmd matches any of the patterns in the # array $@regexarray, and none of the patterns in \@regexexcl, otherwise return 0 sub iscmd { my ($cmd,$regexar,$regexexcl)=@_; @@ -2148,7 +2184,7 @@ sub iscmd { ### print STDERR "DEBUG: iscmd($cmd)=" if $debug; foreach $pat ( @$regexar ) { if ( $cmd =~ m/^${pat}$/ ) { - $ret=1 ; + $ret=1 ; last; } } @@ -2164,13 +2200,13 @@ sub iscmd { # pass2( \@seq1,\@seq2) -# Look for differences between seq1 and seq2. +# Look for differences between seq1 and seq2. # Mark begin and end of deleted and appended sequences with tags $DELOPEN and $DELCLOSE # and $ADDOPEN and $ADDCLOSE, respectively, however exclude { } & and all comands, unless # they match an element of the whitelist (SAFECMD) # For words in TEXTCMD but not in SAFECMD, enclose interior with $ADDOPEN and $ADDCLOSE brackets -# Deleted comment lines are marked with %DIF < -# Added comment lines are marked with %DIF > +# Deleted comment lines are marked with %DIF < +# Added comment lines are marked with %DIF > sub pass2 { my $seq1 = shift ; my $seq2 = shift ; @@ -2202,7 +2238,7 @@ sub pass2 { $addhunk = []; } push(@$retval,$seq2->[$_[1]]) }; - + my $keyfunc = sub { join(" ",split(" ",shift())) }; traverse_sequences($seq1,$seq2, { MATCH=>$match, DISCARD_A=>$discard, DISCARD_B=>$add }, $keyfunc ); @@ -2211,7 +2247,7 @@ sub pass2 { push @$retval,marktags($ADDMARKOPEN,$ADDMARKCLOSE,$ADDOPEN,$ADDCLOSE,"","",$ADDCOMMENT,$addhunk) if scalar @$addhunk; - if ($verbose) { + if ($verbose) { print STDERR "\n"; print STDERR " $mattokcnt matching tokens. \n"; print STDERR " $deltokcnt discarded tokens in $delblkcnt blocks.\n"; @@ -2233,7 +2269,7 @@ sub marktags { my (@argtext); my $retval=[]; my $noncomment=0; - my $cmd=-1; # -1 at beginning 0: last token written is a ordinary word + my $cmd=-1; # -1 at beginning 0: last token written is a ordinary word # 1: last token written is a command # for keeping track whether we are just in a command sequence or in a word sequence my $cmdcomment= ($opencmd =~ m/^%/); # Flag to indicate whether opencmd is a comment (i.e. if we intend to simply comment out changed commands) @@ -2249,31 +2285,31 @@ sub marktags { # we redefine locally $extraspace (shadowing the global definition) to capture command sequences with intervening spaces no matter what the global setting # this is done so we can capture those commands with a predefined number of arguments without having to introduce them again explicitly here - my $extraspace_mt='\s*'; + my $extraspace_mt='\s*'; foreach (@$block) { - $word=$_; + $word=$_; if ( $word =~ s/^%/%$comment/ ) { # a comment if ($cmd==1) { push (@$retval,$closecmd) ; $cmd=-1; } - push (@$retval,$word); + push (@$retval,$word); next; } if ( $word =~ m/^\s*$/ ) { ### print STDERR "DEBUG MARKTAGS: whitespace detected |$word| cmdcom |$cmdcomment| |$opencmd|\n" if $debug; # a sequence of white-space characters - this should only ever happen for the first element of block. - # in deleted block, omit, otherwise just copy it in + # in deleted block, omit, otherwise just copy it in if ( ! $cmdcomment) { # ignore in deleted blocks push(@$retval,$word); } next; } if (! $noncomment) { - push (@$retval,$openmark); + push (@$retval,$openmark); $noncomment=1; } # negative lookahead pattern (?!) in second clause is put in to avoid matching \( .. \) patterns @@ -2283,7 +2319,7 @@ sub marktags { # word is a command or other significant token (not in SAFECMDLIST) ## same conditions as in subroutine extractcommand: # check if token is an alphanumeric command sequence with at least one non-optional argument - # \cmd[...]{...}{last argument} + # \cmd[...]{...}{last argument} # Capturing in the following results in these associations # $1: \cmd[...]{...}{ # $2: cmd @@ -2300,11 +2336,11 @@ sub marktags { # Condition 3: But if we are in a deleted block ($cmdcomment=1) and # $2 (the command) is in context2, just treat it as an ordinary command (i.e. comment it open with $opencmd) # Because we do not want to disable this command - # here we do not use $opencmd and $closecmd($opencmd is empty) + # here we do not use $opencmd and $closecmd($opencmd is empty) print STDERR "DEBUG: Detected text |$word| but not safe command \$2: $2 \$3: $3\n." if $debug; if ($cmd==1) { push (@$retval,$closecmd) ; - } elsif ($cmd==0) { + } elsif ($cmd==0) { push (@$retval,$close) ; } $command=$1; $commandword=$2; $closingbracket=$4; @@ -2320,16 +2356,16 @@ sub marktags { # for latexrevise push (@$retval,$command,"%\n{$AUXCMD\n",marktags("","",$open,$close,$opencmd,$closecmd,$comment,\@argtext),$closingbracket); } elsif ( iscmd($commandword,,\@MATHTEXTCMDLIST, \@MATHTEXTCMDEXCL) ) { - # MATHBLOCK pseudo command: consider all commands safe, except & and \\, \begin and \end and a few package sprcific one (look at UNSAFEMATHCMD definition) - # Keep these commands even in deleted blocks, hence set $opencmd and $closecmd (5th and 6th argument of marktags) to + # MATHBLOCK pseudo command: consider all commands safe, except & and \\, \begin and \end and a few package sprcific one (look at UNSAFEMATHCMD definition) + # Keep these commands even in deleted blocks, hence set $opencmd and $closecmd (5th and 6th argument of marktags) to # "" - local @SAFECMDLIST=(".*"); + local @SAFECMDLIST=(".*"); local @SAFECMDEXCL=('\\','\\\\',@UNSAFEMATHCMD); push(@$retval,$command,marktags("","",$open,$close,"","",$comment,\@argtext)#@argtext ,$closingbracket); } else { # normal textcmd or context1cmd in an added block - push (@$retval,$command,marktags("","",$open,$close,$opencmd,$closecmd,$comment,\@argtext),$closingbracket); + push (@$retval,$command,marktags("","",$open,$close,$opencmd,$closecmd,$comment,\@argtext),$closingbracket); } push (@$retval,$AUXCMD,"\n") if $cmdcomment ; $cmd=-1 ; @@ -2415,10 +2451,10 @@ sub take_comments_and_newline_from_frac() { # names or labels but it does not matter because they are converted back in the postprocessing step # Returns: leading white space removed in step 1 sub preprocess { - for (@_) { + for (@_) { - # change in \verb and similar commands - note that I introduce an extra space here so that the + # change in \verb and similar commands - note that I introduce an extra space here so that the # already hashed variants do not trigger again # transform \lstinline{...} # s/\\lstinline(\[$brat0\])?(\{(?:.*?)\})/"\\DIFlstinline". $1 ."{". tohash(\%verbhash,"$2") ."}"/esg; @@ -2448,7 +2484,7 @@ sub preprocess { 1 while s/(?<!\\)_(\s*{($pat_n)})/\\SUBSCRIPT$1/g ; # Convert ^n into \SUPERSCRIPTNB{n} and ^{nnn} into \SUPERSCRIPT{nn} 1 while s/(?<!\\)\^(\s*([^{\\\s]|\\\w+))/\\SUPERSCRIPTNB{$1}/g ; - 1 while s/(?<!\\)\^(\s*{($pat_n)})/\\SUPERSCRIPT$1/g ; + 1 while s/(?<!\\)\^(\s*{($pat_n)})/\\SUPERSCRIPT$1/g ; # Convert \sqrt{n} into \SQRT{n} and \sqrt nn into SQRTNB{nn} 1 while s/(?<!\\)\\sqrt(\s*([^{\\\s]|\\\w+))/\\SQRTNB{$1}/g ; 1 while s/(?<!\\)\\sqrt(\s*{($pat_n)})/\\SQRT$1/g ; @@ -2468,16 +2504,16 @@ sub preprocess { if ( $mathmarkup != FINE ) { # DIFANCHORARRB and DIFANCHORARRE, DIFANCHORMATHB and DIFANCHORMATHE markers are inserted here to encourage the matching algorithm # to always match up the closing brace. Otherwise sometimes one ends up with a situation where - # the closing brace is deleted and added at another point. The deleted closing brace is then + # the closing brace is deleted and added at another point. The deleted closing brace is then # prevented by a %DIFDELCMD, leading to material leaking in or out of the math environment. # The anchors are removed in post-processing again. (note that they are simple text to cause least amount of complications - # Admittedly, this is something of a hack and will not always work. If it does not, then one needs to + # Admittedly, this is something of a hack and will not always work. If it does not, then one needs to # resort to WHOLE or FINE, or NONE math mode processing. s/\\begin\{($ARRENV)}(.*?)\\end\{\1}/\\ARRAYBLOCK$1\{$2\\DIFANCHORARRB \}\\DIFANCHORARRE /sg; take_comments_and_newline_from_frac(); - # Convert Math environments with arguments + # Convert Math environments with arguments s/\\begin\{($MATHENV|$MATHARRENV|SQUAREBRACKET)\}((?:\[$brat_n\])|(?:\{$pat_n\}))+(.*?)\\end\{\1\}/\\MATHBLOCK$1\[$2\]\{$3\\DIFANCHORMATHB \}\\DIFANCHORMATHE /sg; # Convert Math environments without arguments s/\\begin\{($MATHENV|$MATHARRENV|SQUAREBRACKET)\}(.*?)\\end\{\1\}/\\MATHBLOCK$1\{$2\\DIFANCHORMATHB \}\\DIFANCHORMATHE /sg; @@ -2491,7 +2527,7 @@ sub preprocess { # $expanded=linecomment($string) #preface all lines with verbatim marker (usually DIFVRB) -sub linecomment { +sub linecomment { my @verbatimlines=split("\n",$_[0]); # the first line needs special treatment - we do want to retain optional arguments as is but wrap the remainder also with VERBCOMMENT ### print STDERR "DEBUG: before verbatimlines[0] = ",$verbatimlines[0],"\n"; @@ -2501,7 +2537,7 @@ sub linecomment { } # $simple=reverselinecomment($env $string) -# remove DIFVRB comments but leave changed lines marked +# remove DIFVRB comments but leave changed lines marked sub reverselinecomment { my ($environment, $verbatimtext)=@_; ### print STDERR "DEBUG REVERSELINECOMMENT input: $environment,|$verbatimtext|\n" if $debug; @@ -2516,7 +2552,7 @@ sub reverselinecomment { $verbatimtext =~ s/\\DIFdelend //g; $verbatimtext =~ s/$DELCMDOPEN.*//g; - # remove DIFVRB mark + # remove DIFVRB mark $verbatimtext=~ s/%$VERBCOMMENT//g; # remove part of the markup in changed lines @@ -2607,7 +2643,7 @@ sub writedebugfile { # * Remove STOP token from the end # * Replace \RIGHTBRACE by } # * If option --no-del is set delete all deleted blocks -# 1. Check all deleted blocks: +# 1. Check all deleted blocks: # a.where a deleted block contains a matching \begin and # \end environment (these will be disabled by a %DIFDELCMD statements), for selected environments enable # these commands again (such that for example displayed math in a deleted equation @@ -2628,14 +2664,14 @@ sub writedebugfile { # For added blocks: # c. If in-line math mode contains array environment, enclose the whole environment in \mbox'es # d. place \cite commands in mbox'es (for UNDERLINE style) -# +# # 2. If math-mode COARSE,WHOLE or NONE option set: Convert \MATHBLOCKmath{..} commands back to environments # # Convert all PICTUREblock{..} commands back to the appropriate environments # 3. Convert DIFadd, DIFdel, DIFaddbegin , ... into FL varieties # within floats (currently recognised float environments: plate,table,figure # plus starred varieties). -# 4. Remove empty %DIFDELCMD < lines +# 4. Remove empty %DIFDELCMD < lines # 4. Convert \begin{SQUAREBRACKET} \end{SQUAREBRACKET} into \[ \] # Convert \begin{DOLLARDOLLAR} \end{DOLLARDOLLAR} into $$ $$ # 5. Convert \SUPERSCRIPTNB{n} into ^n and \SUPERSCRIPT{nn} into ^{nnn} @@ -2648,7 +2684,7 @@ sub writedebugfile { # 4, undo renaming of the \begin, \end,{,} in comments # Change \QLEFTBRACE, \QRIGHTBRACE,\AMPERSAND to \{,\},\& # -# Note have to manually synchronize substitution commands below and +# Note have to manually synchronize substitution commands below and # DIF.. command names in the header sub postprocess { my ($begin,$len,$float,$delblock,$addblock); ### $cnt @@ -2660,7 +2696,7 @@ sub postprocess { my (@itemargs, $itemarg); - for (@_) { + for (@_) { # change $'s in comments to something harmless 1 while s/(%.*)\$/$1DOLLARDIF/mg ; @@ -2670,7 +2706,7 @@ sub postprocess { # the only way to get these is as %DIFDELCMD < \RIGHTBRACE construction # This essentially marks closing right braces of MATHBLOCK environments, which did not get matched # up. This case should be rare, so I just leave this in the diff file output. Not really elegant - # but can still be dealt with later if it results in problems. + # but can still be dealt with later if it results in problems. s/%DIFDELCMD < \\RIGHTBRACE/%DIFDELCMD < \\MBLOCKRIGHTBRACE/g ; # Replace \RIGHTBRACE by } s/\\RIGHTBRACE/}/g; @@ -2698,7 +2734,7 @@ sub postprocess { $len=length($&); $begin=pos($_) - $len; $delblock=$&; - ### A much simpler method for math replacement might follow this strategy (can recycle part of the commands below for following + ### A much simpler method for math replacement might follow this strategy (can recycle part of the commands below for following ### this strategy: ### 1. a Insert aux commands \begin{MATHMODE} or \end{MATHMODE} for all deleted commands opening or closing displayed math mode ### b Insert aux commands \begin{MATHARRMODE} or \end{MATHARRMODE} for all deleted commands opening or closing math array mode @@ -2724,14 +2760,14 @@ sub postprocess { ###0.5: $delblock=~ s/(?<!${AUXCMD}\n)(\%DIFDELCMD < \s*\\end\{((?:$MATHENV)|SQUAREBRACKET)\}\s*?(?:$DELCMDCLOSE|\n))(.*?[^\n]?)\n?(?<!${AUXCMD}\n)(\%DIFDELCMD < \s*\\begin\{\2\})/\\end{MATHMODE}$AUXCMD\n$1$3\n\\begin{MATHMODE}$AUXCMD\n$4/sg; $delblock=~ s/(?<!${AUXCMD}\n)(\%DIFDELCMD < \h*\\end\{((?:$MATHENV)|SQUAREBRACKET)\}.*?(?:$DELCMDCLOSE|\n))(.*?[^\n]?)\n?(?<!${AUXCMD}\n)(\%DIFDELCMD < \h*\\begin\{\2\})/\\end\{MATHMODE\}$AUXCMD\n$1$3\n\\begin\{MATHMODE\}$AUXCMD\n$4/sg; - # now look for unpaired %DIFDELCMD < \begin{MATHENV}; if found add \begin{$MATHREPL} and insert \end{$MATHREPL} + # now look for unpaired %DIFDELCMD < \begin{MATHENV}; if found add \begin{$MATHREPL} and insert \end{$MATHREPL} # just before end of block; again we use look-behind assertion to avoid matching constructions which have already been converted if ($delblock=~ s/(?<!${AUXCMD}\n)(\%DIFDELCMD < \h*\\begin\{((?:$MATHENV)|SQUAREBRACKET)\}\s*?(?:$DELCMDCLOSE|\n))/$1\\begin{$MATHREPL}$AUXCMD\n/sg ) { ### print STDERR "BINGO: begin block: \nBefore: |" . substr($_,$begin,$len) . "|\n" if $debug ; $delblock =~ s/(\\DIFdelend$)/\\end{$MATHREPL}$AUXCMD\n$1/s ; ### print STDERR "After: |" . $delblock . "|\n\n" if $debug ; } - # now look for unpaired %DIFDELCMD < \end{MATHENV}; if found add \end{MATHMODE} and insert \begin{MATHMODE} + # now look for unpaired %DIFDELCMD < \end{MATHENV}; if found add \end{MATHMODE} and insert \begin{MATHMODE} # just before end of block; again we use look-behind assertion to avoid matching constructions which have already been converted if ($delblock=~ s/(?<!${AUXCMD}\n)(\%DIFDELCMD < \h*\\end\{((?:$MATHENV)|SQUAREBRACKET)\}\s*?(?:$DELCMDCLOSE|\n))/$1\\end\{MATHMODE\}$AUXCMD\n/sg ) { ### print STDERR "BINGO: end block:\nBefore: |" . substr($_,$begin,$len) . "|\n" if $debug; @@ -2754,15 +2790,15 @@ sub postprocess { $delblock=~ s/(?<!${AUXCMD}\n)(\%DIFDELCMD < \h*\\end\{($MATHARRENV)\}\s*?(?:$DELCMDCLOSE|\n))(.*?[^\n]?)\n?(?<!${AUXCMD}\n)(\%DIFDELCMD < \h*\\begin\{\2\})/\\end{MATHMODE}$AUXCMD\n$1$3\n\\begin{MATHMODE}$AUXCMD\n$4/sg; ### print STDERR "STEP1: |" . $delblock . "|\n\n" if $debug ; - # now look for unpaired %DIFDELCMD < \begin{MATHARRENV}; if found add \begin{$MATHARRREPL} and insert \end{$MATHARRREPL} + # now look for unpaired %DIFDELCMD < \begin{MATHARRENV}; if found add \begin{$MATHARRREPL} and insert \end{$MATHARRREPL} # just before end of block; again we use look-behind assertion to avoid matching constructions which have already been converted if ($delblock=~ s/(?<!${AUXCMD}\n)(\%DIFDELCMD < \h*\\begin\{($MATHARRENV)\}(.*?)(?:$DELCMDCLOSE|\n))/$1\\begin{$2*}$3$AUXCMD\n/sg ) { $arrenv=$2; - $delblock =~ s/(\\DIFdelend$)/\\end{$arrenv*}}$AUXCMD\n$1/s ; + $delblock =~ s/(\\DIFdelend$)/\\end{$arrenv*}$AUXCMD\n$1/s ; } ### print STDERR "STEP2: |" . $delblock . "|\n\n" if $debug ; - # now look for unpaired %DIFDELCMD < \end{MATHENV}; if found add \end{MATHMODE} and insert \begin{MATHMODE} + # now look for unpaired %DIFDELCMD < \end{MATHENV}; if found add \end{MATHMODE} and insert \begin{MATHMODE} # just before end of block; again we use look-behind assertion to avoid matching constructions which have already been converted if ($delblock=~ s/(?<!${AUXCMD}\n)(\%DIFDELCMD < \h*\\end\{($MATHARRENV)\}\s*?(?:$DELCMDCLOSE|\n))/$1\\end{MATHMODE}$AUXCMD\n/sg ) { $delblock =~ s/(\\DIFdelend$)/\\begin{MATHMODE}$AUXCMD\n$1/s ; @@ -2780,7 +2816,7 @@ sub postprocess { ### $eqarrayblock=~ s/(\%DIFDELCMD < \s*(\&|\\\\)\s*?(?:$DELCMDCLOSE|\n))/$1$2$AUXCMD\n/sg ; $eqarrayblock =~ s/(\%DIFDELCMD < (.*?(?:\&|\\\\).*)(?:$DELCMDCLOSE|\n))/ # The pattern captures comments with at least one of & or \\ - @symbols= split(m@((?:&|\\\\)\s*)@,$2); # extract & and \\ and other material from sequence + @symbols= split(m@((?:&|\\\\)\s*)@,$2); # extract & and \\ and other material from sequence @symbols= grep ( m@&|\\\\\s*@, @symbols); # select & and \\ (and subsequent spaces) "$1@symbols$AUXCMD\n" /eg ; @@ -2793,7 +2829,7 @@ sub postprocess { } elsif ( $mathmarkup == COARSE || $mathmarkup == WHOLE ) { # Convert MATHBLOCKmath commands to their uncounted numbers (e.g. convert equation -> displaymath # (environments defined in $MATHENV will be replaced by $MATHREPL, and environments in $MATHARRENV - # will be replaced by their starred variety + # will be replaced by their starred variety $delblock=~ s/\\MATHBLOCK($MATHENV)((?:\[$brat_n\])?)\{($pat_n)\}/\\MATHBLOCK$MATHREPL$2\{$3\}/sg; $delblock=~ s/\\MATHBLOCK($MATHARRENV)((?:\[$brat_n\])?)\{($pat_n)\}/\\MATHBLOCK$1\*$2\{$3\}/sg; } @@ -2807,10 +2843,10 @@ sub postprocess { print STDERR "DELBLOCK after maths processing: |" . $delblock . "|\n\n" if $debug ; - # Reinstate completely deleted list environments. note that items within the + # Reinstate completely deleted list environments. note that items within the # environment will still be commented out. They will be restored later $delblock=~ s/(\%DIFDELCMD < \s*\\begin\{($LISTENV)\}\s*?(?:\n|$DELCMDCLOSE))(.*?)(\%DIFDELCMD < \s*\\end\{\2\})/{ - ### # block within the search; replacement environment + ### # block within the search; replacement environment ### "$1\\begin{$2}$AUXCMD\n". restore_item_commands($3). "\n\\end{$2}$AUXCMD\n$4"; "$1\\begin{$2}$AUXCMD\n$3\n\\end{$2}$AUXCMD\n$4"; }/esg; @@ -2844,7 +2880,7 @@ sub postprocess { ### if ($CITE2CMD) { ###### ${extraspace}(?:\[$brat0\]${extraspace}){0,2}\{$pat_n\})) .*?%%%\n ### $delblock=~s/($DELCMDOPEN\s*\\($CITE2CMD)(.*)$DELCMDCLOSE)/ - ### # Replacement code + ### # Replacement code ### {my ($aux,$all); ### $aux=$all=$1; ### $aux=~s#\n?($DELCMDOPEN|$DELCMDCLOSE)##g; @@ -2854,7 +2890,7 @@ sub postprocess { ### if ($CITECMD) { ###### $delblock=~s/(\\($CITECMD)${extraspace}(?:\[$brat0\]${extraspace}){0,2}\{$pat_n\})(\s*)/\\mbox{$AUXCMD\n$1\n}$AUXCMD\n/msg ; ### $delblock=~s/(\\($CITECMD)${extraspace}(?:<$abrat0>${extraspace})?(?:\[$brat0\]${extraspace}){0,2}\{$pat_n\})(\s*)/\\mbox{$AUXCMD\n$1\n}$AUXCMD\n/msg ; - ### } + ### } # if MBOXINLINEMATH is set, protect inlined math environments with an extra mbox @@ -2862,7 +2898,7 @@ sub postprocess { # note additional \newline after command is omitted from output if right at the end of deleted block (otherwise a spurious empty line is generated) $delblock=~s/($math)(?:[\s\n]*)?/\\mbox{$AUXCMD\n$1\n}$AUXCMD\n/sg; } - ###if ( defined($packages{"listings"} and $latexdiffpreamble =~ /\\RequirePackage(?:\[$brat_n\])?\{color\}/)) { + ###if ( defined($packages{"listings"} and $latexdiffpreamble =~ /\\RequirePackage(?:\[$brat_n\])?\{color\}/)) { ### # change included verbatim environments ### $delblock =~ s/\\DIFverb\{/\\DIFDIFdelverb\{/g; ### $delblock =~ s/\\DIFlstinline/\\DIFDIFdellstinline/g; @@ -2904,7 +2940,7 @@ sub postprocess { ##$addblock=~s/($math)/\\mbox{$AUXCMD\n$1\n}$AUXCMD\n/sg; $addblock=~s/($math)(?:[\s\n]*)?/\\mbox{$AUXCMD\n$1\n}$AUXCMD\n/sg; } - ###if ( defined($packages{"listings"} and $latexdiffpreamble =~ /\\RequirePackage(?:\[$brat0\])?\{color\}/)) { + ###if ( defined($packages{"listings"} and $latexdiffpreamble =~ /\\RequirePackage(?:\[$brat0\])?\{color\}/)) { # mark added verbatim commands $addblock =~ s/\\DIFverb/\\DIFDIFaddverb/g; $addblock =~ s/\\DIFlstinline/\\DIFDIFaddlstinline/g; @@ -2922,11 +2958,11 @@ sub postprocess { pos = $begin + length($addblock); } - # Go through whole text, and by counting list environment commands, find out when we are within a list environment. + # Go through whole text, and by counting list environment commands, find out when we are within a list environment. # Within those restore deleted \item commands - @textparts=split /(?<!$DELCMDOPEN)(\\(?:begin|end)\{$LISTENV\})/ ; + @textparts=split /(?<!$DELCMDOPEN)(\\(?:begin|end)\{$LISTENV\})/ ; @liststack=(); - @newtextparts=map { + @newtextparts=map { ### print STDERR ":::::::: $_\n"; if ( ($listtype) = m/^\\begin\{($LISTENV)\}$/ ) { print STDERR "DEBUG: postprocess \\begin{$listtype}\n" if $debug; @@ -2942,7 +2978,7 @@ sub postprocess { } else { print STDERR "DEBUG: postprocess \@liststack=(",join(",",@liststack),")\n" if $debug; if (scalar @liststack > 0 ) { - # we are within a list environment and should replace all item commands + # we are within a list environment and should replace all item commands $_=restore_item_commands($_); } # else: we are outside a list environment and do not need to do anything @@ -2955,17 +2991,17 @@ sub postprocess { # Replace MATHMODE environments from step 1a above by the correct Math environment and remove unncessary pairings - + if ( $mathmarkup == FINE ) { # look for AUXCMD math-mode pairs which have only comments (or empty lines between them), and remove the added commands # \begin{..} ... \end{..} pairs - s/\\begin\{((?:$MATHENV)|(?:$MATHARRENV)|SQUAREBRACKET|MATHMODE)\}$AUXCMD\n((?:\s*%.[^\n]*\n)*)\\end\{\1\}$AUXCMD\n/$2/sg; + s/\\begin\{((?:$MATHENV)|(?:$MATHARRENV)|SQUAREBRACKET|MATHMODE)\}$AUXCMD\n((?:\s*%.[^\n]*\n)*)\\end\{\1\}$AUXCMD\n/$2/sg; # \end{..} .... \begin{..} pairs - s/\\end\{((?:$MATHENV)|(?:$MATHARRENV)|SQUAREBRACKET|MATHMODE)\}$AUXCMD\n((?:\s*%.[^\n]*\n)*)\\begin\{\1\}$AUXCMD\n/$2/sg; + s/\\end\{((?:$MATHENV)|(?:$MATHARRENV)|SQUAREBRACKET|MATHMODE)\}$AUXCMD\n((?:\s*%.[^\n]*\n)*)\\begin\{\1\}$AUXCMD\n/$2/sg; writedebugfile($_,'postprocess15'); # The next line is complicated. The negative look-ahead insertion makes sure that no \end{$MATHENV} (or other mathematical - # environments) are between the \begin{$MATHENV} and \end{MATHMODE} commands. This is necessary as the minimal matching + # environments) are between the \begin{$MATHENV} and \end{MATHMODE} commands. This is necessary as the minimal matching # is not globally minimal but only 'locally' (matching is beginning from the left side of the string) # [NB: Do not be tempted to prettify the expression with /x modified. It seems this is applied after strings are expanded so will ignore spaces in strings 1 while s/(?<!$DELCMDOPEN)\\begin\{((?:$MATHENV)|(?:$MATHARRENV)|SQUAREBRACKET)}((?:${DELCMDOPEN}[^\n]*|.(?!(?:\\end\{(?:(?:$MATHENV)|(?:$MATHARRENV)|SQUAREBRACKET)}|\\begin\{MATHMODE})))*?)\\end\{MATHMODE}/\\begin{$1}$2\\end{$1}/s; @@ -3040,7 +3076,7 @@ sub postprocess { # remove empty DIFCMD < lines s/^\Q${DELCMDOPEN}\E\n//msg; - # Expand hashes of verb and verbatim environments + # Expand hashes of verb and verbatim environments s/${DELCMDOPEN}\\($VERBATIMENV)\{([-\d]*?)\}/"${DELCMDOPEN}\\begin{${1}}".fromhash(\%verbhash,$2,$DELCMDOPEN)."${DELCMDOPEN}\\end{${1}}"/esg; # revert changes to verbatim environments for line diffs (and add code to mark up changes) (note negative look behind assertions to not leak out of DIFDELCMD comments) # Example: @@ -3066,8 +3102,8 @@ sub postprocess { ((?:\%\Q$DELCOMMENT$VERBCOMMENT\E[^\n]*?\n)*) # Deleted \end command of verbatim environment. Note that the type is forced to match the opening. Captures: $5: Whole deleted environment (previous way this line was written: (\Q$DELCMDOPEN\E\\end\{\2\}(?:\n|\s|\Q$DELCMDOPEN\E)*\Q$DELCMDCLOSE\E) (\Q$DELCMDOPEN\E\\end\{\2\}) - / # Substitution part - $1 # Leave expression as is + / # Substitution part + $1 # Leave expression as is . "$AUXCMD NEXT\n" # Mark the following line as an auxiliary command . "" # reinstate the original environment without options . reverselinecomment($2, "$3$4") # modify the body to change the markup; reverselinecomment parses for options @@ -3076,7 +3112,7 @@ sub postprocess { /esgx; # Modifiers of substitution command writedebugfile($_,'postprocess2'); # where changes have occurred in verbatim environment, change verbatim to DIFverbatim to allow mark-up - # (I use the presence of optional paramater to verbatim environment as the marker - normal verbatim + # (I use the presence of optional paramater to verbatim environment as the marker - normal verbatim # environment does not take optional arguments) s/(?<!$DELCMDOPEN)\\begin\{(verbatim[*]?)\}(\[$brat_n\].*?)\\end\{\1\}/\\begin{DIF$1}$2\\end{DIF$1}/sg; @@ -3090,7 +3126,7 @@ sub postprocess { # convert remaining PAR commands (which are preceded by non-white space characters, usually "}" ($ADDCLOSE) s/\\PAR\n/\n\n/sg; - # package specific processing: + # package specific processing: if ( defined($packages{"endfloat"})) { #endfloat: make sure \begin{figure} and \end{figure} are always # on a line by themselves, similarly for table environment @@ -3103,12 +3139,16 @@ sub postprocess { s/^((?:[^%]+)\\(?:begin|end)\{(?:figure|table)\}(?:\[[a-zA-Z]+\])?)(.+)((?:%.*)?)$/$1\n$2$3/mg; } - # Convert '\PERCENTAGE ' back into '\%' (the final question mark catches a special situation where due to a latter pre-processing step the ' ' becomes separated + # Remove empty auxiliary LISTENV (sometmes these are generated if list environment occurs within the argument of a deleted comment) + # (slightly hacky but I could not see an easy way to see if in argument of another command when this extra markup is added) + s/\\begin\{($LISTENV)\}$AUXCMD\n((?:\s*\%[^\n]*\n)*\n?)\\end\{\1\}$AUXCMD\n/$2\n/msg ; + + # Convert '\PERCENTAGE ' back into '\%' (the final question mark catches a special situation where due to a latter pre-processing step the ' ' becomes separated s/\\PERCENTAGE ?/\\%/g; - # Convert '\DOLLAR ' back into '\$' + # Convert '\DOLLAR ' back into '\$' s/\\DOLLAR /\\\$/g; - # undo renaming of the \begin and \end,{,} and dollars in comments + # undo renaming of the \begin and \end,{,} and dollars in comments # although we only renamed $ in comments to DOLLARDIFF, we might have lost the % in unchanged verbatim blocks, so rename all s/DOLLARDIF/\$/g; @@ -3126,7 +3166,7 @@ sub postprocess { # Convert \SQRT{n} into \sqrt{n} and \SQRTNB{nn} into \sqrt nn 1 while s/\\SQRT(\s*\{($pat_n)\})/\\sqrt$1/g ; 1 while s/\\SQRTNB\{(\s*$pat0)\}/\\sqrt$1/g ; - + 1 while s/(%.*)\\CFRAC (.*)$/$1\\frac$2/mg ; 1 while s/(%.*)\\CRIGHTBRACE (.*)$/$1\}$2/mg ; 1 while s/(%.*)\\CLEFTBRACE (.*)$/$1\{$2/mg ; @@ -3137,7 +3177,7 @@ sub postprocess { s/\\QRIGHTBRACE /\\\}/sg; s/\\AMPERSAND /\\&/sg; # Highlight added inline verbatim commands if possible - if ( $latexdiffpreamble =~ /\\RequirePackage(?:\[$brat_n\])?\{color\}/ ) { + if ( $latexdiffpreamble =~ /\\RequirePackage(?:\[$brat_n\])?\{color\}/ ) { # wrap added verb commands with color commands s/\\DIFDIFadd((?:verb\*?|lstinline(?:\[$brat_n\])?)\{[-\d]*?\}[\s\n]*)/\{\\color{blue}$AUXCMD\n\\DIF$1%\n\}$AUXCMD\n/sg; s/\\DIFDIFdel((?:verb\*?|lstinline(?:\[$brat_n\])?)\{[-\d]*?\}[\s\n]*$AUXCMD)/\{\\color{red}${AUXCMD}\n\\DIF$1\n\}${AUXCMD}/sg; @@ -3152,8 +3192,8 @@ sub postprocess { # finally add the comment to the ones not having an optional argument before ###s/\\DIFaddlstinline(?!\[)/\\lstinline\n[basicstyle=\\color{blue}]$AUXCMD\n/g; - return; } + return; } # $out = restore_item_commands($listenviron) @@ -3177,13 +3217,13 @@ sub restore_item_commands { # @auxlines=preprocess_preamble($oldpreamble,$newpreamble); - # pre-process preamble by looking for commands used in \maketitle (title, author, date etc commands) - # the list of commands is defined in CONTEXT2CMD - # if found then use a bodydiff to mark up content, and replace the corresponding commands + # pre-process preamble by looking for commands used in \maketitle (title, author, date etc commands) + # the list of commands is defined in CONTEXT2CMD + # if found then use a bodydiff to mark up content, and replace the corresponding commands # in both preambles by marked up version to 'fool' the linediff (such that only body is marked up). # A special case are e.g. author commands being added (or removed) # 1. If commands are added, then the entire content is marked up as new, but also the lines are marked as new in the linediff - # 2. If commands are removed, then the linediff will mark the line as deleted. The program returns + # 2. If commands are removed, then the linediff will mark the line as deleted. The program returns # with $auxlines a text to be appended at the end of the preamble, which shows the respective fields as deleted sub preprocess_preamble { my ($oldpreambleref,$newpreambleref)=(\$_[0],\$_[1]) ; @@ -3205,7 +3245,7 @@ EOF $titlecmd = "(?:".join("|",@CONTEXT2CMDLIST).")"; # as context2cmdlist is stored as regex, e.g. ((?-xism:^title$), we need to remove ^- fo # resue in a more complex regex - $titlecmd =~ s/[\$\^]//g; + $titlecmd =~ s/[\$\^]//g; # make sure to not match on comment lines: $titlecmdpat=qr/^(?:[^%\n]|\\%)*(\\($titlecmd)$extraspace(?:\[($brat_n)\])?(?:\{($pat_n)\}))/ms; ###print STDERR "DEBUG:",$titlecmdpat,"\n"; @@ -3231,7 +3271,7 @@ EOF $cmd=shift @newtitlecommands; $optarg=shift @newtitlecommands; $arg=shift @newtitlecommands; - + if ( defined($newhash{$cmd})) { warn "$cmd is used twice in preamble of new file. Reverting to pure line diff mode for preamble.\n"; print STDERR $warnmsgdetail; @@ -3258,7 +3298,7 @@ EOF } $argnew=$newhash{$cmd}->[2]; $argdiff="{" . join("",bodydiff($argold,$argnew)) ."}"; - # Replace \RIGHTBRACE by } + # Replace \RIGHTBRACE by } $argdiff =~ s/\\RIGHTBRACE/}/g; if ( length $optargnew ) { @@ -3273,7 +3313,7 @@ EOF $optargdiff=""; } ### print STDERR "DEBUG s/\\Q$newhash{$cmd}->[0]\\E/\\$cmd$optargdiff$argdiff/s\n"; - # Note: \Q and \E force literal interpretation of what it between them but allow + # Note: \Q and \E force literal interpretation of what it between them but allow # variable interpolation, such that e.g. \title matches just that and not TAB-itle $$newpreambleref=~s/\Q$newhash{$cmd}->[0]\E/\\$cmd$optargdiff$argdiff/s; # replace this in old preamble if necessary @@ -3313,7 +3353,7 @@ EOF #%< old deleted line(s) #%DIF ------- #%DIF mmann-nn -#new appended line %< +#new appended line %< #%DIF ------- # Future extension: mark change explicitly # Assumes: traverse_sequence traverses deletions before insertions in changed sequences @@ -3325,9 +3365,9 @@ sub linediff { my $block = []; my $retseq = []; my @begin=('','',''); # dummy initialisation - my $instring ; + my $instring ; - my $discard = sub { @begin=('d',$_[0],$_[1]) unless scalar @$block ; + my $discard = sub { @begin=('d',$_[0],$_[1]) unless scalar @$block ; push(@$block, "%DIF < " . $seq1->[$_[0]]) }; my $add = sub { if (! scalar @$block) { @begin=('a',$_[0],$_[1]) ;} @@ -3342,12 +3382,12 @@ sub linediff { $instring = sprintf "%%DIF %da%d-%d",$begin[1],$begin[2],$_[1]-1; } elsif ( $begin[0] eq 'c' ) { $instring = sprintf "%%DIF %sc%s", - ($begin[1]==$_[0]-1) ? "$begin[1]" : $begin[1]."-".($_[0]-1) , + ($begin[1]==$_[0]-1) ? "$begin[1]" : $begin[1]."-".($_[0]-1) , ($begin[2]==$_[1]-1) ? "$begin[2]" : $begin[2]."-".($_[1]-1) ; } else { $instring = sprintf "%%DIF %d%s%d",$begin[1],$begin[0],$begin[2]; } - push @$retseq, $instring,@$block, "%DIF -------" ; - $block = []; + push @$retseq, $instring,@$block, "%DIF -------" ; + $block = []; } push @$retseq, $seq2->[$_[1]] }; @@ -3355,7 +3395,7 @@ sub linediff { my $keyfunc = sub { join(" ",split(" ",shift())) }; traverse_sequences($seq1,$seq2, { MATCH=>$match, DISCARD_A=>$discard, DISCARD_B=>$add }, $keyfunc ); - push @$retseq, @$block if scalar @$block; + push @$retseq, @$block if scalar @$block; return wantarray ? @$retseq : $retseq ; } @@ -3365,23 +3405,23 @@ sub linediff { # init_regex_arr_data(\@array,"TOKEN INIT") # scans DATA file handel for line "%% TOKEN INIT" line # then appends each line not beginning with % into array (as a quoted regex) -# This is used for command lists and configuration variables, but the processing is slightly -# different: +# This is used for command lists and configuration variables, but the processing is slightly +# different: # For lists, the regular expression is extended to include beginning (^) and end ($) markers, to require full-string matching # For configuration variables (and all others), simply an unadorned list is copied sub init_regex_arr_data { my ($arr,$token)=@_; my $copy=0; my ($mode); - if ($token =~ m/COMMANDS/ ) { - $mode=0; # Reading command list + if ($token =~ m/COMMANDS/ ) { + $mode=0; # Reading command list } else { $mode=1; # Reading configuration variables } while (<DATA>) { if ( m/^%%BEGIN $token\s*$/ ) { - $copy=1; + $copy=1; next; } elsif ( m/^%%END $token\s*$/ ) { last; } @@ -3462,17 +3502,18 @@ sub exetime { sub usage { - print STDERR <<"EOF"; + print STDERR <<"EOF"; Usage: $0 [options] old.tex new.tex > diff.tex -Compares two latex files and writes tex code to stdout, which has the same format as new.tex but +Compares two latex files and writes tex code to stdout, which has the same format as new.tex but has all changes relative to old.tex marked up or commented. Note that old.tex and new.tex need to -be real files (not pipes or similar) as they are opened twice. +be real files (not pipes or similar) as they are opened twice. --type=markupstyle -t markupstyle Add code to preamble for selected markup style - Available styles: UNDERLINE CTRADITIONAL TRADITIONAL CFONT FONTSTRIKE INVISIBLE + Available styles: UNDERLINE CTRADITIONAL TRADITIONAL CFONT FONTSTRIKE INVISIBLE CHANGEBAR CCHANGEBAR CULINECHBAR CFONTCHBAR BOLD PDFCOMMENT + LUAUNDERLINE [ Default: UNDERLINE ] --subtype=markstyle @@ -3483,7 +3524,7 @@ be real files (not pipes or similar) as they are opened twice. * LABEL subtype is deprecated --floattype=markstyle --f markstyle Add code to preamble for selected style which +-f markstyle Add code to preamble for selected style which replace standard marking and markup commands within floats (e.g., marginal remarks cause an error within floats so marginal marking can be disabled thus) @@ -3492,11 +3533,11 @@ be real files (not pipes or similar) as they are opened twice. --encoding=enc -e enc Specify encoding of old.tex and new.tex. Typical encodings are - ascii, utf8, latin1, latin9. A list of available encodings can be - obtained by executing + ascii, utf8, latin1, latin9. A list of available encodings can be + obtained by executing perl -MEncode -e 'print join ("\\n",Encode->encodings( ":all" )) ;' [Default encoding is utf8 unless the first few lines of the preamble contain - an invocation "\\usepackage[..]{inputenc} in which case the + an invocation "\\usepackage[..]{inputenc} in which case the encoding chosen by this command is asssumed. Note that ASCII (standard latex) is a subset of utf8] @@ -3513,22 +3554,22 @@ be real files (not pipes or similar) as they are opened twice. --exclude-safecmd=exclude-file --exclude-safecmd="cmd1,cmd2,..." --A exclude-file +-A exclude-file --replace-safecmd=replace-file --append-safecmd=append-file --append-safecmd="cmd1,cmd2,..." -a append-file Exclude from, replace or append to the list of regex - matching commands which are safe to use within the + matching commands which are safe to use within the scope of a \\DIFadd or \\DIFdel command. The file must contain one Perl-RegEx per line (Comment lines beginning with # or % are ignored). A literal comma within the comma-separated list must be - escaped thus "\\,", Note that the RegEx needs to match the whole of + escaped thus "\\,", Note that the RegEx needs to match the whole of the token, i.e., /^regex\$/ is implied and that the initial "\\" of the command is not included. The --exclude-safecmd - and --append-safecmd options can be combined with the --replace-safecmd + and --append-safecmd options can be combined with the --replace-safecmd option and can be used repeatedly to add cumulatively to the lists. ---exclude-textcmd=exclude-file +--exclude-textcmd=exclude-file --exclude-textcmd="cmd1,cmd2,..." -X exclude-file --replace-textcmd=replace-file @@ -3544,7 +3585,7 @@ be real files (not pipes or similar) as they are opened twice. Replace or append to the list of regex matching commands whose last argument is text but which require a particular context to work, e.g. \\caption will only work within a figure - or table. These commands behave like text commands, except when + or table. These commands behave like text commands, except when they occur in a deleted section, when they are disabled, but their argument is shown as deleted text. @@ -3554,7 +3595,7 @@ be real files (not pipes or similar) as they are opened twice. As corresponding commands for context1. The only difference is that context2 commands are completely disabled in deleted sections, including their arguments. - context2 commands are also the only commands in the preamble, whose argument will + context2 commands are also the only commands in the preamble, whose argument will be processed in word-by-word mode (which only works, if they occur no more than once in the preamble). @@ -3563,15 +3604,15 @@ be real files (not pipes or similar) as they are opened twice. --append-mboxsafecmd=append-file --append-mboxsafecmd="cmd1,cmd2,..." Define safe commands, which additionally need to be protected by encapsulating - in an \\mbox{..}. This is sometimes needed to get around incompatibilities + in an \\mbox{..}. This is sometimes needed to get around incompatibilities between external packages and the ulem package, which is used for highlighting in the default style UNDERLINE as well as CULINECHBAR CFONTSTRIKE - + --config var1=val1,var2=val2,... -c var1=val1,.. Set configuration variables. --c configfile Available variables: +-c configfile Available variables: ARRENV (RegEx) COUNTERCMD (RegEx) FLOATENV (RegEx) @@ -3590,15 +3631,15 @@ be real files (not pipes or similar) as they are opened twice. --add-to-config varenv1=pattern1,varenv2=pattern2 For configuration variables containing a regular expression (essentially those ending - in ENV, and COUNTERCMD) this provides an alternative way to modify the configuration + in ENV, and COUNTERCMD) this provides an alternative way to modify the configuration variables. Instead of setting the complete pattern, with this option it is possible to add an alternative pattern. varenv must be one of the variables listed above that take a regular - expression as argument, and pattern is any regular expression (which might need to be + expression as argument, and pattern is any regular expression (which might need to be protected from the shell by quotation). Several patterns can be added at once by using semi-colons to separate them, e.g. --add-to-config "LISTENV=myitemize;myenumerate,COUNTERCMD=endnote" --packages=pkg1,pkg2,.. - Tell latexdiff that .tex file is processed with the packages in list + Tell latexdiff that .tex file is processed with the packages in list loaded. This is normally not necessary if the .tex file includes the preamble, as the preamble is automatically scanned for \\usepackage commands. Use of the --packages option disables automatic scanning, so if for any @@ -3619,57 +3660,57 @@ be real files (not pipes or similar) as they are opened twice. --show-all Show all of the above - NB For all --show commands, no old.tex or new.tex file needs to be given, and no + NB For all --show commands, no old.tex or new.tex file needs to be given, and no differencing takes place. Other configuration options: --allow-spaces Allow spaces between bracketed or braced arguments to commands - [Default requires arguments to directly follow each other without + [Default requires arguments to directly follow each other without intervening spaces] --math-markup=level Determine granularity of markup in displayed math environments: Possible values for level are (both numerical and text labels are acceptable): - off or 0: suppress markup for math environments. Deleted equations will not - appear in diff file. This mode can be used if all the other modes + off or 0: suppress markup for math environments. Deleted equations will not + appear in diff file. This mode can be used if all the other modes cause invalid latex code. whole or 1: Differencing on the level of whole equations. Even trivial changes - to equations cause the whole equation to be marked changed. This - mode can be used if processing in coarse or fine mode results in + to equations cause the whole equation to be marked changed. This + mode can be used if processing in coarse or fine mode results in invalid latex code. coarse or 2: Detect changes within equations marked up with a coarse - granularity; changes in equation type (e.g.displaymath to equation) + granularity; changes in equation type (e.g.displaymath to equation) appear as a change to the complete equation. This mode is recommended for situations where the content and order of some equations are still being changed. [Default] fine or 3: Detect small change in equations and mark up and fine granularity. This mode is most suitable, if only minor changes to equations are - expected, e.g. correction of typos. + expected, e.g. correction of typos. --graphics-markup=level Change highlight style for graphics embedded with \\includegraphics commands Possible values for level: none,off or 0: no highlighting for figures new-only or 1: surround newly added or changed figures with a blue frame [Default] - both or 2: highlight new figures with a blue frame and show deleted figures + both or 2: highlight new figures with a blue frame and show deleted figures at reduced scale, and crossed out with a red diagonal cross. Use configuration variable SCALEDELGRAPHICS to set size of deleted figures. - Note that changes to the optional parameters will make the figure appear as changed + Note that changes to the optional parameters will make the figure appear as changed to latexdiff, and this figure will thus be highlighted. In some circumstances "Misplaced \\noalign" errors can occur if there are certain types - of changes in tables. In this case please use option --graphics-markup=none as a - work-around. + of changes in tables. In this case please use option --graphics-markup=none as a + work-around. ---no-del Suppress deleted text from the diff. It is similar in effect to the BOLD style, +--no-del Suppress deleted text from the diff. It is similar in effect to the BOLD style, but the deleted text ist not just invisible in the output, it is also not included in the - diff text file. This can be more robust than just making it invisible. + diff text file. This can be more robust than just making it invisible. ---disable-citation-markup ---disable-auto-mbox Suppress citation markup and markup of other vulnerable commands in styles +--disable-citation-markup +--disable-auto-mbox Suppress citation markup and markup of other vulnerable commands in styles using ulem (UNDERLINE,FONTSTRIKE, CULINECHBAR) (the two options are identical and are simply aliases) --enable-citation-markup ---enforce-auto-mbox Protect citation commands and other vulnerable commands in changed sections +--enforce-auto-mbox Protect citation commands and other vulnerable commands in changed sections with \\mbox command, i.e. use default behaviour for ulem package for other packages (the two options are identical and are simply aliases) @@ -3685,14 +3726,14 @@ Miscellaneous options --no-label Suppress inclusion of old and new file names as comment in output file ---visible-label Include old and new filenames (or labels set with --label option) as +--visible-label Include old and new filenames (or labels set with --label option) as visible output --flatten Replace \\input and \\include commands within body by the content of the files in their argument. If \\includeonly is present in the - preamble, only those files are expanded into the document. However, - no recursion is done, i.e. \\input and \\include commands within - included sections are not expanded. The included files are assumed to + preamble, only those files are expanded into the document. However, + no recursion is done, i.e. \\input and \\include commands within + included sections are not expanded. The included files are assumed to be located in the same directories as the old and new master files, respectively, making it possible to organise files into old and new directories. --flatten is applied recursively, so inputted files can contain further @@ -3715,7 +3756,7 @@ Miscellaneous options -h Show this help text. --ignore-warnings Suppress warnings about inconsistencies in length between input - and parsed strings and missing characters. + and parsed strings and missing characters. --verbose -V Output various status information to stderr during processing. @@ -3727,10 +3768,10 @@ Internal options: These options are mostly for automated use by latexdiff-vc. They can be used directly, but the API should be considered less stable than for the other options. ---no-links Suppress generation of hyperreferences, used for minimal diffs +--no-links Suppress generation of hyperreferences, used for minimal diffs (option --only-changes of latexdiff-vc). EOF - exit 0; + exit 0; } =head1 NAME @@ -3756,8 +3797,8 @@ be real files (not pipes or similar) as they are opened twice (unless C<--encodi The program treats the preamble differently from the main document. Differences between the preambles are found using line-based differencing (similarly to the Unix diff command, but ignoring white -spaces). A comment, "S<C<%DIF E<gt>>>" is appended to each added line, i.e. a -line present in C<new.tex> but not in C<old.tex>. Discarded lines +spaces). A comment, "S<C<%DIF E<gt>>>" is appended to each added line, i.e. a +line present in C<new.tex> but not in C<old.tex>. Discarded lines are deactivated by prepending "S<C<%DIF E<lt>>>". Changed blocks are preceded by comment lines giving information about line numbers in the original files. Where there are insignificant differences, the resulting file C<diff.tex> will be similar to @@ -3810,7 +3851,7 @@ curly braces immediately following a command (i.e. a sequence of letters beginning with a backslash) are arguments for that command. As a restriction to condition 1 above it is thus necessary to surround all arguments with curly braces, and to not insert -extraneous spaces. For example, write +extraneous spaces. For example, write \section{\textem{This is an emphasized section title}} @@ -3842,7 +3883,7 @@ but the choice is yours. Any markup within the environment will be removed, and generally everything within the environment will just be taken from the new file. -It is also possible to difference files which do not have a preamble. +It is also possible to difference files which do not have a preamble. In this case, the file is processed in the main document mode, but the definitions of the markup commands are not inserted. @@ -3860,7 +3901,7 @@ the scope of C<\DIFadd>. Added comments are marked by prepending Within deleted blocks text is highlighted with C<\DIFdel>. Deleted comments are marked by prepending "S<C<%DIF E<lt> >>". Non-safe command -and curly braces within deleted blocks are commented out with +and curly braces within deleted blocks are commented out with "S<C<%DIFDELCMD E<lt> >>". @@ -3870,7 +3911,7 @@ and curly braces within deleted blocks are commented out with =head2 Preamble The following options determine the visual markup style by adding the appropriate -command definitions to the preamble. See the end of this section for a description of +command definitions to the preamble. See the end of this section for a description of available styles. =over 4 @@ -3880,15 +3921,16 @@ B<-t markupstyle> Add code to preamble for selected markup style. This option defines C<\DIFadd> and C<\DIFdel> commands. -Available styles: +Available styles: -C<UNDERLINE CTRADITIONAL TRADITIONAL CFONT FONTSTRIKE INVISIBLE -CHANGEBAR CCHANGEBAR CULINECHBAR CFONTCHBAR BOLD PDFCOMMENT> +C<UNDERLINE CTRADITIONAL TRADITIONAL CFONT FONTSTRIKE INVISIBLE +CHANGEBAR CCHANGEBAR CULINECHBAR CFONTCHBAR BOLD PDFCOMMENT +LUAUNDERLINE> [ Default: C<UNDERLINE> ] =item B<--subtype=markstyle> or -B<-s markstyle> +B<-s markstyle> Add code to preamble for selected style for bracketing commands (e.g. to mark changes in margin). This option defines @@ -3901,27 +3943,27 @@ Available styles: C<SAFE MARGIN COLOR DVIPSCOL ZLABEL ONLYCHANGEDPAGE (LABEL)*> =item B<--floattype=markstyle> or B<-f markstyle> -Add code to preamble for selected style which +Add code to preamble for selected style which replace standard marking and markup commands within floats (e.g., marginal remarks cause an error within floats -so marginal marking can be disabled thus). This option defines all +so marginal marking can be disabled thus). This option defines all C<\DIF...FL> commands. Available styles: C<FLOATSAFE TRADITIONALSAFE IDENTICAL> [ Default: C<FLOATSAFE> ] -=item B<--encoding=enc> or +=item B<--encoding=enc> or B<-e enc> Specify encoding of old.tex and new.tex. Typical encodings are -C<ascii>, C<utf8>, C<latin1>, C<latin9>. A list of available encodings can be -obtained by executing +C<ascii>, C<utf8>, C<latin1>, C<latin9>. A list of available encodings can be +obtained by executing C<perl -MEncode -e 'print join ("\n",Encode->encodings( ":all" )) ;' > If this option is used, then old.tex, new.tex are only opened once. [Default encoding is utf8 unless the first few lines of the preamble contain -an invocation C<\usepackage[..]{inputenc}> in which case the +an invocation C<\usepackage[..]{inputenc}> in which case the encoding chosen by this command is asssumed. Note that ASCII (standard latex) is a subset of utf8] @@ -3938,7 +3980,7 @@ C<\DIFaddbeginFL, \DIFaddendFL, \DIFaddFL{..}, (If this option is set B<-t>, B<-s>, and B<-f> options are ignored.) -=item B<--packages=pkg1,pkg2,..> +=item B<--packages=pkg1,pkg2,..> Tell latexdiff that .tex file is processed with the packages in list loaded. This is normally not necessary if the .tex file includes the @@ -3949,13 +3991,13 @@ The following packages trigger special behaviour: =over 8 -=item C<endfloat> +=item C<endfloat> Ensure that C<\begin{figure}> and C<\end{figure}> always appear by themselves on a line. =item C<hyperref> -Change name of C<\DIFadd> and C<\DIFdel> commands to C<\DIFaddtex> and C<\DIFdeltex> and +Change name of C<\DIFadd> and C<\DIFdel> commands to C<\DIFaddtex> and C<\DIFdeltex> and define new C<\DIFadd> and C<\DIFdel> commands, which provide a wrapper for these commands, using them for the text but not for the link defining command (where any markup would cause errors). @@ -4007,17 +4049,17 @@ B<-A exclude-file> or B<--exclude-safecmd="cmd1,cmd2,..."> =item B<--replace-safecmd=replace-file> -=item B<--append-safecmd=append-file> or +=item B<--append-safecmd=append-file> or B<-a append-file> or B<--append-safecmd="cmd1,cmd2,..."> Exclude from, replace or append to the list of regular expressions (RegEx) -matching commands which are safe to use within the +matching commands which are safe to use within the scope of a C<\DIFadd> or C<\DIFdel> command. The file must contain one Perl-RegEx per line (Comment lines beginning with # or % are -ignored). Note that the RegEx needs to match the whole of +ignored). Note that the RegEx needs to match the whole of the token, i.e., /^regex$/ is implied and that the initial -"\" of the command is not included. -The B<--exclude-safecmd> and B<--append-safecmd> options can be combined with the -B<--replace-safecmd> +"\" of the command is not included. +The B<--exclude-safecmd> and B<--append-safecmd> options can be combined with the -B<--replace-safecmd> option and can be used repeatedly to add cumulatively to the lists. B<--exclude-safecmd> and B<--append-safecmd> can also take a comma separated list as input. If a @@ -4030,7 +4072,7 @@ B<-X exclude-file> or B<--exclude-textcmd="cmd1,cmd2,..."> =item B<--replace-textcmd=replace-file> -=item B<--append-textcmd=append-file> or +=item B<--append-textcmd=append-file> or B<-x append-file> or B<--append-textcmd="cmd1,cmd2,..."> Exclude from, replace or append to the list of regular expressions @@ -4038,7 +4080,7 @@ matching commands whose last argument is text. See entry for B<--exclude-safecmd> directly above for further details. -=item B<--replace-context1cmd=replace-file> +=item B<--replace-context1cmd=replace-file> =item B<--append-context1cmd=append-file> or @@ -4047,11 +4089,11 @@ entry for B<--exclude-safecmd> directly above for further details. Replace or append to the list of regex matching commands whose last argument is text but which require a particular context to work, e.g. C<\caption> will only work within a figure -or table. These commands behave like text commands, except when +or table. These commands behave like text commands, except when they occur in a deleted section, when they are disabled, but their argument is shown as deleted text. -=item B<--replace-context2cmd=replace-file> +=item B<--replace-context2cmd=replace-file> =item B<--append-context2cmd=append-file> or @@ -4061,9 +4103,9 @@ As corresponding commands for context1. The only difference is that context2 commands are completely disabled in deleted sections, including their arguments. -context2 commands are also the only commands in the preamble, whose argument will be processed in +context2 commands are also the only commands in the preamble, whose argument will be processed in word-by-word mode (which only works, if they occur no more than once in the preamble). The algorithm currently cannot cope with repeated context2 commands in the preamble, as they occur e.g. for the C<\author> argument in some journal styles (not in the standard styles, though -If such a repetition is detected, the whole preamble will be processed in line-by-line mode. In such a case, use C<--replace-context2cmd> option to just select the commands, which should be processed and are not used repeatedly in the preamble. +If such a repetition is detected, the whole preamble will be processed in line-by-line mode. In such a case, use C<--replace-context2cmd> option to just select the commands, which should be processed and are not used repeatedly in the preamble. @@ -4072,7 +4114,7 @@ If such a repetition is detected, the whole preamble will be processed in line-b =item B<--append-mboxsafecmd=append-file> or B<--append-mboxsafecmd="cmd1,cmd2,..."> Define safe commands, which additionally need to be protected by encapsulating -in an C<\mbox{..}>. This is sometimes needed to get around incompatibilities +in an C<\mbox{..}>. This is sometimes needed to get around incompatibilities between external packages and the ulem package, which is used for highlighting in the default style UNDERLINE as well as CULINECHBAR CFONTSTRIKE @@ -4086,7 +4128,7 @@ in the default style UNDERLINE as well as CULINECHBAR CFONTSTRIKE Set configuration variables. The option can be repeated to set different variables (as an alternative to the comma-separated list). -Available variables (see below for further explanations): +Available variables (see below for further explanations): C<ARRENV> (RegEx) @@ -4116,10 +4158,10 @@ C<SCALEDELGRAPHICS> (Float) =item B<--add-to-config varenv1=pattern1,varenv2=pattern2,...> For configuration variables, which are a regular expression (essentially those ending -in ENV, COUNTERCMD and CUSTOMDIFCMD, see list above) this option provides an alternative way to modify the configuration +in ENV, COUNTERCMD and CUSTOMDIFCMD, see list above) this option provides an alternative way to modify the configuration variables. Instead of setting the complete pattern, with this option it is possible to add an alternative pattern. C<varenv> must be one of the variables listed above that take a regular -expression as argument, and pattern is any regular expression (which might need to be +expression as argument, and pattern is any regular expression (which might need to be protected from the shell by quotation). Several patterns can be added at once by using semi-colons to separate them, e.g. C<--add-to-config "LISTENV=myitemize;myenumerate,COUNTERCMD=endnote"> @@ -4139,7 +4181,7 @@ Show values of configuration variables. Combine all --show commands. -NB For all --show commands, no C<old.tex> or C<new.tex> file needs to be specified, and no +NB For all --show commands, no C<old.tex> or C<new.tex> file needs to be specified, and no differencing takes place. =back @@ -4156,29 +4198,29 @@ might get lumpeded with preceding commands) so should only be used if the default produces erroneous results. (Default requires arguments to directly follow each other without intervening spaces). -=item B<--math-markup=level> +=item B<--math-markup=level> -Determine granularity of markup in displayed math environments: +Determine granularity of markup in displayed math environments: Possible values for level are (both numerical and text labels are acceptable): -C<off> or C<0>: suppress markup for math environments. Deleted equations will not -appear in diff file. This mode can be used if all the other modes +C<off> or C<0>: suppress markup for math environments. Deleted equations will not +appear in diff file. This mode can be used if all the other modes cause invalid latex code. C<whole> or C<1>: Differencing on the level of whole equations. Even trivial changes -to equations cause the whole equation to be marked changed. This -mode can be used if processing in coarse or fine mode results in +to equations cause the whole equation to be marked changed. This +mode can be used if processing in coarse or fine mode results in invalid latex code. C<coarse> or C<2>: Detect changes within equations marked up with a coarse -granularity; changes in equation type (e.g.displaymath to equation) +granularity; changes in equation type (e.g.displaymath to equation) appear as a change to the complete equation. This mode is recommended for situations where the content and order of some equations are still being changed. [Default] C<fine> or C<3>: Detect small change in equations and mark up at fine granularity. This mode is most suitable, if only minor changes to equations are -expected, e.g. correction of typos. +expected, e.g. correction of typos. =item B<--graphics-markup=level> @@ -4190,33 +4232,33 @@ C<none>, C<off> or C<0>: no highlighting for figures C<new-only> or C<1>: surround newly added or changed figures with a blue frame [Default if graphicx package loaded] -C<both> or C<2>: highlight new figures with a blue frame and show deleted figures at reduced +C<both> or C<2>: highlight new figures with a blue frame and show deleted figures at reduced scale, and crossed out with a red diagonal cross. Use configuration variable SCALEDELGRAPHICS to set size of deleted figures. -Note that changes to the optional parameters will make the figure appear as changed +Note that changes to the optional parameters will make the figure appear as changed to latexdiff, and this figure will thus be highlighted. In some circumstances "Misplaced \noalign" error can occur if there are certain types -of changes in tables. In this case please use C<--graphics-markup=none> as a -work-around. +of changes in tables. In this case please use C<--graphics-markup=none> as a +work-around. -=item B<--no-del> +=item B<--no-del> -Suppress deleted text from the diff. It is similar in effect to the BOLD style, -but the deleted text ist not just invisible in the output, it is also not included in the diff text file. -This can be more robust than just making it invisible. +Suppress deleted text from the diff. It is similar in effect to the BOLD style, +but the deleted text ist not just invisible in the output, it is also not included in the diff text file. +This can be more robust than just making it invisible. =item B<--disable-citation-markup> or B<--disable-auto-mbox> -Suppress citation markup and markup of other vulnerable commands in styles +Suppress citation markup and markup of other vulnerable commands in styles using ulem (UNDERLINE,FONTSTRIKE, CULINECHBAR) (the two options are identical and are simply aliases) =item B<--enable-citation-markup> or B<--enforce-auto-mbox> -Protect citation commands and other vulnerable commands in changed sections +Protect citation commands and other vulnerable commands in changed sections with C<\mbox> command, i.e. use default behaviour for ulem package for other packages (the two options are identical and are simply aliases) @@ -4262,18 +4304,18 @@ Suppress inclusion of old and new file names as comment in output file =item B<--visible-label> -Include old and new filenames (or labels set with C<--label> option) as +Include old and new filenames (or labels set with C<--label> option) as visible output. =item B<--flatten> Replace C<\input> and C<\include> commands within body by the content of the files in their argument. If C<\includeonly> is present in the -preamble, only those files are expanded into the document. However, -no recursion is done, i.e. C<\input> and C<\include> commands within -included sections are not expanded. The included files are assumed to +preamble, only those files are expanded into the document. However, +no recursion is done, i.e. C<\input> and C<\include> commands within +included sections are not expanded. The included files are assumed to be located in the same directories as the old and new master files, -respectively, making it possible to organise files into old and new directories. +respectively, making it possible to organise files into old and new directories. --flatten is applied recursively, so inputted files can contain further C<\input> statements. Also handles files included by the import package (C<\import> and C<\subimport>), and C<\subfile> command. @@ -4320,7 +4362,7 @@ Suppress generation of hyperreferences, used for minimal diffs (option --only-ch =back -=head2 Predefined styles +=head2 Predefined styles =head2 Major types @@ -4333,9 +4375,14 @@ The major type determine the markup of plain text and some selected latex comman Added text is wavy-underlined and blue, discarded text is struck out and red (Requires color and ulem packages). Overstriking does not work in displayed math equations such that deleted parts of equation are underlined, not struck out (this is a shortcoming inherent to the ulem package). +=item C<LUAUNDERLINE> + +Added text is underlined and blue, discarded text is struck out and red +(Requires lua-ul package + LuaLaTeX). + =item C<CTRADITIONAL> -Added text is blue and set in sans-serif, and a red footnote is created for each discarded +Added text is blue and set in sans-serif, and a red footnote is created for each discarded piece of text. (Requires color package) =item C<TRADITIONAL> @@ -4376,13 +4423,13 @@ Added text is set in bold face, discarded is not shown. (also see --no-del optio =item C<PDFCOMMENT> -The pdfcomment package is used to underline new text, and mark deletions with a PDF comment. Note that this markup might appear differently or not at all based on the pdf viewer used. The viewer with best support for pdf markup is probably acroread. This style is only recommended if the number of differences is small. +The pdfcomment package is used to underline new text, and mark deletions with a PDF comment. Note that this markup might appear differently or not at all based on the pdf viewer used. The viewer with best support for pdf markup is probably acroread. This style is only recommended if the number of differences is small. =back =head2 Subtypes -The subtype defines the commands that are inserted at the begin and end of added or discarded blocks, irrespectively of whether these blocks contain text or commands (Defined commands: C<\DIFaddbegin, \DIFaddend, \DIFdelbegin, \DIFdelend>) +The subtype defines the commands that are inserted at the begin and end of added or discarded blocks, irrespectively of whether these blocks contain text or commands (Defined commands: C<\DIFaddbegin, \DIFaddend, \DIFdelbegin, \DIFdelend>) =over 10 @@ -4400,7 +4447,7 @@ from the intended position. An alternative way of marking added passages in blue, and deleted ones in red. (It is recommeneded to use instead the main types to effect colored markup, -although in some cases coloring with dvipscol can be more complete, for example +although in some cases coloring with dvipscol can be more complete, for example with citation commands). =item C<DVIPSCOL> @@ -4415,12 +4462,12 @@ although in some cases coloring with dvipscol can be more complete). can be used to highlight only changed pages, but requires post-processing. It is recommend to not call this option manually but use C<latexdiff-vc> with C<--only-changes> option. Alternatively, use the script given within preamble of diff files made using this style. -=item C<ONLYCHANGEDPAGE> +=item C<ONLYCHANGEDPAGE> also highlights changed pages, without the need for post-processing, but might not work reliably if there is floating material (figures, tables). -=item C<LABEL> +=item C<LABEL> is similar to C<ZLABEL>, but does not need the zref package and works less reliably (deprecated). @@ -4428,7 +4475,7 @@ is similar to C<ZLABEL>, but does not need the zref package and works less relia =head2 Float Types -Some of the markup used in the main text might cause problems when used within +Some of the markup used in the main text might cause problems when used within floats (e.g. figures or tables). For this reason alternative versions of all markup commands are used within floats. The float type defines these alternative commands. @@ -4455,7 +4502,7 @@ Make no difference between the main text and floats. =item C<ARRENV> -If a match to C<ARRENV> is found within an inline math environment within a deleted or added block, then the inlined math +If a match to C<ARRENV> is found within an inline math environment within a deleted or added block, then the inlined math is surrounded by C<\mbox{>...C<}>. This is necessary as underlining does not work within inlined array environments. [ Default: C<ARRENV>=S<C<(?:array|[pbvBV]matrix)> > @@ -4475,9 +4522,9 @@ C<|subsubsection|paragraph|subparagraph)> ] This option is for advanced users and allows definition of special versions of commands, which do not work as safe commands. Commands in C<CUSTOMDIFCMD> that occur in added or deleted blocks will be given an ADD or DEL prefix. -The prefixed versions of the command must be defined in the preamble, either by putting them +The prefixed versions of the command must be defined in the preamble, either by putting them in the preamble of at least the new file, or by creating a custom preamble file (Option --preamble). -For example the command C<\blindtext> (from package blindtext) does not interact well with underlining, so that +For example the command C<\blindtext> (from package blindtext) does not interact well with underlining, so that for the standard markup type, it is not satisfactory to define it as a safe command. Instead, a customised versions without underlining can be defined in the preamble: @@ -4491,7 +4538,7 @@ and then latexdiff should be invoked with the option C<-c CUSTOMDIFCMD=blindtext =item C<FLOATENV> -Environments whose name matches the regular expression in C<FLOATENV> are +Environments whose name matches the regular expression in C<FLOATENV> are considered floats. Within these environments, the I<latexdiff> markup commands are replaced by their FL variaties. @@ -4540,17 +4587,17 @@ If C<--graphics-markup=both> is chosen, C<SCALEDELGRAPHICS> is the factor, by wh =item C<VERBATIMENV> -RegEx describing environments like verbatim, whose contents should be taken verbatim. The content of these environments will not be processed in any way: +RegEx describing environments like verbatim, whose contents should be taken verbatim. The content of these environments will not be processed in any way: deleted content is commented out, new content is not marked up [ Default: S<C<comment> > ] =item C<VERBATIMLINEENV> -RegEx describing environments like verbatim, whose contents should be taken verbatim. The content of environments described by VERBATIMLINEENV are compared in +RegEx describing environments like verbatim, whose contents should be taken verbatim. The content of environments described by VERBATIMLINEENV are compared in line mode, and changes are marked up using the listings package. The markup style is set based on the chosen mains markup type (Option -t), or on an analysis of the preamble. -Note that "listings.sty" must be installed. If this file is not found the fallback solution is to +Note that "listings.sty" must be installed. If this file is not found the fallback solution is to treat VERBATIMLINEENV environments treated exactly the same way as VERBATIMENV environments. [ Default: S<C<(?:verbatim[*]?|lstlisting> > ] @@ -4561,30 +4608,40 @@ treat VERBATIMLINEENV environments treated exactly the same way as VERBATIMENV e =over 10 -=item Citations result in overfull boxes +=item Changed citations result in overfull boxes There is an incompatibility between the C<ulem> package, which C<latexdiff> uses for underlining and striking out in the UNDERLINE style, -the default style, and the way citations are generated. In order to be able to mark up citations properly, they are enclosed with an C<\mbox> -command. As mboxes cannot be broken across lines, this procedure frequently results in overfull boxes, possibly obscuring the content as it extends beyond the right margin. The same occurs for some other packages (e.g., siunitx). If this is a problem, you have two possibilities. +the default style, and the way citations are generated. In order to be able to mark up citations properly, they are enclosed with an C<\mbox> +command. As mboxes cannot be broken across lines, this procedure frequently results in overfull boxes, possibly obscuring the content as it extends beyond the right margin. The same occurs for some other packages (e.g., siunitx). If this is a problem, you have several possibilities. 1. Use C<CFONT> type markup (option C<-t CFONT>): If this markup is chosen, then changed citations are no longer marked up -with the wavy line (additions) or struck out (deletions), but are still highlighted in the appropriate color, and deleted text is shown with a different font. Other styles not using the C<ulem> package will also work. +with the wavy line (additions) or struck out (deletions), but are still highlighted in the appropriate color, and deleted text is shown with a different font. Other styles not using the C<ulem> package will also work. 2. Choose option C<--disable-citation-markup> which turns off the marking up of citations: deleted citations are no longer shown, and -added citations are shown without markup. (This was the default behaviour of latexdiff at versions 0.6 and older) - +added citations are shown without markup. (This was the default behaviour of latexdiff at versions 0.6 and older). For custom packages you can define the commands which need to be protected by C<\mbox> with C<--append-mboxsafecmd> and C<--excludemboxsafecmd> options (submit your lists of command as feature request at github page to set the default behaviour of future versions, see section 6) -=item Changes in complicated mathematical equations result in latex processing errors +3. If you are using luatex >= 1.12.0 you can use option LUAUNDERLINE that uses lua-ul instead of ulem for underlining, which does not have this problem (experimental feature). + +=item Changes in complicated mathematical equations result in latex processing errors. + +Try option C<--math-markup=whole>. If even that fails, you can turn off mark up for equations with C<--math-markup=off>. -Try options C<--math-markup=whole>. If even that fails, you can turn off mark up for equations with C<--math-markup=off>. +=item Deleted parts in equations are not struck out but underlined. -=item How can I just show the pages where changes had been made +This is a limitation of the ulem package that implements the strike-out. If you use the amsmath package, then the strike-out command is redefined in such a way that deleted passages are wrapped with C<\text> command; adding C<\usepackage{amsmath}> to your preamble will trigger this behaviour. (If amsmath is not included directly, but imported by another package, latexdiff will not be able to detect its availability; in this case you can give latexdiff a hint with option C<--packages=amsmath>. -Use options -C<-s ZLABEL> (some postprocessing required) or C<-s ONLYCHANGEDPAGE>. C<latexdiff-vc --ps|--pdf> with C<--only-changes> option takes care of + +=item How can I just show the pages where changes had been made? + +Use options C<--s ZLABEL> (some postprocessing required) or C<-s ONLYCHANGEDPAGE>. C<latexdiff-vc --ps|--pdf> with C<--only-changes> option takes care of the post-processing for you (requires zref package to be installed). +=item The character encoding breaks when running latexdiff from powershell. + +This problem is not limited to C<latexdiff> and has to do with the default settings of C<powershell> in Windows. It is recommended to use C<cmd> instead. + =back =head1 BUGS @@ -4597,13 +4654,13 @@ different numbers of inter-argument spaces are treated as significant. =back -Please submit bug reports using the issue tracker of the github repository page I<https://github.com/ftilmann/latexdiff.git>, +Please submit bug reports using the issue tracker of the github repository page I<https://github.com/ftilmann/latexdiff.git>, or send them to I<tilmann -- AT -- gfz-potsdam.de>. Include the version number of I<latexdiff> (from comments at the top of the source or use B<--version>). If you come across latex files that are error-free and conform to the specifications set out above, and whose differencing still does not result in error-free latex, please send me those files, ideally edited to only contain the -offending passage as long as that still reproduces the problem. If your +offending passage as long as that still reproduces the problem. If your file relies on non-standard class files, you must include those. I will not look at examples where I have trouble to latex the original files. @@ -4614,24 +4671,24 @@ L<latexrevise>, L<latexdiff-vc> =head1 PORTABILITY I<latexdiff> does not make use of external commands and thus should run -on any platform supporting Perl 5.6 or higher. If files with encodings +on any platform supporting Perl 5.6 or higher. If files with encodings other than ASCII or UTF-8 are processed, Perl 5.8 or higher is required. The standard version of I<latexdiff> requires installation of the Perl package -C<Algorithm::Diff> (available from I<www.cpan.org> - +C<Algorithm::Diff> (available from I<www.cpan.org> - I<http://search.cpan.org/~nedkonz/Algorithm-Diff-1.15>) but a stand-alone version, I<latexdiff-so>, which has this package inlined, is available, too. I<latexdiff-fast> requires the I<diff> command to be present. =head1 AUTHOR -Version 1.3.3 -Copyright (C) 2004-2022 Frederik Tilmann +Version 1.3.4 +Copyright (C) 2004-2024 Frederik Tilmann This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License Version 3 -Contributors of fixes and additions: V. Kuhlmann, J. Paisley, N. Becker, T. Doerges, K. Huebner, +Contributors of fixes and additions: V. Kuhlmann, J. Paisley, N. Becker, T. Doerges, K. Huebner, T. Connors, Sebastian Gouezel and many others. Thanks to the many people who sent in bug reports, feature suggestions, and other feedback. @@ -4902,13 +4959,14 @@ value underline sqrt (SUPER|SUB)SCRIPT -%%END TEXT COMMANDS +%%END TEXT COMMANDS %%BEGIN CONTEXT1 COMMANDS % Regex matching commands with a text argument (leave out the \), which will fail out of context. These commands behave like text commands, except when they occur in a deleted section, where they are disabled, but their argument is shown as deleted text. caption subcaption -%%END CONTEXT1 COMMANDS +multicolumn +%%END CONTEXT1 COMMANDS %%BEGIN CONTEXT2 COMMANDS % Regex matching commands with a text argument (leave out the \), which will fail out of context. As corresponding commands for context1. The only difference is that context2 commands are completely disabled in deleted sections, including their arguments. @@ -4916,7 +4974,7 @@ title author date institute -%%END CONTEXT2 COMMANDS +%%END CONTEXT2 COMMANDS %% CONFIGURATION variabe defaults %%BEGIN LISTENV CONFIG @@ -4994,9 +5052,16 @@ verbatim[*]? \RequirePackage[normalem]{ulem} \RequirePackage{color}\definecolor{RED}{rgb}{1,0,0}\definecolor{BLUE}{rgb}{0,0,1} \providecommand{\DIFadd}[1]{{\protect\color{blue}\uwave{#1}}} -\providecommand{\DIFdel}[1]{{\protect\color{red}\sout{#1}}} +\providecommand{\DIFdel}[1]{{\protect\color{red}\sout{#1}}} %DIF END UNDERLINE PREAMBLE +%DIF LUAUNDERLINE PREAMBLE +\RequirePackage{lua-ul} +\RequirePackage{color}\definecolor{RED}{rgb}{1,0,0}\definecolor{BLUE}{rgb}{0,0,1} +\providecommand{\DIFadd}[1]{{\protect\color{blue}\underLine{#1}}} +\providecommand{\DIFdel}[1]{{\protect\color{red}\strikeThrough{#1}}} +%DIF END LUAUNDERLINE PREAMBLE + %DIF CTRADITIONAL PREAMBLE \RequirePackage{color}\definecolor{RED}{rgb}{1,0,0}\definecolor{BLUE}{rgb}{0,0,1} \RequirePackage[stable]{footmisc} @@ -5168,7 +5233,7 @@ verbatim[*]? % To show only pages with changes (dvips/dvipdf) % latex diff.tex % latex diff.tex -% dvips -pp `perl -lne 'if (m/\\newlabel{DIFchg[be]\d*}{{.*}{(.*)}}/) { print $1 }' diff.aux | uniq | tr -s \\n ','` diff.dvi +% dvips -pp `perl -lne 'if (m/\\newlabel{DIFchg[be]\d*}{{.*}{(.*)}}/) { print $1 }' diff.aux | uniq | tr -s \\n ','` diff.dvi \typeout{Check comments in preamble of output for instructions how to show only pages where changes have been made} \usepackage[user,abspage]{zref} \newcount\DIFcounterb @@ -5188,10 +5253,10 @@ verbatim[*]? \RequirePackage{etoolbox} \RequirePackage{zref} % redefine label command to write immediately to aux file - page references will be lost -\makeatletter \let\oldlabel\label% Store \label -\renewcommand{\label}[1]{% Update \label to write to the .aux immediately -\zref@wrapper@immediate{\oldlabel{#1}}} -\makeatother +\makeatletter \let\oldlabel\label% Store \label +\renewcommand{\label}[1]{% Update \label to write to the .aux immediately +\zref@wrapper@immediate{\oldlabel{#1}}} +\makeatother \newbool{DIFkeeppage} \newbool{DIFchange} \boolfalse{DIFkeeppage} @@ -5209,7 +5274,7 @@ verbatim[*]? \providecommand{\DIFmodend}{\global\booltrue{DIFkeeppage}\global\boolfalse{DIFchange}} %DIF END ONLYCHANGEDPAGE PREAMBLE -%% FLOAT TYPES +%% FLOAT TYPES %DIF FLOATSAFE PREAMBLE \providecommand{\DIFaddFL}[1]{\DIFadd{#1}} @@ -5241,7 +5306,7 @@ verbatim[*]? %DIF END TRADITIONALSAFE PREAMBLE % see: -% http://tex.stackexchange.com/questions/47351/can-i-redefine-a-command-to-contain-itself +% http://tex.stackexchange.com/questions/47351/can-i-redefine-a-command-to-contain-itself %DIF HIGHLIGHTGRAPHICS PREAMBLE \RequirePackage{settobox} @@ -5287,6 +5352,15 @@ verbatim[*]? %% SPECIAL PACKAGE PREAMBLE COMMANDS +%% Redefine strike out command to wrap in text box if amsmath is used and markup style with ulem is used +%DIF AMSMATHULEM PREAMBLE +\makeatletter +\let\sout@orig\sout +\renewcommand{\sout}[1]{\ifmmode\text{\sout@orig{\ensuremath{#1}}}\else\sout@orig{#1}\fi} +\makeatother +%DIF END AMSMATHULEM PREAMBLE + + % Standard \DIFadd and \DIFdel are redefined as \DIFaddtex and \DIFdeltex % when hyperref package is included. %DIF HYPERREF PREAMBLE @@ -5389,7 +5463,7 @@ verbatim[*]? %DIF END DIFCODE_BOLD %DIF DIFCODE_PDFCOMMENT - + moredelim=[il][\color{white}\tiny]{\%DIF\ <\ }, moredelim=[il][\sffamily\bfseries]{\%DIF\ >\ } %DIF END DIFCODE_PDFCOMMENT diff --git a/Master/texmf-dist/doc/support/latexdiff/latexdiff-fast b/Master/texmf-dist/doc/support/latexdiff/latexdiff-fast index ff9a732bacc..44d6005845f 100755 --- a/Master/texmf-dist/doc/support/latexdiff/latexdiff-fast +++ b/Master/texmf-dist/doc/support/latexdiff/latexdiff-fast @@ -25,6 +25,21 @@ # # Note references to issue numbers are for the github repository of latexdiff: https://github.com/ftilmann/latexdiff # +# Version 1.3.4: +# New features: +# - Option to use lua-ul instead of ulem (for use with LuaLaTeX) (fix #17, #60, #188, #255, #270) +# Enhancement +# - If amsmath is detected as one of the included (based on idea in PR #263 contributed by github user xlucn +# Bug fix +# - sometimes the introduction of aux commands to show deleted lists or descriptions leaves in place empty auxiliary +# list environments, which would cause error messages (though skipping messages would result in a correct output pdf). +# These are now removed. +# - add more mboxsafecmd and safecmd commands for SIunitx to stay compatible with newer versionsof SIunitx (PR #283, fixing issue #282, contributed by github user joe6302413) +# - File added via --preamble option is no longer assumed to be ASCII, but read either with encoding as defined by --encoding option or using the encoding of the LOCALE (fixes issue #285 ) +# - multicolumn argument is now treated as text +# - when tikz-dependency package is used, \& is no longer a safe command as it has special meaning inside dependency environment. The fix is a little of a hack as really it should only be considered unsafe within dependency environment (fixes (mostly) issue #303 ) +# - listings package had trouble with non-ASCII chars. The encoding is now set (thanks to github user anka-213 for finding this). Fixes #304 +# # Version 1.3.3: # New features: # - Option --no-del to remove all deleted text (merge contributed by github user tdegeus PR #252, fixing issue #66 @@ -33,22 +48,22 @@ # - Abbreviations involving punctuations within them. They need special treatment because otherwise in some # circumstances the gnoring of white space differences in conjunction with merging according to MINWORDSBLOCK rule # could turn 'i.e.' into 'i.\PAR e.' (see https://github.com/ftilmann/latexdiff/issues/269). A few abbreviations -# are now hard-coded and treated as atomic: +# are now hard-coded and treated as atomic: # English: i.e., e.g. Deutsch: z.B. # (fixes issue #269) # - In WHOLE and COARSE math modes, now properly treat math environments with arguments such as \alignat. Fixes #251 -# - For FINE math mode, multiple improvments to the processing work flow yield more robust outcomes. In particular, changes -# to the equation type, e.g. \begin{displaymath} -> \begin{equation} without modifications now usually no longer result -# in errors. (Partially) fixes issues #235 and #244. -# - When encountering deleted math array environments such as align or eqnarray, rather than replacing them with a -# fixed replacement environment (e.g. align* or eqnarray*), an asterisk is now added to the original command, which +# - For FINE math mode, multiple improvments to the processing work flow yield more robust outcomes. In particular, changes +# to the equation type, e.g. \begin{displaymath} -> \begin{equation} without modifications now usually no longer result +# in errors. (Partially) fixes issues #235 and #244. +# - When encountering deleted math array environments such as align or eqnarray, rather than replacing them with a +# fixed replacement environment (e.g. align* or eqnarray*), an asterisk is now added to the original command, which # in amsmath (and with eqnarray) will result in the same environment but without line numbers. Config variable MATHARRREPL # is therefore (nearly) redundant, and a depracation warning is given when it is set. Reference to MATHARRREPL are have # been removed from the manual (there is one exception, when it's still being used: sometimes latexdiff can figure out # that there is a deleted array environment, but does not know which one. In this case, MATHARRREPL is still being used -# to encapsulate these parts of the source, and therefore it is still set internally. But this is a quite rare situation). +# to encapsulate these parts of the source, and therefore it is still set internally. But this is a quite rare situation). # Fixes issue #216 -# - Unlike 'array' environment, 'split' (amsmath) does not work in argument of \DIFadd or \DIFdl in UNDERLINE modes; therefore remove it from ARRENV configuration variable. +# - Unlike 'array' environment, 'split' (amsmath) does not work in argument of \DIFadd or \DIFdl in UNDERLINE modes; therefore remove it from ARRENV configuration variable. # Exclude \begin and \end in math environments in COARSE and WHOLE modes. Fixes #258. Fixes #109 # - --flatten now works for empty files. Fixes issue #242 # - improved processing of Chinese and Japanese texts in that splitting is done based on characters. Thanks to LuXu (Oliver Lew) in git for working this out. Fixes #229, fixes #145 @@ -65,7 +80,7 @@ # Bug fixes: # - fix issue #206 affecting proper markup of text commands which are not also safe cmd's and have multiple arguments # - fix issue #210 by adding \eqref (amsmath package) to the list of safe commands -# - fix bug reported in issue #168 mangled verbatim line environment +# - fix bug reported in issue #168 mangled verbatim line environment # - fix bug reported in issue #218 by replacing \hspace{0pt} after \mbox{..} auxiliary commands with \hskip0pt. # - more ways to process \frac correctly with atomic arguments (committed by julianuu PR #246 # - fix a bug in biblatex mode, which prevented proper processing of modified \textcite (see: https://tex.stackexchange.com/questions/555157/latexdiff-and-biblatex-citation-commands) @@ -74,10 +89,10 @@ # Version 1.3.1.1 # - remove spurious \n to fix error: Unknown regexp modifier "/n" at .../latexdiff line 1974, near "=~ " (see github issue #201) # -# Version 1.3.1 +# Version 1.3.1 # Bug fixes: # - remove some uninitialised variable $2 warnings in string substitution in flatten function in case included file is not found -# - add minimal postprocessing to diff processing of preamble commands (replace \RIGHTBRACE by \} ) +# - add minimal postprocessing to diff processing of preamble commands (replace \RIGHTBRACE by \} ) # - pre-processing: replace (contributed) routine take_comments_and_enter_from_frac() with take_comments_and_newline_from_frac(), which does the same thing # (remove whitespace characters and comments between the argument of \frac commands) in an easier and more robust way. In addition, it # will replace commands like \frac12 with \frac{1}{2} as pre-processing step. Fixes issue #184 @@ -95,15 +110,15 @@ # Version 1.3.0 (7 October 2018): # - treat options to \documentclass as potential package names (some packages allow implicit loading of or imply selected packages # - improved pattern matching: now allows nested angular brackets, and is no longer confused by escaped curly braces -# - improved pattern matching in COARSE mode: occasionally, the closing bracket or some other elements would be matched in an 'unnatural' way due to another sequence being more minimal in the computational sense, sometimes even causing errors due to tokens moving in or out of the scope of math environments. This is now discouraged by adding internal \DIFANCHOR commands (which are removed again in post-processing) (fixes issues reported via email by li_ruomeng . +# - improved pattern matching in COARSE mode: occasionally, the closing bracket or some other elements would be matched in an 'unnatural' way due to another sequence being more minimal in the computational sense, sometimes even causing errors due to tokens moving in or out of the scope of math environments. This is now discouraged by adding internal \DIFANCHOR commands (which are removed again in post-processing) (fixes issues reported via email by li_ruomeng . # - verbatim and lstlisting environments are marked-up with line-by-line in a similar style to non-verbatim text (requires the listing package to be installed) # (see new configuration variable VERBATIMLINEENV) (several issues and pull requests by jprotze) -# - --flatten: now supports \verbatiminput and \lstlistinput +# - --flatten: now supports \verbatiminput and \lstlistinput # - --flatten: if file is not found, do not fail, simply warn and leave command unexpanded (inspired by issue #112). Don't warn if file name contains #[0-9] as it is then most likely an argument within a command definition rather than an actual file (applies to \input, \subfile, \include commands) # - added to textcmds: \intertext # - new config variable CUSTOMDIFCMD to allow defining special versions of commands in added or deleted blocks (Pull request by github user jprotze) # - added option -no-links (mostly for use by latexdiff-vc in only-changes modes) (Pull request by github user jprotze) -# - new option --filter-script to run both input through a pre-processing script (PR jasonmccsmith #167) +# - new option --filter-script to run both input through a pre-processing script (PR jasonmccsmith #167) # new option --no-filter-stderr to hide stderr output from filter-script (potentially dangerous, as this might hide malfunctioning of filter scripts) # - --flatten now can deal with imports made using the import package {PR jasonmccsmith #173) # Bug fixes: @@ -122,12 +137,12 @@ # make environments that are treated like verbatim environments configurable (config variable VERBATIMENV) # treat lstinlne as equivalent to verb command # partially addresses issue #38 -# - refactoring: set default configuration variables in a hash, and those that correspond to lists +# - refactoring: set default configuration variables in a hash, and those that correspond to lists # - feature: option --add-to-config used to amend configuration variables, which are regex pattern lists # - bug fix: deleted figures when endfloat package is activated # - bug fix: alignat environment now always processed correctly (fix issues #65) # - bug fix: avoid processing of commands as potential files in routine init_regex_arr (fix issue #70 ) -# - minimal feature enhancement: treat '@' as allowed character in commands (strictly speaking requires prior \makeatletter statement, but always assuming it to be +# - minimal feature enhancement: treat '@' as allowed character in commands (strictly speaking requires prior \makeatletter statement, but always assuming it to be # @ a letter if it is part of a command name will usually lead to the correct behaviour (see http://tex.stackexchange.com/questions/346651/latexdiff-and-let) # - new feature/bug fix: --flatten option \endinput in included files now respected but only if \endinput stands right at the beginning of the line (issue #77) # - bug fix: flatten would incorrectly attempt to process commented out \include commands (from discussion in issue #77 ) @@ -165,7 +180,7 @@ # - introduce list UNSAFEMATHCMD, which holds list of commands which cannot be marked up with \DIFadd or \DIFdel commands (only relevant for WHOLE and COARSE math markup modes) # - new subtype LABEL which gives each change a label. This can later be used to only display pages where changes # have been made (instructions for that are put as comments into the diff'ed file) inspired by answer on http://tex.stackexchange.com/questions/166049/invisible-markers-in-pdfs-using-pdflatex -# - Configuration variables take into accout some commands from additional packages: +# - Configuration variables take into accout some commands from additional packages: # tikzpicture environment now treated as PICTUREENV, and \smallmatrix in ARRENV (amsmath) # - --flatten: support for \subfile command (subfiles package) (in response to http://tex.stackexchange.com/questions/167620/latexdiff-with-subfiles ) # - --flatten: \bibliography commands expand if corresponding bbl file present @@ -179,11 +194,11 @@ # - \% in one-letter sub/Superscripts was not converted correctly # # Version 1.0.3 -# - fix bug in add_safe_commands that made latexdiff hang on DeclareMathOperator +# - fix bug in add_safe_commands that made latexdiff hang on DeclareMathOperator # command in preamble # - \(..\) inline math expressions were not parsed correctly, if they contained a linebreak # - applied patch contributed by tomflannaghan via Berlios: [ Patch #3431 ] Adds correct handling of \left< and \right> -# - \$ is treated correctly as a literal dollar sign (thanks to Reed Cartwright and Joshua Miller for reporting this bug +# - \$ is treated correctly as a literal dollar sign (thanks to Reed Cartwright and Joshua Miller for reporting this bug # and sketching out the solution) # - \^ and \_ are correctly interpreted as accent and underlined space, respectively, not as superscript of subscript # (thanks to Wail Yahyaoui for pointing out this bug) @@ -191,19 +206,19 @@ # Version 1.0.1 - treat \big,\bigg etc. equivalently to \left and # \right - include starred version in MATHENV - apply # - flatten recursively and --flatten expansion is now -# aware of comments (thanks to Tim Connors for patch) +# aware of comments (thanks to Tim Connors for patch) # - Change to post-processing for more reliability for # deleted math environments -# - On linux systems, recognise and remove DOS style newlines +# - On linux systems, recognise and remove DOS style newlines # - Provide markup for some special preamble commands (\title, -# \author,\date, -# - configurable by setting context2cmd +# \author,\date, +# - configurable by setting context2cmd # - for styles using ulem package, remove \emph and \text.. from list of # safe commands in order to allow linebreaks within the -# highlighted sections. -# - for ulem style, now show citations by enclosing them in \mbox commands. -# This unfortunately implies linebreaks within citations no longer function, -# so this functionality can be turned off (Option --disable-citation-markup). +# highlighted sections. +# - for ulem style, now show citations by enclosing them in \mbox commands. +# This unfortunately implies linebreaks within citations no longer function, +# so this functionality can be turned off (Option --disable-citation-markup). # With --enable-citation-markup, the mbox markup is forced for other styles) # - new substyle COLOR. This is particularly useful for marking up citations # and some special post-processing is implemented to retain cite @@ -211,11 +226,11 @@ # - four different levels of math-markup # - Option --driver for choosing driver for modes employing changebar package # - accept \\* as valid command (and other commands of form \.*). Also accept -# \<nl> (backslashed newline) +# \<nl> (backslashed newline) # - some typo fixes, include commands defined in preamble as safe commands -# (Sebastian Gouezel) +# (Sebastian Gouezel) # - include compared filenames as comments as line 2 and 3 of -# the preamble (can be modified with option --label, and suppressed with +# the preamble (can be modified with option --label, and suppressed with # --no-label), option --visible-label to show files in generated pdf or dvi # at the beginning of main document # @@ -231,7 +246,7 @@ # # Version 0.4 March 06 option for fast differencing using UNIX diff command, several minor bug fixes (\par bug, improved highlighting of textcmds) # -# Version 0.3 August 05 improved parsing of displayed math, --allow-spaces +# Version 0.3 August 05 improved parsing of displayed math, --allow-spaces # option, several minor bug fixes # # Version 0.25 October 04 Fix bug with deleted equations, add math mode commands to safecmd, add | to allowed interpunctuation signs @@ -808,12 +823,13 @@ use utf8 ; use File::Spec ; + my ($algodiffversion)=split(/ /,$Algorithm::Diff::VERSION); my ($versionstring)=<<EOF ; -This is LATEXDIFF 1.3.3 (Algorithm::Diff $Algorithm::Diff::VERSION, Perl $^V) - (c) 2004-2022 F J Tilmann +This is LATEXDIFF 1.3.4 (Algorithm::Diff $Algorithm::Diff::VERSION, Perl $^V) + (c) 2004-2024 F J Tilmann EOF # Hash with defaults for configuration variables. These marked undef have default values constructed from list defined in the DATA block @@ -904,9 +920,9 @@ my $DELCMDOPEN='%DIFDELCMD < '; # To mark begin of deleted commands (must begin my $DELCMDCLOSE="%%%\n"; # To mark end of deleted commands (must end with a new line) my $AUXCMD='%DIFAUXCMD' ; # follows auxiliary commands put in by latexdiff to make difference file legal # auxiliary commands must be on a line of their own - # Note that for verbatim environment openings the %DIFAUXCMD cannot be placed in + # Note that for verbatim environment openings the %DIFAUXCMD cannot be placed in # the same line as this would mean they are shown - # so the special form "%DIFAUXCMD NEXT" is used to indicate that the next line + # so the special form "%DIFAUXCMD NEXT" is used to indicate that the next line # is an auxiliary command # Similarly "%DIFAUXCMD LAST" would indicate the auxiliary command is in previous line (not currently used) my $DELCOMMENT='DIF < '; # To mark deleted comment line @@ -917,21 +933,21 @@ my @TEXTCMDLIST=(); # array containing patterns of commands with text arguments my @TEXTCMDEXCL=(); # array containing patterns of commands without text arguments (if a pattern # matches both TEXTCMDLIST and TEXTCMDEXCL it is excluded) my @CONTEXT1CMDLIST=(); # array containing patterns of commands with text arguments (subset of text commands), - # but which cause confusion if used out of context (e.g. \caption). + # but which cause confusion if used out of context (e.g. \caption). # In deleted passages, the command will be disabled but its argument is marked up - # Otherwise they behave exactly like TEXTCMD's + # Otherwise they behave exactly like TEXTCMD's my @CONTEXT1CMDEXCL=(); # exclude list for above, but always empty my @CONTEXT2CMDLIST=(); # array containing patterns of commands with text arguments, but which fail or cause confusion # if used out of context (e.g. \title). They and their arguments will be disabled in deleted # passages my @CONTEXT2CMDEXCL=(); # exclude list for above, but always empty my @MATHTEXTCMDLIST=(); # treat like textcmd. If a textcmd is in deleted or added block, just wrap the - # whole content with \DIFadd or \DIFdel irrespective of content. This functionality + # whole content with \DIFadd or \DIFdel irrespective of content. This functionality # is useful for pseudo commands \MATHBLOCK.. into which math environments are being - # transformed -my @MATHTEXTCMDEXCL=(); # + # transformed +my @MATHTEXTCMDEXCL=(); # -# Note I need to declare this with "our" instead of "my" because later in the code I have to "local"ise these +# Note I need to declare this with "our" instead of "my" because later in the code I have to "local"ise these our @SAFECMDLIST=(); # array containing patterns of safe commands (which do not break when in the argument of DIFadd or DIFDEL) our @SAFECMDEXCL=(); my @MBOXCMDLIST=(); # patterns for commands which are in principle safe but which need to be surrounded by an \mbox @@ -996,7 +1012,7 @@ $mathmarkup=COARSE; $verbose=0; $onlyadditions=0; # output debug and intermediate files, set to 0 in final distribution -$debug=0; +$debug=0; # insert preamble directly after documentclass - experimental feature, set to 0 in final distribution # Note that this failed with mini example (or other files, where packages used in latexdiff preamble # are called again with incompatible options in preamble of resulting file) @@ -1019,9 +1035,9 @@ END my %verbhash; Getopt::Long::Configure('bundling'); -GetOptions('type|t=s' => \$type, - 'subtype|s=s' => \$subtype, - 'floattype|f=s' => \$floattype, +GetOptions('type|t=s' => \$type, + 'subtype|s=s' => \$subtype, + 'floattype|f=s' => \$floattype, 'config|c=s' => \@configlist, 'add-to-config=s' => \@addtoconfiglist, 'preamble|p=s' => \$preamblefile, @@ -1070,11 +1086,11 @@ if ( $help ) { if ( $version ) { - print STDERR $versionstring ; + print STDERR $versionstring ; exit 0; } -print STDERR $versionstring if $verbose; +print STDERR $versionstring if $verbose; if (defined($showall)){ $showpreamble=$showsafe=$showtext=$showconfig=1; @@ -1092,7 +1108,7 @@ if (defined($mathmarkup)) { $mathmarkup=~tr/a-z/A-Z/; if ( $mathmarkup eq 'OFF' ){ $mathmarkup=OFF; - } elsif ( $mathmarkup eq 'WHOLE' ){ + } elsif ( $mathmarkup eq 'WHOLE' ){ $mathmarkup=WHOLE; } elsif ( $mathmarkup eq 'COARSE' ){ $mathmarkup=COARSE; @@ -1195,7 +1211,7 @@ foreach $config ( @configlist ) { } } foreach $assign ( @config ) { - $assign=~ m/\s*(\w*)\s*=\s*(\S*)\s*$/ or die "Illegal assignment $assign in configuration list (must be variable=value)"; + $assign=~ m/\s*(\w*)\s*=\s*(\S*)\s*$/ or die "Illegal assignment $assign in configuration list (must be variable=value)"; exists $CONFIG{$1} or die "Unknown configuration variable $1."; $CONFIG{$1}=$2; } @@ -1232,7 +1248,7 @@ foreach $key ( keys(%CONFIG) ) { foreach $assign ( @addtoconfig ) { ###print STDERR "assign:|$assign|\n"; - $assign=~ m/\s*(\w*)\s*=\s*(\S*)\s*$/ or die "Illegal assignment $assign in configuration list (must be variable=value)"; + $assign=~ m/\s*(\w*)\s*=\s*(\S*)\s*$/ or die "Illegal assignment $assign in configuration list (must be variable=value)"; exists $CONFIG{$1} or die "Unknown configuration variable $1."; $CONFIG{$1}.=";$2"; } @@ -1247,8 +1263,8 @@ foreach ( keys(%CONFIG) ) { elsif ( $_ eq "MATHENV" ) { $MATHENV = liststringtoregex($CONFIG{$_}) ; } elsif ( $_ eq "MATHREPL" ) { $MATHREPL = $CONFIG{$_} ; } elsif ( $_ eq "MATHARRENV" ) { $MATHARRENV = liststringtoregex($CONFIG{$_}) ; } - elsif ( $_ eq "MATHARRREPL" ) { $MATHARRREPL = $CONFIG{$_} ; - print STDERR "WARNING: Setting MATHARRREPL is depracated. Generally deleted math array environments will be set to their starred varieties and the setting of MATHARREPL is ignored.\n\n" unless $MATHARRREPL =~ /eqnarray\*/ ; + elsif ( $_ eq "MATHARRREPL" ) { $MATHARRREPL = $CONFIG{$_} ; + print STDERR "WARNING: Setting MATHARRREPL is depracated. Generally deleted math array environments will be set to their starred varieties and the setting of MATHARREPL is ignored.\n\n" unless $MATHARRREPL =~ /eqnarray\*/ ; } elsif ( $_ eq "ARRENV" ) { $ARRENV = liststringtoregex($CONFIG{$_}) ; } elsif ( $_ eq "VERBATIMENV" ) { $VERBATIMENV = liststringtoregex($CONFIG{$_}) ; } @@ -1275,11 +1291,11 @@ foreach $pkg ( @packagelist ) { if ($showconfig || $showtext || $showsafe || $showpreamble) { show_configuration(); - exit 0; + exit 0; } -if ( @ARGV != 2 ) { +if ( @ARGV != 2 ) { print STDERR "2 and only 2 non-option arguments required. Write latexdiff -h to get help\n"; exit(2); } @@ -1287,7 +1303,7 @@ if ( @ARGV != 2 ) { # Are extra spaces between command arguments permissible? my $extraspace; if ($allowspaces) { - $extraspace='\s*'; + $extraspace='\s*'; } else { $extraspace=''; } @@ -1310,14 +1326,14 @@ push(@SAFECMDLIST, qr/^QLEFTBRACE$/, qr/^QRIGHTBRACE$/); # if you get "undefined control sequence MATHBLOCKmath" error, increase the maximum value in this loop for (my $i_pat = 0; $i_pat < 20; ++$i_pat){ $pat_n = '(?:[^{}]|\{'.$pat_n.'\}|\\\\\{|\\\\\})*'; - # Actually within the text body, quoted braces are replaced in pre-processing. The only place where + # Actually within the text body, quoted braces are replaced in pre-processing. The only place where # the last part of the pattern matters is when processing the arguments of context2cmds in the preamble # and these contain a \{ or \} combination, probably rare. # It should thus be fine to use the simpler version below. ### $pat_n = '(?:[^{}]|\{'.$pat_n.'\})*'; } - my $brat0 = '(?:[^\[\]]|\\\[|\\\])*'; + my $brat0 = '(?:[^\[\]]|\\\[|\\\])*'; my $brat_n = $brat0; for (my $i_pat = 0; $i_pat < 4; ++$i_pat){ $brat_n = '(?:[^\[\]]|\['.$brat_n.'\]|\\\[|\\\])*'; @@ -1334,7 +1350,7 @@ push(@SAFECMDLIST, qr/^QLEFTBRACE$/, qr/^QRIGHTBRACE$/); # could turn 'i.e.' into 'i.\PAR e.' (see https://github.com/ftilmann/latexdiff/issues/269) # English: i.e., e.g. Deutsch: z.B. my $abbreviation='(?:i\. ?e\.|e\. ?g\.|z\. ?B\.)' ; - my $number='-?\d*\.\d*'; + my $number='-?\d*\.\d*'; # word: sequence of letters or accents followed by letter my $word_cj='\p{Han}|\p{InHiragana}|\p{InKatakana}'; @@ -1362,7 +1378,7 @@ push(@SAFECMDLIST, qr/^QLEFTBRACE$/, qr/^QRIGHTBRACE$/); # inline math $....$ or \(..\) ### the commented out version is simpler but for some reason cannot cope with newline (in spite of s option) - need to include \newline explicitly ### my $math='\$(?:[^$]|\\\$)*?\$|\\\\[(].*?\\\\[)]'; - my $math='\$(?:[^$]|\\\$)*?\$|\\\\[(](?:.|\n)*?\\\\[)]'; + my $math='\$(?:[^$]|\\\$)*?\$|\\\\[(](?:.|\n)*?\\\\[)]'; ### test version (this seems to give the same results as version above) ## the current maths command cannot cope with newline within the math expression ### my $math='\$(?:[^$]|\\\$)*?\$|\\[(].*?\\[)]'; @@ -1380,7 +1396,7 @@ push(@SAFECMDLIST, qr/^QLEFTBRACE$/, qr/^QRIGHTBRACE$/); -# now we are done setting up and can start working +# now we are done setting up and can start working my ($oldfile, $newfile) = @ARGV; # check for existence of input files if ( ! -e $oldfile ) { @@ -1408,7 +1424,7 @@ my ($oldtime,$newtime,$oldlabel,$newlabel); if (defined($labels[0])) { $oldlabel=$labels[0] ; } else { - $oldtime=localtime((stat($oldfile))[9]); + $oldtime=localtime((stat($oldfile))[9]); $oldlabel="$oldfile " . " "x($oldlabel_n_spaces) . $oldtime; } if (defined($labels[1])) { @@ -1421,6 +1437,7 @@ if (defined($labels[1])) { $encoding=guess_encoding($newfile) unless defined($encoding); $encoding = "utf8" if $encoding =~ m/^utf8/i ; +print STDERR "Encoding $encoding\n" if $verbose; if (lc($encoding) eq "utf8" ) { binmode(STDOUT, ":utf8"); binmode(STDERR, ":utf8"); @@ -1504,7 +1521,7 @@ my @auxlines; my ($ulem)=0; if ( length $oldpreamble && length $newpreamble ) { - # pre-process preamble by looking for commands used in \maketitle (title, author, date etc commands) + # pre-process preamble by looking for commands used in \maketitle (title, author, date etc commands) # and marking up content with latexdiff markup @auxlines=preprocess_preamble($oldpreamble,$newpreamble); @@ -1536,7 +1553,7 @@ if (defined($graphicsmarkup)) { } else { # Default: no explicit setting in menu if ( defined $packages{"graphicx"} or defined $packages{"graphics"} ) { - $graphicsmarkup=NEWONLY; + $graphicsmarkup=NEWONLY; } else { $graphicsmarkup=NONE; } @@ -1569,7 +1586,7 @@ if ($graphicsmarkup != NONE ) { @matches=( $latexdiffpreamble =~ m/command\{\\DIFaddbeginFL}\{($pat_n)}/sg ) ; # we look at the last one of the list to take into account possible redefinition but almost always matches should have exactly one element if ( $matches[$#matches] =~ m/\\DIFaddbegin/ ) { - die "Cannot combine graphics markup with float styles defining \\DIFaddbeginFL in terms of \\DIFaddbegin. Use --graphics-markup=none option or choose a different float style."; + die "Cannot combine graphics markup with float styles defining \\DIFaddbeginFL in terms of \\DIFaddbegin. Use --graphics-markup=none option or choose a different float style."; exit 10; } ###} @@ -1583,6 +1600,11 @@ if ($graphicsmarkup != NONE ) { $ulem = ($latexdiffpreamble =~ /\\RequirePackage(?:\[$brat_n\])?\{ulem\}/ || defined $packages{"ulem"}); +# If amsmath is defined and $ulem is used for markup, redefine the \sout command to also work (mostly) in math mode +# See stack exchange https://tex.stackexchange.com/questions/20609/strikeout-in-math-mode/308647#308647 based on comment by Taylor Raine +if ( defined($packages{'amsmath'}) and $ulem ) { + $latexdiffpreamble .= join "\n",(extrapream('AMSMATHULEM'),""); +} # If listings is being used or can be found in the latexdiff search path, add to the preamble auxiliary code to enable line-by-line markup if ( defined($packages{"listings"}) or `kpsewhich listings.sty` ne "" ) { @@ -1592,7 +1614,7 @@ if ( defined($packages{"listings"}) or `kpsewhich listings.sty` ne "" ) { } my @listingDIFcode=(); my $replaced; - # note that in case user supplies preamblefile the type might not reflect well the + # note that in case user supplies preamblefile the type might not reflect well the actual markup style @listingDIFcode=extrapream("-nofail","DIFCODE_" . $type) unless defined($preamblefile); if (!(@listingDIFcode)) { # if listingDIFcode is empty try to guess a suitable one from the preamble @@ -1606,13 +1628,17 @@ if ( defined($packages{"listings"}) or `kpsewhich listings.sty` ne "" ) { @listingDIFcode=extrapream("DIFCODE_BOLD"); } } - # now splice it in + # add configuration so that listings work with utf-8 + push @listingpreamble, '\lstset{extendedchars=\true,inputencoding='.$encoding."}\n"; + + + # now splice it in $replaced=0; ###print STDERR "DEBUG: listingDIFcode: ",join("\n",@listingDIFcode),"|||\n" if $debug; - @listingpreamble=grep { + @listingpreamble=grep { # only replace if this has not been done already (use short-circuit property of and) - if (!$replaced and $_ =~ s/^.*%DIFCODE TEMPLATE.*$/join("\n",@listingDIFcode)/e ) { + if (!$replaced and $_ =~ s/^.*%DIFCODE TEMPLATE.*$/join("\n",@listingDIFcode)/e ) { ###print STDERR "DEBUG: Replaced text $_\n" if $debug; $replaced=1; 1; @@ -1642,7 +1668,7 @@ if ( length $oldpreamble && length $newpreamble ) { unshift @oldpreamble,''; @diffpreamble = linediff(\@oldpreamble, \@newpreamble); # remove dummy line again - shift @diffpreamble; + shift @diffpreamble; # add filenames, modification time and latexdiff mark defined($nolabel) or splice @diffpreamble,1,0, "%DIF LATEXDIFF DIFFERENCE FILE", @@ -1691,8 +1717,8 @@ if (defined $packages{"siunitx"} ) { # protect SI command by surrounding them with an \mbox # this is done to get around an incompatibility between the ulem and siunitx package print STDERR "siunitx package detected.\n" if $verbose ; - my $mboxcmds='SI,ang,numlist,numrange,SIlist,SIrange'; - init_regex_arr_list(\@SAFECMDLIST,'num,si'); + my $mboxcmds='SI,ang,numlist,numrange,SIlist,SIrange,qty,qtylist,qtyproduct,qtyrange,complexqty'; + init_regex_arr_list(\@SAFECMDLIST,'num,si,numproduct,unit,complexnum'); if ( $enablecitmark || ( $ulem && ! $disablecitmark )) { init_regex_arr_list(\@MBOXCMDLIST,$mboxcmds); } else { @@ -1714,7 +1740,7 @@ if (defined $packages{"cleveref"} ) { if (defined $packages{"glossaries"} ) { # protect selected command by surrounding them with an \mbox - # this is done to get around an incompatibility between ulem and glossaries package + # this is done to get around an incompatibility between ulem and glossaries package print STDERR "glossaries package detected.\n" if $verbose ; my $mboxcmds='[gG][lL][sS](?:|pl|disp|link|first|firstplural|desc|user[iv][iv]?[iv]?),[aA][cC][rR](?:long|longpl|full|fullpl),[aA][cC][lfp]?[lfp]?'; init_regex_arr_list(\@SAFECMDLIST,'[gG][lL][sS](?:(?:entry)?(?:text|plural|name|symbol)|displaynumberlist|entryfirst|entryfirstplural|entrydesc|entrydescplural|entrysymbolplural|entryuser[iv][iv]?[iv]?|entrynumberlist|entrydisplaynumberlist|entrylong|entrylongpl|entryshort|entryshortpl|entryfull|entryfullpl),[gG]lossentry(?:name|desc|symbol),[aA][cC][rR](?:short|shortpl),[aA]csp?'); @@ -1743,6 +1769,10 @@ if (defined $packages{"mhchem"} ) { # push(@MATHTEXTCMDLIST,'cee'); } +if ( defined $packages{"tikz-dependency"} ) { + init_regex_arr_ext(\@SAFECMDEXCL, 'AMPERSAND'); +} + my ( $citpat); @@ -1830,7 +1860,7 @@ print STDERR "(",exetime()," s)\n","Done.\n" if $verbose; # liststringtoregex(liststring) -# expands string with semi-colon separated list into a regular expression corresponding +# expands string with semi-colon separated list into a regular expression corresponding # matching any of the elements sub liststringtoregex { my ($liststring)=@_; @@ -1843,7 +1873,7 @@ sub liststringtoregex { } # show_configuration -# note that this is not encapsulated but uses variables from the main program +# note that this is not encapsulated but uses variables from the main program # It is provided for convenience because in the future it is planned to allow output # to be modified based on what packages are read etc - this works only if the input files are actually read # whether or not additional files are provided @@ -1870,7 +1900,7 @@ sub show_configuration { print "\nContext1 commands (last argument textual, command will be disabled in deleted passages, last argument will be shown as plain text):\n"; print_regex_arr(@CONTEXT1CMDLIST); print "\nContext2 commands (last argument textual, command and its argument will be disabled in deleted passages):\n"; - print_regex_arr(@CONTEXT2CMDLIST); + print_regex_arr(@CONTEXT2CMDLIST); print "\nExclude list of Commands with last argument not textual (overrides patterns above):\n"; print_regex_arr(@TEXTCMDEXCL); } @@ -1978,7 +2008,7 @@ sub list_packages { my %packages=(); my $pkg; - # remove comments + # remove comments $preamble=~s/(?<!\\)%.*$//mg ; while ( $preamble =~ m/\\(?:documentclass|usepackage|RequirePackage)(?:\[($brat_n)\])?\{(.*?)\}/gs ) { @@ -2083,7 +2113,7 @@ sub flatten { my ($includeonly,$dirname,$fname,$newpage,$fullfile,$filecontent,$replacement,$begline,$inputcmd,$bblfile,$subfile,$command,$verbenv,$verboptions,$ignore,$fileonly); my ($subpreamble,$subbody,$subpost); my ($subdir,$subdirfull,$importfilepath); - require File::Basename ; + require File::Basename ; ### require File::Spec ; # now this is needed even if flatten option not given $filename = File::Spec->rel2abs( $filename ) ; ($ignore, $dirname, $fileonly) = File::Spec->splitpath($filename) ; @@ -2123,15 +2153,15 @@ sub flatten { $subdirfull = (defined($3) ? File::Spec->catdir($dirname,$subdir) : $subdir); $importfilepath = File::Spec->catfile($subdirfull, $fname); - + print STDERR "importing importfilepath:", $importfilepath,"\n" if $verbose; if ( -f $importfilepath ) { # If file exists, replace input or include command with expanded input #TODO: need remove_endinput & newpage similar to other replacements inside flatten - $replacement=flatten(read_file_with_encoding($importfilepath, $encoding), $preamble,$importfilepath,$encoding); + $replacement=flatten(read_file_with_encoding($importfilepath, $encoding), $preamble,$importfilepath,$encoding); } else { # if file does not exist, do not expand include or input command (do not warn if fname contains #[0-9] as it is then likely part of a command definition - # and is not meant to be expanded directly + # and is not meant to be expanded directly print STDERR "WARNING: Could not find included file ",$importfilepath,". I will continue but not expand |$2|\n"; $replacement = $2; $replacement .= "{$subdir}{$fname} % Processed"; @@ -2140,13 +2170,13 @@ sub flatten { }/exgm; # recursively replace \\input and \\include files - $text =~ s/(^(?:[^%\n]|\\%)*)(\\input\{(.*?)\}|\\include\{(${includeonly}(?:\.tex)?)\})/{ + $text =~ s/(^(?:[^%\n]|\\%)*)(\\input\{(.*?)\}|\\include\{(${includeonly}(?:\.tex)?)\})/{ $begline=(defined($1)? $1 : "") ; $inputcmd=$2; $fname = $3 if defined($3) ; $fname = $4 if defined($4) ; $newpage=(defined($4)? " \\newpage " : "") ; - # # add tex extension unless there is a three or four letter extension already + # # add tex extension unless there is a three or four letter extension already $fname .= ".tex" unless $fname =~ m|\.\w{3,4}$|; $fullfile = File::Spec->catfile($dirname,$fname); print STDERR "DEBUG Beg of line match |$1|\n" if defined($1) && $debug ; @@ -2155,12 +2185,12 @@ sub flatten { # content of file becomes replacement value (use recursion), add \newpage if the command was include if ( -f $fullfile ) { # If file exists, replace input or include command with expanded input - $replacement=flatten(read_file_with_encoding($fullfile, $encoding), $preamble,$filename,$encoding); - $replacement = remove_endinput($replacement); + $replacement=flatten(read_file_with_encoding($fullfile, $encoding), $preamble,$filename,$encoding); + $replacement = remove_endinput($replacement); # \include always starts a new page; use explicit \newpage command to simulate this } else { # if file does not exist, do not expand include or input command (do not warn if fname contains #[0-9] as it is then likely part of a command definition - # and is not meant to be expanded directly + # and is not meant to be expanded directly print STDERR "WARNING: Could not find included file ",$fullfile,". I will continue but not expand |$inputcmd|\n" unless $fname =~ m(#[0-9]) ; $replacement = $inputcmd ; # i.e. just the original command again -> make no change file does not exist $newpage=""; @@ -2169,7 +2199,7 @@ sub flatten { }/exgm; # replace bibliography with bbl file if it exists - $text=~s/(^(?:[^%\n]|\\%)*)\\bibliography\{(.*?)\}/{ + $text=~s/(^(?:[^%\n]|\\%)*)\\bibliography\{(.*?)\}/{ if ( -f $bblfile ){ $replacement=read_file_with_encoding(File::Spec->catfile($bblfile), $encoding); } else { @@ -2181,10 +2211,10 @@ sub flatten { }/exgm; # replace subfile with contents (subfile package) - $text=~s/(^(?:[^%\n]|\\%)*)\\subfile\{(.*?)\}/{ + $text=~s/(^(?:[^%\n]|\\%)*)\\subfile\{(.*?)\}/{ $begline=(defined($1)? $1 : "") ; - $fname = $2; - # # add tex extension unless there is a three or four letter extension already + $fname = $2; + # # add tex extension unless there is a three or four letter extension already $fname .= ".tex" unless $fname =~ m|\.\w{3,4}|; print STDERR "Include file as subfile $fname\n" if $verbose; # content of file becomes replacement value (use recursion) @@ -2195,10 +2225,10 @@ sub flatten { # if file exists, expand \subfile command by contents of file $subfile=read_file_with_encoding($fullfile,$encoding) or die "Could not open included subfile ",$fullfile,": $!"; ($subpreamble,$subbody,$subpost)=splitdoc($subfile,'\\\\begin\{document\}','\\\\end\{document\}'); - ### $subfile=~s|^.*\\begin{document}||s; + ### $subfile=~s|^.*\\begin{document}||s; ### $subfile=~s|\\end{document}.*$||s; $replacement=flatten($subbody, $preamble,$fullfile,$encoding); - ### $replacement = remove_endinput($replacement); + ### $replacement = remove_endinput($replacement); } else { # if file does not exist, do not expand subfile print STDERR "WARNING: Could not find subfile ",$fullfile,". I will continue but not expand |$2|\n" unless $fname =~ m(#[0-9]) ; @@ -2209,11 +2239,11 @@ sub flatten { }/exgm; # replace \verbatiminput and \lstlistinginput - $text=~s/(^(?:[^%\n]|\\%)*)\\(verbatiminput\*?|lstinputlisting)$extraspace(\[$brat_n\])?$extraspace\{(.*?)\}/{ + $text=~s/(^(?:[^%\n]|\\%)*)\\(verbatiminput\*?|lstinputlisting)$extraspace(\[$brat_n\])?$extraspace\{(.*?)\}/{ $begline=(defined($1)? $1 : "") ; $command = $2 ; $fname = $4 ; - $verboptions = defined($3)? $3 : "" ; + $verboptions = defined($3)? $3 : "" ; if ($command eq 'verbatiminput' ) { $verbenv = "verbatim" ; } elsif ($command eq 'verbatiminput*' ) { @@ -2222,7 +2252,7 @@ sub flatten { $verbenv = "lstlisting" ; } else { die "Internal errorL Unexpected verbatim input type $command.\n"; - } + } print STDERR "DEBUG Beg of line match |$begline|\n" if $debug ; print STDERR "Include file $fname verbatim\n" if $verbose; print STDERR "DEBUG looking for file ",File::Spec->catfile($dirname,$fname), "\n" if $debug; @@ -2254,8 +2284,8 @@ sub print_regex_arr { # if $type is a filename, it will read the file instead of reading from the appendix # otherwise it will screen appendix for line "%DIF $TYPE" and copy everything up to line # '%DIF END $TYPE' (where $TYPE is upcased version of $type) -# extrapream('-nofail',$type) will---instead of failing---simply return nothing if -# it does not find the matching line in a appendix (do not use -nofail option with multiple types!) +# extrapream('-nofail',$type) will---instead of failing---simply return nothing if +# it does not find the matching line in appendix (do not use -nofail option with multiple types!) sub extrapream { my @types=@_; my ($type,$arg); @@ -2272,14 +2302,20 @@ sub extrapream { $type=$arg; $copy=0; if ( -f $type || lc $type eq '/dev/null' ) { - open (FILE,$type) or die "Cannot open preamble file $type: $!"; print STDERR "Reading preamble file $type\n" if $verbose ; + open (FILE,$type) or die "Cannot open preamble file $type: $!"; + if (defined($encoding)) { + binmode(FILE,":encoding($encoding)"); + } else { + require Encode::Locale; + binmode(FILE,":encoding(locale)"); + } while (<FILE>) { chomp ; if ( $_ =~ m/%DIF PREAMBLE/ ) { - push (@retval,"$_"); + push (@retval,"$_"); } else { - push (@retval,"$_ %DIF PREAMBLE"); + push (@retval,"$_ %DIF PREAMBLE"); } } } else { # not (-f $type) @@ -2291,9 +2327,9 @@ sub extrapream { my $data_start = tell DATA; while (<DATA>) { if ( m/^%DIF $type/ ) { - $copy=1; + $copy=1; } elsif ( m/^%DIF END $type/ ) { - last; + last; } chomp; push (@retval,"$_ %DIF PREAMBLE") if $copy; @@ -2333,7 +2369,7 @@ sub splitdoc { $pos=pos $rest; $part2=substr($rest,0,$pos-length($2)); $part3=substr($rest,$pos); - } + } else { die "$word1 and $word2 not in the correct order or not present as a pair." ; } @@ -2405,7 +2441,7 @@ sub splitlatex { my $leadin=$1; length($string)>0 or return ($leadin); - my @retval=($string =~ m/$pat/osg); + my @retval=($string =~ m/$pat/osg); if (length($string) != length(join("",@retval))) { print STDERR "\nWARNING: Inconsistency in length of input string and parsed string:\n This often indicates faulty or non-standard latex code.\n In many cases you can ignore this and the following warning messages.\n Note that character numbers in the following are counted beginning after \\begin{document} and are only approximate." unless $ignorewarnings; @@ -2449,17 +2485,17 @@ sub splitlatex { # pass1( \@seq1,\@seq2) # Look for differences between seq1 and seq2. -# Where an common-subsequence block is flanked by deleted or appended blocks, +# Where an common-subsequence block is flanked by deleted or appended blocks, # and is shorter than $MINWORDSBLOCK words it is appended -# to the last deleted or appended word. If the block contains tokens other than words +# to the last deleted or appended word. If the block contains tokens other than words # or punctuation it is not merged. # Deleted or appended block consisting of words and safe commands only are # also merged, to prevent break-up in pass2 (after previous isolated words have been removed) -# If there are commands with textual arguments (e.g. \caption) both in corresponding -# appended and deleted blocks split them such that the command and opening bracket -# are one token, then the rest is split up following standard rules, and the closing +# If there are commands with textual arguments (e.g. \caption) both in corresponding +# appended and deleted blocks split them such that the command and opening bracket +# are one token, then the rest is split up following standard rules, and the closing # bracket is a separate token, ie. turn -# "\caption{This is a textual argument}" into +# "\caption{This is a textual argument}" into # ("\caption{","This ","is ","a ","textual ","argument","}") # No return value. Destructively changes sequences sub pass1 { @@ -2488,15 +2524,15 @@ sub pass1 { my $adddiscard = sub { if ($cnt > 0 ) { $matblkcnt++; - # just after an unchanged block + # just after an unchanged block # print STDERR "Unchanged block $cnt, $last1,$last2 \n"; - if ($cnt < $MINWORDSBLOCK + if ($cnt < $MINWORDSBLOCK && $cnt==scalar ( - grep { /^$wpat/ || ( /^\\((?:[`'^"~=.]|[\w\d@*]+))((?:\[$brat_n\]|\{$pat_n\})*)/o - && iscmd($1,\@SAFECMDLIST,\@SAFECMDEXCL) + grep { /^$wpat/ || ( /^\\((?:[`'^"~=.]|[\w\d@*]+))((?:\[$brat_n\]|\{$pat_n\})*)/o + && iscmd($1,\@SAFECMDLIST,\@SAFECMDEXCL) && scalar(@dummy=split(" ",$2))<3 ) } @$block) ) { - # merge identical blocks shorter than $MINWORDSBLOCK + # merge identical blocks shorter than $MINWORDSBLOCK # and only containing ordinary words # with preceding different word # We cannot carry out this merging immediately as this @@ -2504,23 +2540,23 @@ sub pass1 { # the algorithm, instead we store in @$todo where we have to merge push(@$todo, [ $last1,$last2,$cnt,@$block ]); } - $block = []; + $block = []; $cnt=0; $last1=-1; $last2=-1; } }; my $discard=sub { $deltokcnt++; &$adddiscard; #($_[0],$_[1]); push(@$delblock,[ $seq1->[$_[0]],$_[0] ]); - $last1=$_[0] }; + $last1=$_[0] }; my $add = sub { $addtokcnt++; &$adddiscard; #($_[0],$_[1]); push(@$addblock,[ $seq2->[$_[1]],$_[1] ]); - $last2=$_[1] }; + $last2=$_[1] }; my $match = sub { $mattokcnt++; if ($cnt==0) { # first word of matching sequence after changed sequence or at beginning of word sequence - $deltextblocks = extracttextblocks($delblock); + $deltextblocks = extracttextblocks($delblock); $delblkcnt++ if scalar @$delblock; $addtextblocks = extracttextblocks($addblock); $addblkcnt++ if scalar @$addblock; @@ -2536,7 +2572,7 @@ sub pass1 { ### Algorithm::Diff 1.19 $matchindex=Algorithm::Diff::_longestCommonSubsequence($delcmds,$addcmds, 0, sub { $_[0]->[0] } ); } else { - ### Algorithm::Diff 1.15 + ### Algorithm::Diff 1.15 $matchindex=Algorithm::Diff::_longestCommonSubsequence($delcmds,$addcmds, sub { $_[0]->[0] } ); } @@ -2567,11 +2603,11 @@ sub pass1 { my ($index,$block,$cnt)=@{ shift(@$addtextblocks) }; push(@$todo, [-1,$index,$cnt,@$block]); } - + $addblock=[]; $delblock=[]; } - push(@$block,$seq2->[$_[1]]); + push(@$block,$seq2->[$_[1]]); $cnt++ }; my $keyfunc = sub { join(" ",split(" ",shift())) }; @@ -2579,7 +2615,7 @@ sub pass1 { traverse_sequences($seq1,$seq2, { MATCH=>$match, DISCARD_A=>$discard, DISCARD_B=>$add }, $keyfunc ); - # now carry out the merging/splitting. Refer to elements relative from + # now carry out the merging/splitting. Refer to elements relative from # the end (with negative indices) as these offsets don't change before the instruction is executed # cnt>0: merged small unchanged groups with previous changed blocks # cnt==-1: split textual commands into components @@ -2594,7 +2630,7 @@ sub pass1 { } } - if ($verbose) { + if ($verbose) { print STDERR "\n"; print STDERR " $mattokcnt matching tokens in $matblkcnt blocks.\n"; print STDERR " $deltokcnt discarded tokens in $delblkcnt blocks.\n"; @@ -2604,10 +2640,10 @@ sub pass1 { # extracttextblocks(\@blockindex) -# $blockindex has the following format -# [ [ token1, index1 ], [token2, index2],.. ] -# where index refers to the index in the original old or new word sequence -# Returns: reference to an array of the form +# $blockindex has the following format +# [ [ token1, index1 ], [token2, index2],.. ] +# where index refers to the index in the original old or new word sequence +# Returns: reference to an array of the form # [[ $index, $textblock, $cnt ], .. # where $index index of block to be merged # $textblock contains all the words to be merged with the word at $index (but does not contain this word) @@ -2615,7 +2651,7 @@ sub pass1 { # # requires: iscmd # -sub extracttextblocks { +sub extracttextblocks { my $block=shift; my ($i,$token,$index); my $textblock=[]; @@ -2625,13 +2661,13 @@ sub extracttextblocks { # we redefine locally $extraspace (shadowing the global definition) to capture command sequences with intervening spaces no matter what the global setting # this is done so we can capture those commands with a predefined number of arguments without having to introduce them again explicitly here - my $extraspace='\s*'; + my $extraspace='\s*'; for ($i=0;$i< scalar @$block;$i++) { ($token,$index)=@{ $block->[$i] }; # store pure text blocks - if ($token =~ /$wpat/ || ( $token =~/^\\((?:[`'^"~=.]|[\w\d@\*]+))((?:${extraspace}\[$brat_n\]${extraspace}|${extraspace}\{$pat_n\})*)/ - && iscmd($1,\@SAFECMDLIST,\@SAFECMDEXCL) + if ($token =~ /$wpat/ || ( $token =~/^\\((?:[`'^"~=.]|[\w\d@\*]+))((?:${extraspace}\[$brat_n\]${extraspace}|${extraspace}\{$pat_n\})*)/ + && iscmd($1,\@SAFECMDLIST,\@SAFECMDEXCL) && !iscmd($1,\@TEXTCMDLIST,\@TEXTCMDEXCL))) { # we have text or a command which can be treated as text if ($last<0) { @@ -2639,7 +2675,7 @@ sub extracttextblocks { $last=$index; } else { # add to pure-text block - push(@$textblock, $token); + push(@$textblock, $token); } } else { # it is not text @@ -2660,29 +2696,29 @@ sub extracttextblocks { # extractcommands( \@blockindex ) -# $blockindex has the following format -# [ [ token1, index1 ], [token2, index2],.. ] -# where index refers to the index in the original old or new word sequence -# Returns: reference to an array of the form -# [ [ "\cmd1", index, "\cmd1[optarg]{arg1}{", "arg2" ,"} " ],.. -# where index is just taken from input array -# command must have a textual argument as last argument -# -# requires: iscmd -# -sub extractcommands { +# $blockindex has the following format +# [ [ token1, index1 ], [token2, index2],.. ] +# where index refers to the index in the original old or new word sequence +# Returns: reference to an array of the form +# [ [ "\cmd1", index, "\cmd1[optarg]{arg1}{", "arg2" ,"} " ],.. +# where index is just taken from input array +# command must have a textual argument as last argument +# +# requires: iscmd +# +sub extractcommands { my $block=shift; my ($i,$token,$index,$cmd,$open,$mid,$closing); my $retval=[]; # we redefine locally $extraspace (shadowing the global definition) to capture command sequences with intervening spaces no matter what the global setting # this is done so we can capture those commands with a predefined number of arguments without having to introduce them again explicitly here - my $extraspace='\s*'; + my $extraspace='\s*'; for ($i=0;$i< scalar @$block;$i++) { ($token,$index)=@{ $block->[$i] }; # check if token is an alphanumeric command sequence with at least one non-optional argument - # \cmd[...]{...}{last argument} + # \cmd[...]{...}{last argument} # Capturing in the following results in these associations # $1: \cmd[...]{...}{ # $2: \cmd @@ -2690,7 +2726,7 @@ sub extractcommands { # $4: } + trailing spaces if ( ( $token =~ m/^(\\([\w\d\*]+)(?:${extraspace}\[$brat_n\]|${extraspace}\{$pat_n\})*${extraspace}\{)($pat_n)(\}\s*)$/so ) && iscmd($2,\@TEXTCMDLIST,\@TEXTCMDEXCL) ) { - print STDERR "DEBUG EXTRACTCOMMANDS Match |$1|$2|$3|$4|$index \n" if $debug; + print STDERR "DEBUG EXTRACTCOMMANDS Match |$1|$2|$3|$4|$index \n" if $debug; # push(@$retval,[ $2,$index,$1,$3,$4 ]); ($cmd,$open,$mid,$closing) = ($2,$1,$3,$4) ; $closing =~ s/\}/\\RIGHTBRACE/ ; @@ -2701,7 +2737,7 @@ sub extractcommands { } # iscmd($cmd,\@regexarray,\@regexexcl) checks -# return 1 if $cmd matches any of the patterns in the +# return 1 if $cmd matches any of the patterns in the # array $@regexarray, and none of the patterns in \@regexexcl, otherwise return 0 sub iscmd { my ($cmd,$regexar,$regexexcl)=@_; @@ -2709,7 +2745,7 @@ sub iscmd { ### print STDERR "DEBUG: iscmd($cmd)=" if $debug; foreach $pat ( @$regexar ) { if ( $cmd =~ m/^${pat}$/ ) { - $ret=1 ; + $ret=1 ; last; } } @@ -2725,13 +2761,13 @@ sub iscmd { # pass2( \@seq1,\@seq2) -# Look for differences between seq1 and seq2. +# Look for differences between seq1 and seq2. # Mark begin and end of deleted and appended sequences with tags $DELOPEN and $DELCLOSE # and $ADDOPEN and $ADDCLOSE, respectively, however exclude { } & and all comands, unless # they match an element of the whitelist (SAFECMD) # For words in TEXTCMD but not in SAFECMD, enclose interior with $ADDOPEN and $ADDCLOSE brackets -# Deleted comment lines are marked with %DIF < -# Added comment lines are marked with %DIF > +# Deleted comment lines are marked with %DIF < +# Added comment lines are marked with %DIF > sub pass2 { my $seq1 = shift ; my $seq2 = shift ; @@ -2763,7 +2799,7 @@ sub pass2 { $addhunk = []; } push(@$retval,$seq2->[$_[1]]) }; - + my $keyfunc = sub { join(" ",split(" ",shift())) }; traverse_sequences($seq1,$seq2, { MATCH=>$match, DISCARD_A=>$discard, DISCARD_B=>$add }, $keyfunc ); @@ -2772,7 +2808,7 @@ sub pass2 { push @$retval,marktags($ADDMARKOPEN,$ADDMARKCLOSE,$ADDOPEN,$ADDCLOSE,"","",$ADDCOMMENT,$addhunk) if scalar @$addhunk; - if ($verbose) { + if ($verbose) { print STDERR "\n"; print STDERR " $mattokcnt matching tokens. \n"; print STDERR " $deltokcnt discarded tokens in $delblkcnt blocks.\n"; @@ -2794,7 +2830,7 @@ sub marktags { my (@argtext); my $retval=[]; my $noncomment=0; - my $cmd=-1; # -1 at beginning 0: last token written is a ordinary word + my $cmd=-1; # -1 at beginning 0: last token written is a ordinary word # 1: last token written is a command # for keeping track whether we are just in a command sequence or in a word sequence my $cmdcomment= ($opencmd =~ m/^%/); # Flag to indicate whether opencmd is a comment (i.e. if we intend to simply comment out changed commands) @@ -2810,31 +2846,31 @@ sub marktags { # we redefine locally $extraspace (shadowing the global definition) to capture command sequences with intervening spaces no matter what the global setting # this is done so we can capture those commands with a predefined number of arguments without having to introduce them again explicitly here - my $extraspace_mt='\s*'; + my $extraspace_mt='\s*'; foreach (@$block) { - $word=$_; + $word=$_; if ( $word =~ s/^%/%$comment/ ) { # a comment if ($cmd==1) { push (@$retval,$closecmd) ; $cmd=-1; } - push (@$retval,$word); + push (@$retval,$word); next; } if ( $word =~ m/^\s*$/ ) { ### print STDERR "DEBUG MARKTAGS: whitespace detected |$word| cmdcom |$cmdcomment| |$opencmd|\n" if $debug; # a sequence of white-space characters - this should only ever happen for the first element of block. - # in deleted block, omit, otherwise just copy it in + # in deleted block, omit, otherwise just copy it in if ( ! $cmdcomment) { # ignore in deleted blocks push(@$retval,$word); } next; } if (! $noncomment) { - push (@$retval,$openmark); + push (@$retval,$openmark); $noncomment=1; } # negative lookahead pattern (?!) in second clause is put in to avoid matching \( .. \) patterns @@ -2844,7 +2880,7 @@ sub marktags { # word is a command or other significant token (not in SAFECMDLIST) ## same conditions as in subroutine extractcommand: # check if token is an alphanumeric command sequence with at least one non-optional argument - # \cmd[...]{...}{last argument} + # \cmd[...]{...}{last argument} # Capturing in the following results in these associations # $1: \cmd[...]{...}{ # $2: cmd @@ -2861,11 +2897,11 @@ sub marktags { # Condition 3: But if we are in a deleted block ($cmdcomment=1) and # $2 (the command) is in context2, just treat it as an ordinary command (i.e. comment it open with $opencmd) # Because we do not want to disable this command - # here we do not use $opencmd and $closecmd($opencmd is empty) + # here we do not use $opencmd and $closecmd($opencmd is empty) print STDERR "DEBUG: Detected text |$word| but not safe command \$2: $2 \$3: $3\n." if $debug; if ($cmd==1) { push (@$retval,$closecmd) ; - } elsif ($cmd==0) { + } elsif ($cmd==0) { push (@$retval,$close) ; } $command=$1; $commandword=$2; $closingbracket=$4; @@ -2881,16 +2917,16 @@ sub marktags { # for latexrevise push (@$retval,$command,"%\n{$AUXCMD\n",marktags("","",$open,$close,$opencmd,$closecmd,$comment,\@argtext),$closingbracket); } elsif ( iscmd($commandword,,\@MATHTEXTCMDLIST, \@MATHTEXTCMDEXCL) ) { - # MATHBLOCK pseudo command: consider all commands safe, except & and \\, \begin and \end and a few package sprcific one (look at UNSAFEMATHCMD definition) - # Keep these commands even in deleted blocks, hence set $opencmd and $closecmd (5th and 6th argument of marktags) to + # MATHBLOCK pseudo command: consider all commands safe, except & and \\, \begin and \end and a few package sprcific one (look at UNSAFEMATHCMD definition) + # Keep these commands even in deleted blocks, hence set $opencmd and $closecmd (5th and 6th argument of marktags) to # "" - local @SAFECMDLIST=(".*"); + local @SAFECMDLIST=(".*"); local @SAFECMDEXCL=('\\','\\\\',@UNSAFEMATHCMD); push(@$retval,$command,marktags("","",$open,$close,"","",$comment,\@argtext)#@argtext ,$closingbracket); } else { # normal textcmd or context1cmd in an added block - push (@$retval,$command,marktags("","",$open,$close,$opencmd,$closecmd,$comment,\@argtext),$closingbracket); + push (@$retval,$command,marktags("","",$open,$close,$opencmd,$closecmd,$comment,\@argtext),$closingbracket); } push (@$retval,$AUXCMD,"\n") if $cmdcomment ; $cmd=-1 ; @@ -2976,10 +3012,10 @@ sub take_comments_and_newline_from_frac() { # names or labels but it does not matter because they are converted back in the postprocessing step # Returns: leading white space removed in step 1 sub preprocess { - for (@_) { + for (@_) { - # change in \verb and similar commands - note that I introduce an extra space here so that the + # change in \verb and similar commands - note that I introduce an extra space here so that the # already hashed variants do not trigger again # transform \lstinline{...} # s/\\lstinline(\[$brat0\])?(\{(?:.*?)\})/"\\DIFlstinline". $1 ."{". tohash(\%verbhash,"$2") ."}"/esg; @@ -3009,7 +3045,7 @@ sub preprocess { 1 while s/(?<!\\)_(\s*{($pat_n)})/\\SUBSCRIPT$1/g ; # Convert ^n into \SUPERSCRIPTNB{n} and ^{nnn} into \SUPERSCRIPT{nn} 1 while s/(?<!\\)\^(\s*([^{\\\s]|\\\w+))/\\SUPERSCRIPTNB{$1}/g ; - 1 while s/(?<!\\)\^(\s*{($pat_n)})/\\SUPERSCRIPT$1/g ; + 1 while s/(?<!\\)\^(\s*{($pat_n)})/\\SUPERSCRIPT$1/g ; # Convert \sqrt{n} into \SQRT{n} and \sqrt nn into SQRTNB{nn} 1 while s/(?<!\\)\\sqrt(\s*([^{\\\s]|\\\w+))/\\SQRTNB{$1}/g ; 1 while s/(?<!\\)\\sqrt(\s*{($pat_n)})/\\SQRT$1/g ; @@ -3029,16 +3065,16 @@ sub preprocess { if ( $mathmarkup != FINE ) { # DIFANCHORARRB and DIFANCHORARRE, DIFANCHORMATHB and DIFANCHORMATHE markers are inserted here to encourage the matching algorithm # to always match up the closing brace. Otherwise sometimes one ends up with a situation where - # the closing brace is deleted and added at another point. The deleted closing brace is then + # the closing brace is deleted and added at another point. The deleted closing brace is then # prevented by a %DIFDELCMD, leading to material leaking in or out of the math environment. # The anchors are removed in post-processing again. (note that they are simple text to cause least amount of complications - # Admittedly, this is something of a hack and will not always work. If it does not, then one needs to + # Admittedly, this is something of a hack and will not always work. If it does not, then one needs to # resort to WHOLE or FINE, or NONE math mode processing. s/\\begin\{($ARRENV)}(.*?)\\end\{\1}/\\ARRAYBLOCK$1\{$2\\DIFANCHORARRB \}\\DIFANCHORARRE /sg; take_comments_and_newline_from_frac(); - # Convert Math environments with arguments + # Convert Math environments with arguments s/\\begin\{($MATHENV|$MATHARRENV|SQUAREBRACKET)\}((?:\[$brat_n\])|(?:\{$pat_n\}))+(.*?)\\end\{\1\}/\\MATHBLOCK$1\[$2\]\{$3\\DIFANCHORMATHB \}\\DIFANCHORMATHE /sg; # Convert Math environments without arguments s/\\begin\{($MATHENV|$MATHARRENV|SQUAREBRACKET)\}(.*?)\\end\{\1\}/\\MATHBLOCK$1\{$2\\DIFANCHORMATHB \}\\DIFANCHORMATHE /sg; @@ -3052,7 +3088,7 @@ sub preprocess { # $expanded=linecomment($string) #preface all lines with verbatim marker (usually DIFVRB) -sub linecomment { +sub linecomment { my @verbatimlines=split("\n",$_[0]); # the first line needs special treatment - we do want to retain optional arguments as is but wrap the remainder also with VERBCOMMENT ### print STDERR "DEBUG: before verbatimlines[0] = ",$verbatimlines[0],"\n"; @@ -3062,7 +3098,7 @@ sub linecomment { } # $simple=reverselinecomment($env $string) -# remove DIFVRB comments but leave changed lines marked +# remove DIFVRB comments but leave changed lines marked sub reverselinecomment { my ($environment, $verbatimtext)=@_; ### print STDERR "DEBUG REVERSELINECOMMENT input: $environment,|$verbatimtext|\n" if $debug; @@ -3077,7 +3113,7 @@ sub reverselinecomment { $verbatimtext =~ s/\\DIFdelend //g; $verbatimtext =~ s/$DELCMDOPEN.*//g; - # remove DIFVRB mark + # remove DIFVRB mark $verbatimtext=~ s/%$VERBCOMMENT//g; # remove part of the markup in changed lines @@ -3168,7 +3204,7 @@ sub writedebugfile { # * Remove STOP token from the end # * Replace \RIGHTBRACE by } # * If option --no-del is set delete all deleted blocks -# 1. Check all deleted blocks: +# 1. Check all deleted blocks: # a.where a deleted block contains a matching \begin and # \end environment (these will be disabled by a %DIFDELCMD statements), for selected environments enable # these commands again (such that for example displayed math in a deleted equation @@ -3189,14 +3225,14 @@ sub writedebugfile { # For added blocks: # c. If in-line math mode contains array environment, enclose the whole environment in \mbox'es # d. place \cite commands in mbox'es (for UNDERLINE style) -# +# # 2. If math-mode COARSE,WHOLE or NONE option set: Convert \MATHBLOCKmath{..} commands back to environments # # Convert all PICTUREblock{..} commands back to the appropriate environments # 3. Convert DIFadd, DIFdel, DIFaddbegin , ... into FL varieties # within floats (currently recognised float environments: plate,table,figure # plus starred varieties). -# 4. Remove empty %DIFDELCMD < lines +# 4. Remove empty %DIFDELCMD < lines # 4. Convert \begin{SQUAREBRACKET} \end{SQUAREBRACKET} into \[ \] # Convert \begin{DOLLARDOLLAR} \end{DOLLARDOLLAR} into $$ $$ # 5. Convert \SUPERSCRIPTNB{n} into ^n and \SUPERSCRIPT{nn} into ^{nnn} @@ -3209,7 +3245,7 @@ sub writedebugfile { # 4, undo renaming of the \begin, \end,{,} in comments # Change \QLEFTBRACE, \QRIGHTBRACE,\AMPERSAND to \{,\},\& # -# Note have to manually synchronize substitution commands below and +# Note have to manually synchronize substitution commands below and # DIF.. command names in the header sub postprocess { my ($begin,$len,$float,$delblock,$addblock); ### $cnt @@ -3221,7 +3257,7 @@ sub postprocess { my (@itemargs, $itemarg); - for (@_) { + for (@_) { # change $'s in comments to something harmless 1 while s/(%.*)\$/$1DOLLARDIF/mg ; @@ -3231,7 +3267,7 @@ sub postprocess { # the only way to get these is as %DIFDELCMD < \RIGHTBRACE construction # This essentially marks closing right braces of MATHBLOCK environments, which did not get matched # up. This case should be rare, so I just leave this in the diff file output. Not really elegant - # but can still be dealt with later if it results in problems. + # but can still be dealt with later if it results in problems. s/%DIFDELCMD < \\RIGHTBRACE/%DIFDELCMD < \\MBLOCKRIGHTBRACE/g ; # Replace \RIGHTBRACE by } s/\\RIGHTBRACE/}/g; @@ -3259,7 +3295,7 @@ sub postprocess { $len=length($&); $begin=pos($_) - $len; $delblock=$&; - ### A much simpler method for math replacement might follow this strategy (can recycle part of the commands below for following + ### A much simpler method for math replacement might follow this strategy (can recycle part of the commands below for following ### this strategy: ### 1. a Insert aux commands \begin{MATHMODE} or \end{MATHMODE} for all deleted commands opening or closing displayed math mode ### b Insert aux commands \begin{MATHARRMODE} or \end{MATHARRMODE} for all deleted commands opening or closing math array mode @@ -3285,14 +3321,14 @@ sub postprocess { ###0.5: $delblock=~ s/(?<!${AUXCMD}\n)(\%DIFDELCMD < \s*\\end\{((?:$MATHENV)|SQUAREBRACKET)\}\s*?(?:$DELCMDCLOSE|\n))(.*?[^\n]?)\n?(?<!${AUXCMD}\n)(\%DIFDELCMD < \s*\\begin\{\2\})/\\end{MATHMODE}$AUXCMD\n$1$3\n\\begin{MATHMODE}$AUXCMD\n$4/sg; $delblock=~ s/(?<!${AUXCMD}\n)(\%DIFDELCMD < \h*\\end\{((?:$MATHENV)|SQUAREBRACKET)\}.*?(?:$DELCMDCLOSE|\n))(.*?[^\n]?)\n?(?<!${AUXCMD}\n)(\%DIFDELCMD < \h*\\begin\{\2\})/\\end\{MATHMODE\}$AUXCMD\n$1$3\n\\begin\{MATHMODE\}$AUXCMD\n$4/sg; - # now look for unpaired %DIFDELCMD < \begin{MATHENV}; if found add \begin{$MATHREPL} and insert \end{$MATHREPL} + # now look for unpaired %DIFDELCMD < \begin{MATHENV}; if found add \begin{$MATHREPL} and insert \end{$MATHREPL} # just before end of block; again we use look-behind assertion to avoid matching constructions which have already been converted if ($delblock=~ s/(?<!${AUXCMD}\n)(\%DIFDELCMD < \h*\\begin\{((?:$MATHENV)|SQUAREBRACKET)\}\s*?(?:$DELCMDCLOSE|\n))/$1\\begin{$MATHREPL}$AUXCMD\n/sg ) { ### print STDERR "BINGO: begin block: \nBefore: |" . substr($_,$begin,$len) . "|\n" if $debug ; $delblock =~ s/(\\DIFdelend$)/\\end{$MATHREPL}$AUXCMD\n$1/s ; ### print STDERR "After: |" . $delblock . "|\n\n" if $debug ; } - # now look for unpaired %DIFDELCMD < \end{MATHENV}; if found add \end{MATHMODE} and insert \begin{MATHMODE} + # now look for unpaired %DIFDELCMD < \end{MATHENV}; if found add \end{MATHMODE} and insert \begin{MATHMODE} # just before end of block; again we use look-behind assertion to avoid matching constructions which have already been converted if ($delblock=~ s/(?<!${AUXCMD}\n)(\%DIFDELCMD < \h*\\end\{((?:$MATHENV)|SQUAREBRACKET)\}\s*?(?:$DELCMDCLOSE|\n))/$1\\end\{MATHMODE\}$AUXCMD\n/sg ) { ### print STDERR "BINGO: end block:\nBefore: |" . substr($_,$begin,$len) . "|\n" if $debug; @@ -3315,15 +3351,15 @@ sub postprocess { $delblock=~ s/(?<!${AUXCMD}\n)(\%DIFDELCMD < \h*\\end\{($MATHARRENV)\}\s*?(?:$DELCMDCLOSE|\n))(.*?[^\n]?)\n?(?<!${AUXCMD}\n)(\%DIFDELCMD < \h*\\begin\{\2\})/\\end{MATHMODE}$AUXCMD\n$1$3\n\\begin{MATHMODE}$AUXCMD\n$4/sg; ### print STDERR "STEP1: |" . $delblock . "|\n\n" if $debug ; - # now look for unpaired %DIFDELCMD < \begin{MATHARRENV}; if found add \begin{$MATHARRREPL} and insert \end{$MATHARRREPL} + # now look for unpaired %DIFDELCMD < \begin{MATHARRENV}; if found add \begin{$MATHARRREPL} and insert \end{$MATHARRREPL} # just before end of block; again we use look-behind assertion to avoid matching constructions which have already been converted if ($delblock=~ s/(?<!${AUXCMD}\n)(\%DIFDELCMD < \h*\\begin\{($MATHARRENV)\}(.*?)(?:$DELCMDCLOSE|\n))/$1\\begin{$2*}$3$AUXCMD\n/sg ) { $arrenv=$2; - $delblock =~ s/(\\DIFdelend$)/\\end{$arrenv*}}$AUXCMD\n$1/s ; + $delblock =~ s/(\\DIFdelend$)/\\end{$arrenv*}$AUXCMD\n$1/s ; } ### print STDERR "STEP2: |" . $delblock . "|\n\n" if $debug ; - # now look for unpaired %DIFDELCMD < \end{MATHENV}; if found add \end{MATHMODE} and insert \begin{MATHMODE} + # now look for unpaired %DIFDELCMD < \end{MATHENV}; if found add \end{MATHMODE} and insert \begin{MATHMODE} # just before end of block; again we use look-behind assertion to avoid matching constructions which have already been converted if ($delblock=~ s/(?<!${AUXCMD}\n)(\%DIFDELCMD < \h*\\end\{($MATHARRENV)\}\s*?(?:$DELCMDCLOSE|\n))/$1\\end{MATHMODE}$AUXCMD\n/sg ) { $delblock =~ s/(\\DIFdelend$)/\\begin{MATHMODE}$AUXCMD\n$1/s ; @@ -3341,7 +3377,7 @@ sub postprocess { ### $eqarrayblock=~ s/(\%DIFDELCMD < \s*(\&|\\\\)\s*?(?:$DELCMDCLOSE|\n))/$1$2$AUXCMD\n/sg ; $eqarrayblock =~ s/(\%DIFDELCMD < (.*?(?:\&|\\\\).*)(?:$DELCMDCLOSE|\n))/ # The pattern captures comments with at least one of & or \\ - @symbols= split(m@((?:&|\\\\)\s*)@,$2); # extract & and \\ and other material from sequence + @symbols= split(m@((?:&|\\\\)\s*)@,$2); # extract & and \\ and other material from sequence @symbols= grep ( m@&|\\\\\s*@, @symbols); # select & and \\ (and subsequent spaces) "$1@symbols$AUXCMD\n" /eg ; @@ -3354,7 +3390,7 @@ sub postprocess { } elsif ( $mathmarkup == COARSE || $mathmarkup == WHOLE ) { # Convert MATHBLOCKmath commands to their uncounted numbers (e.g. convert equation -> displaymath # (environments defined in $MATHENV will be replaced by $MATHREPL, and environments in $MATHARRENV - # will be replaced by their starred variety + # will be replaced by their starred variety $delblock=~ s/\\MATHBLOCK($MATHENV)((?:\[$brat_n\])?)\{($pat_n)\}/\\MATHBLOCK$MATHREPL$2\{$3\}/sg; $delblock=~ s/\\MATHBLOCK($MATHARRENV)((?:\[$brat_n\])?)\{($pat_n)\}/\\MATHBLOCK$1\*$2\{$3\}/sg; } @@ -3368,10 +3404,10 @@ sub postprocess { print STDERR "DELBLOCK after maths processing: |" . $delblock . "|\n\n" if $debug ; - # Reinstate completely deleted list environments. note that items within the + # Reinstate completely deleted list environments. note that items within the # environment will still be commented out. They will be restored later $delblock=~ s/(\%DIFDELCMD < \s*\\begin\{($LISTENV)\}\s*?(?:\n|$DELCMDCLOSE))(.*?)(\%DIFDELCMD < \s*\\end\{\2\})/{ - ### # block within the search; replacement environment + ### # block within the search; replacement environment ### "$1\\begin{$2}$AUXCMD\n". restore_item_commands($3). "\n\\end{$2}$AUXCMD\n$4"; "$1\\begin{$2}$AUXCMD\n$3\n\\end{$2}$AUXCMD\n$4"; }/esg; @@ -3405,7 +3441,7 @@ sub postprocess { ### if ($CITE2CMD) { ###### ${extraspace}(?:\[$brat0\]${extraspace}){0,2}\{$pat_n\})) .*?%%%\n ### $delblock=~s/($DELCMDOPEN\s*\\($CITE2CMD)(.*)$DELCMDCLOSE)/ - ### # Replacement code + ### # Replacement code ### {my ($aux,$all); ### $aux=$all=$1; ### $aux=~s#\n?($DELCMDOPEN|$DELCMDCLOSE)##g; @@ -3415,7 +3451,7 @@ sub postprocess { ### if ($CITECMD) { ###### $delblock=~s/(\\($CITECMD)${extraspace}(?:\[$brat0\]${extraspace}){0,2}\{$pat_n\})(\s*)/\\mbox{$AUXCMD\n$1\n}$AUXCMD\n/msg ; ### $delblock=~s/(\\($CITECMD)${extraspace}(?:<$abrat0>${extraspace})?(?:\[$brat0\]${extraspace}){0,2}\{$pat_n\})(\s*)/\\mbox{$AUXCMD\n$1\n}$AUXCMD\n/msg ; - ### } + ### } # if MBOXINLINEMATH is set, protect inlined math environments with an extra mbox @@ -3423,7 +3459,7 @@ sub postprocess { # note additional \newline after command is omitted from output if right at the end of deleted block (otherwise a spurious empty line is generated) $delblock=~s/($math)(?:[\s\n]*)?/\\mbox{$AUXCMD\n$1\n}$AUXCMD\n/sg; } - ###if ( defined($packages{"listings"} and $latexdiffpreamble =~ /\\RequirePackage(?:\[$brat_n\])?\{color\}/)) { + ###if ( defined($packages{"listings"} and $latexdiffpreamble =~ /\\RequirePackage(?:\[$brat_n\])?\{color\}/)) { ### # change included verbatim environments ### $delblock =~ s/\\DIFverb\{/\\DIFDIFdelverb\{/g; ### $delblock =~ s/\\DIFlstinline/\\DIFDIFdellstinline/g; @@ -3465,7 +3501,7 @@ sub postprocess { ##$addblock=~s/($math)/\\mbox{$AUXCMD\n$1\n}$AUXCMD\n/sg; $addblock=~s/($math)(?:[\s\n]*)?/\\mbox{$AUXCMD\n$1\n}$AUXCMD\n/sg; } - ###if ( defined($packages{"listings"} and $latexdiffpreamble =~ /\\RequirePackage(?:\[$brat0\])?\{color\}/)) { + ###if ( defined($packages{"listings"} and $latexdiffpreamble =~ /\\RequirePackage(?:\[$brat0\])?\{color\}/)) { # mark added verbatim commands $addblock =~ s/\\DIFverb/\\DIFDIFaddverb/g; $addblock =~ s/\\DIFlstinline/\\DIFDIFaddlstinline/g; @@ -3483,11 +3519,11 @@ sub postprocess { pos = $begin + length($addblock); } - # Go through whole text, and by counting list environment commands, find out when we are within a list environment. + # Go through whole text, and by counting list environment commands, find out when we are within a list environment. # Within those restore deleted \item commands - @textparts=split /(?<!$DELCMDOPEN)(\\(?:begin|end)\{$LISTENV\})/ ; + @textparts=split /(?<!$DELCMDOPEN)(\\(?:begin|end)\{$LISTENV\})/ ; @liststack=(); - @newtextparts=map { + @newtextparts=map { ### print STDERR ":::::::: $_\n"; if ( ($listtype) = m/^\\begin\{($LISTENV)\}$/ ) { print STDERR "DEBUG: postprocess \\begin{$listtype}\n" if $debug; @@ -3503,7 +3539,7 @@ sub postprocess { } else { print STDERR "DEBUG: postprocess \@liststack=(",join(",",@liststack),")\n" if $debug; if (scalar @liststack > 0 ) { - # we are within a list environment and should replace all item commands + # we are within a list environment and should replace all item commands $_=restore_item_commands($_); } # else: we are outside a list environment and do not need to do anything @@ -3516,17 +3552,17 @@ sub postprocess { # Replace MATHMODE environments from step 1a above by the correct Math environment and remove unncessary pairings - + if ( $mathmarkup == FINE ) { # look for AUXCMD math-mode pairs which have only comments (or empty lines between them), and remove the added commands # \begin{..} ... \end{..} pairs - s/\\begin\{((?:$MATHENV)|(?:$MATHARRENV)|SQUAREBRACKET|MATHMODE)\}$AUXCMD\n((?:\s*%.[^\n]*\n)*)\\end\{\1\}$AUXCMD\n/$2/sg; + s/\\begin\{((?:$MATHENV)|(?:$MATHARRENV)|SQUAREBRACKET|MATHMODE)\}$AUXCMD\n((?:\s*%.[^\n]*\n)*)\\end\{\1\}$AUXCMD\n/$2/sg; # \end{..} .... \begin{..} pairs - s/\\end\{((?:$MATHENV)|(?:$MATHARRENV)|SQUAREBRACKET|MATHMODE)\}$AUXCMD\n((?:\s*%.[^\n]*\n)*)\\begin\{\1\}$AUXCMD\n/$2/sg; + s/\\end\{((?:$MATHENV)|(?:$MATHARRENV)|SQUAREBRACKET|MATHMODE)\}$AUXCMD\n((?:\s*%.[^\n]*\n)*)\\begin\{\1\}$AUXCMD\n/$2/sg; writedebugfile($_,'postprocess15'); # The next line is complicated. The negative look-ahead insertion makes sure that no \end{$MATHENV} (or other mathematical - # environments) are between the \begin{$MATHENV} and \end{MATHMODE} commands. This is necessary as the minimal matching + # environments) are between the \begin{$MATHENV} and \end{MATHMODE} commands. This is necessary as the minimal matching # is not globally minimal but only 'locally' (matching is beginning from the left side of the string) # [NB: Do not be tempted to prettify the expression with /x modified. It seems this is applied after strings are expanded so will ignore spaces in strings 1 while s/(?<!$DELCMDOPEN)\\begin\{((?:$MATHENV)|(?:$MATHARRENV)|SQUAREBRACKET)}((?:${DELCMDOPEN}[^\n]*|.(?!(?:\\end\{(?:(?:$MATHENV)|(?:$MATHARRENV)|SQUAREBRACKET)}|\\begin\{MATHMODE})))*?)\\end\{MATHMODE}/\\begin{$1}$2\\end{$1}/s; @@ -3601,7 +3637,7 @@ sub postprocess { # remove empty DIFCMD < lines s/^\Q${DELCMDOPEN}\E\n//msg; - # Expand hashes of verb and verbatim environments + # Expand hashes of verb and verbatim environments s/${DELCMDOPEN}\\($VERBATIMENV)\{([-\d]*?)\}/"${DELCMDOPEN}\\begin{${1}}".fromhash(\%verbhash,$2,$DELCMDOPEN)."${DELCMDOPEN}\\end{${1}}"/esg; # revert changes to verbatim environments for line diffs (and add code to mark up changes) (note negative look behind assertions to not leak out of DIFDELCMD comments) # Example: @@ -3627,8 +3663,8 @@ sub postprocess { ((?:\%\Q$DELCOMMENT$VERBCOMMENT\E[^\n]*?\n)*) # Deleted \end command of verbatim environment. Note that the type is forced to match the opening. Captures: $5: Whole deleted environment (previous way this line was written: (\Q$DELCMDOPEN\E\\end\{\2\}(?:\n|\s|\Q$DELCMDOPEN\E)*\Q$DELCMDCLOSE\E) (\Q$DELCMDOPEN\E\\end\{\2\}) - / # Substitution part - $1 # Leave expression as is + / # Substitution part + $1 # Leave expression as is . "$AUXCMD NEXT\n" # Mark the following line as an auxiliary command . "" # reinstate the original environment without options . reverselinecomment($2, "$3$4") # modify the body to change the markup; reverselinecomment parses for options @@ -3637,7 +3673,7 @@ sub postprocess { /esgx; # Modifiers of substitution command writedebugfile($_,'postprocess2'); # where changes have occurred in verbatim environment, change verbatim to DIFverbatim to allow mark-up - # (I use the presence of optional paramater to verbatim environment as the marker - normal verbatim + # (I use the presence of optional paramater to verbatim environment as the marker - normal verbatim # environment does not take optional arguments) s/(?<!$DELCMDOPEN)\\begin\{(verbatim[*]?)\}(\[$brat_n\].*?)\\end\{\1\}/\\begin{DIF$1}$2\\end{DIF$1}/sg; @@ -3651,7 +3687,7 @@ sub postprocess { # convert remaining PAR commands (which are preceded by non-white space characters, usually "}" ($ADDCLOSE) s/\\PAR\n/\n\n/sg; - # package specific processing: + # package specific processing: if ( defined($packages{"endfloat"})) { #endfloat: make sure \begin{figure} and \end{figure} are always # on a line by themselves, similarly for table environment @@ -3664,12 +3700,16 @@ sub postprocess { s/^((?:[^%]+)\\(?:begin|end)\{(?:figure|table)\}(?:\[[a-zA-Z]+\])?)(.+)((?:%.*)?)$/$1\n$2$3/mg; } - # Convert '\PERCENTAGE ' back into '\%' (the final question mark catches a special situation where due to a latter pre-processing step the ' ' becomes separated + # Remove empty auxiliary LISTENV (sometmes these are generated if list environment occurs within the argument of a deleted comment) + # (slightly hacky but I could not see an easy way to see if in argument of another command when this extra markup is added) + s/\\begin\{($LISTENV)\}$AUXCMD\n((?:\s*\%[^\n]*\n)*\n?)\\end\{\1\}$AUXCMD\n/$2\n/msg ; + + # Convert '\PERCENTAGE ' back into '\%' (the final question mark catches a special situation where due to a latter pre-processing step the ' ' becomes separated s/\\PERCENTAGE ?/\\%/g; - # Convert '\DOLLAR ' back into '\$' + # Convert '\DOLLAR ' back into '\$' s/\\DOLLAR /\\\$/g; - # undo renaming of the \begin and \end,{,} and dollars in comments + # undo renaming of the \begin and \end,{,} and dollars in comments # although we only renamed $ in comments to DOLLARDIFF, we might have lost the % in unchanged verbatim blocks, so rename all s/DOLLARDIF/\$/g; @@ -3687,7 +3727,7 @@ sub postprocess { # Convert \SQRT{n} into \sqrt{n} and \SQRTNB{nn} into \sqrt nn 1 while s/\\SQRT(\s*\{($pat_n)\})/\\sqrt$1/g ; 1 while s/\\SQRTNB\{(\s*$pat0)\}/\\sqrt$1/g ; - + 1 while s/(%.*)\\CFRAC (.*)$/$1\\frac$2/mg ; 1 while s/(%.*)\\CRIGHTBRACE (.*)$/$1\}$2/mg ; 1 while s/(%.*)\\CLEFTBRACE (.*)$/$1\{$2/mg ; @@ -3698,7 +3738,7 @@ sub postprocess { s/\\QRIGHTBRACE /\\\}/sg; s/\\AMPERSAND /\\&/sg; # Highlight added inline verbatim commands if possible - if ( $latexdiffpreamble =~ /\\RequirePackage(?:\[$brat_n\])?\{color\}/ ) { + if ( $latexdiffpreamble =~ /\\RequirePackage(?:\[$brat_n\])?\{color\}/ ) { # wrap added verb commands with color commands s/\\DIFDIFadd((?:verb\*?|lstinline(?:\[$brat_n\])?)\{[-\d]*?\}[\s\n]*)/\{\\color{blue}$AUXCMD\n\\DIF$1%\n\}$AUXCMD\n/sg; s/\\DIFDIFdel((?:verb\*?|lstinline(?:\[$brat_n\])?)\{[-\d]*?\}[\s\n]*$AUXCMD)/\{\\color{red}${AUXCMD}\n\\DIF$1\n\}${AUXCMD}/sg; @@ -3713,8 +3753,8 @@ sub postprocess { # finally add the comment to the ones not having an optional argument before ###s/\\DIFaddlstinline(?!\[)/\\lstinline\n[basicstyle=\\color{blue}]$AUXCMD\n/g; - return; } + return; } # $out = restore_item_commands($listenviron) @@ -3738,13 +3778,13 @@ sub restore_item_commands { # @auxlines=preprocess_preamble($oldpreamble,$newpreamble); - # pre-process preamble by looking for commands used in \maketitle (title, author, date etc commands) - # the list of commands is defined in CONTEXT2CMD - # if found then use a bodydiff to mark up content, and replace the corresponding commands + # pre-process preamble by looking for commands used in \maketitle (title, author, date etc commands) + # the list of commands is defined in CONTEXT2CMD + # if found then use a bodydiff to mark up content, and replace the corresponding commands # in both preambles by marked up version to 'fool' the linediff (such that only body is marked up). # A special case are e.g. author commands being added (or removed) # 1. If commands are added, then the entire content is marked up as new, but also the lines are marked as new in the linediff - # 2. If commands are removed, then the linediff will mark the line as deleted. The program returns + # 2. If commands are removed, then the linediff will mark the line as deleted. The program returns # with $auxlines a text to be appended at the end of the preamble, which shows the respective fields as deleted sub preprocess_preamble { my ($oldpreambleref,$newpreambleref)=(\$_[0],\$_[1]) ; @@ -3766,7 +3806,7 @@ EOF $titlecmd = "(?:".join("|",@CONTEXT2CMDLIST).")"; # as context2cmdlist is stored as regex, e.g. ((?-xism:^title$), we need to remove ^- fo # resue in a more complex regex - $titlecmd =~ s/[\$\^]//g; + $titlecmd =~ s/[\$\^]//g; # make sure to not match on comment lines: $titlecmdpat=qr/^(?:[^%\n]|\\%)*(\\($titlecmd)$extraspace(?:\[($brat_n)\])?(?:\{($pat_n)\}))/ms; ###print STDERR "DEBUG:",$titlecmdpat,"\n"; @@ -3792,7 +3832,7 @@ EOF $cmd=shift @newtitlecommands; $optarg=shift @newtitlecommands; $arg=shift @newtitlecommands; - + if ( defined($newhash{$cmd})) { warn "$cmd is used twice in preamble of new file. Reverting to pure line diff mode for preamble.\n"; print STDERR $warnmsgdetail; @@ -3819,7 +3859,7 @@ EOF } $argnew=$newhash{$cmd}->[2]; $argdiff="{" . join("",bodydiff($argold,$argnew)) ."}"; - # Replace \RIGHTBRACE by } + # Replace \RIGHTBRACE by } $argdiff =~ s/\\RIGHTBRACE/}/g; if ( length $optargnew ) { @@ -3834,7 +3874,7 @@ EOF $optargdiff=""; } ### print STDERR "DEBUG s/\\Q$newhash{$cmd}->[0]\\E/\\$cmd$optargdiff$argdiff/s\n"; - # Note: \Q and \E force literal interpretation of what it between them but allow + # Note: \Q and \E force literal interpretation of what it between them but allow # variable interpolation, such that e.g. \title matches just that and not TAB-itle $$newpreambleref=~s/\Q$newhash{$cmd}->[0]\E/\\$cmd$optargdiff$argdiff/s; # replace this in old preamble if necessary @@ -3874,7 +3914,7 @@ EOF #%< old deleted line(s) #%DIF ------- #%DIF mmann-nn -#new appended line %< +#new appended line %< #%DIF ------- # Future extension: mark change explicitly # Assumes: traverse_sequence traverses deletions before insertions in changed sequences @@ -3886,9 +3926,9 @@ sub linediff { my $block = []; my $retseq = []; my @begin=('','',''); # dummy initialisation - my $instring ; + my $instring ; - my $discard = sub { @begin=('d',$_[0],$_[1]) unless scalar @$block ; + my $discard = sub { @begin=('d',$_[0],$_[1]) unless scalar @$block ; push(@$block, "%DIF < " . $seq1->[$_[0]]) }; my $add = sub { if (! scalar @$block) { @begin=('a',$_[0],$_[1]) ;} @@ -3903,12 +3943,12 @@ sub linediff { $instring = sprintf "%%DIF %da%d-%d",$begin[1],$begin[2],$_[1]-1; } elsif ( $begin[0] eq 'c' ) { $instring = sprintf "%%DIF %sc%s", - ($begin[1]==$_[0]-1) ? "$begin[1]" : $begin[1]."-".($_[0]-1) , + ($begin[1]==$_[0]-1) ? "$begin[1]" : $begin[1]."-".($_[0]-1) , ($begin[2]==$_[1]-1) ? "$begin[2]" : $begin[2]."-".($_[1]-1) ; } else { $instring = sprintf "%%DIF %d%s%d",$begin[1],$begin[0],$begin[2]; } - push @$retseq, $instring,@$block, "%DIF -------" ; - $block = []; + push @$retseq, $instring,@$block, "%DIF -------" ; + $block = []; } push @$retseq, $seq2->[$_[1]] }; @@ -3916,7 +3956,7 @@ sub linediff { my $keyfunc = sub { join(" ",split(" ",shift())) }; traverse_sequences($seq1,$seq2, { MATCH=>$match, DISCARD_A=>$discard, DISCARD_B=>$add }, $keyfunc ); - push @$retseq, @$block if scalar @$block; + push @$retseq, @$block if scalar @$block; return wantarray ? @$retseq : $retseq ; } @@ -3926,23 +3966,23 @@ sub linediff { # init_regex_arr_data(\@array,"TOKEN INIT") # scans DATA file handel for line "%% TOKEN INIT" line # then appends each line not beginning with % into array (as a quoted regex) -# This is used for command lists and configuration variables, but the processing is slightly -# different: +# This is used for command lists and configuration variables, but the processing is slightly +# different: # For lists, the regular expression is extended to include beginning (^) and end ($) markers, to require full-string matching # For configuration variables (and all others), simply an unadorned list is copied sub init_regex_arr_data { my ($arr,$token)=@_; my $copy=0; my ($mode); - if ($token =~ m/COMMANDS/ ) { - $mode=0; # Reading command list + if ($token =~ m/COMMANDS/ ) { + $mode=0; # Reading command list } else { $mode=1; # Reading configuration variables } while (<DATA>) { if ( m/^%%BEGIN $token\s*$/ ) { - $copy=1; + $copy=1; next; } elsif ( m/^%%END $token\s*$/ ) { last; } @@ -4023,17 +4063,18 @@ sub exetime { sub usage { - print STDERR <<"EOF"; + print STDERR <<"EOF"; Usage: $0 [options] old.tex new.tex > diff.tex -Compares two latex files and writes tex code to stdout, which has the same format as new.tex but +Compares two latex files and writes tex code to stdout, which has the same format as new.tex but has all changes relative to old.tex marked up or commented. Note that old.tex and new.tex need to -be real files (not pipes or similar) as they are opened twice. +be real files (not pipes or similar) as they are opened twice. --type=markupstyle -t markupstyle Add code to preamble for selected markup style - Available styles: UNDERLINE CTRADITIONAL TRADITIONAL CFONT FONTSTRIKE INVISIBLE + Available styles: UNDERLINE CTRADITIONAL TRADITIONAL CFONT FONTSTRIKE INVISIBLE CHANGEBAR CCHANGEBAR CULINECHBAR CFONTCHBAR BOLD PDFCOMMENT + LUAUNDERLINE [ Default: UNDERLINE ] --subtype=markstyle @@ -4044,7 +4085,7 @@ be real files (not pipes or similar) as they are opened twice. * LABEL subtype is deprecated --floattype=markstyle --f markstyle Add code to preamble for selected style which +-f markstyle Add code to preamble for selected style which replace standard marking and markup commands within floats (e.g., marginal remarks cause an error within floats so marginal marking can be disabled thus) @@ -4053,11 +4094,11 @@ be real files (not pipes or similar) as they are opened twice. --encoding=enc -e enc Specify encoding of old.tex and new.tex. Typical encodings are - ascii, utf8, latin1, latin9. A list of available encodings can be - obtained by executing + ascii, utf8, latin1, latin9. A list of available encodings can be + obtained by executing perl -MEncode -e 'print join ("\\n",Encode->encodings( ":all" )) ;' [Default encoding is utf8 unless the first few lines of the preamble contain - an invocation "\\usepackage[..]{inputenc} in which case the + an invocation "\\usepackage[..]{inputenc} in which case the encoding chosen by this command is asssumed. Note that ASCII (standard latex) is a subset of utf8] @@ -4074,22 +4115,22 @@ be real files (not pipes or similar) as they are opened twice. --exclude-safecmd=exclude-file --exclude-safecmd="cmd1,cmd2,..." --A exclude-file +-A exclude-file --replace-safecmd=replace-file --append-safecmd=append-file --append-safecmd="cmd1,cmd2,..." -a append-file Exclude from, replace or append to the list of regex - matching commands which are safe to use within the + matching commands which are safe to use within the scope of a \\DIFadd or \\DIFdel command. The file must contain one Perl-RegEx per line (Comment lines beginning with # or % are ignored). A literal comma within the comma-separated list must be - escaped thus "\\,", Note that the RegEx needs to match the whole of + escaped thus "\\,", Note that the RegEx needs to match the whole of the token, i.e., /^regex\$/ is implied and that the initial "\\" of the command is not included. The --exclude-safecmd - and --append-safecmd options can be combined with the --replace-safecmd + and --append-safecmd options can be combined with the --replace-safecmd option and can be used repeatedly to add cumulatively to the lists. ---exclude-textcmd=exclude-file +--exclude-textcmd=exclude-file --exclude-textcmd="cmd1,cmd2,..." -X exclude-file --replace-textcmd=replace-file @@ -4105,7 +4146,7 @@ be real files (not pipes or similar) as they are opened twice. Replace or append to the list of regex matching commands whose last argument is text but which require a particular context to work, e.g. \\caption will only work within a figure - or table. These commands behave like text commands, except when + or table. These commands behave like text commands, except when they occur in a deleted section, when they are disabled, but their argument is shown as deleted text. @@ -4115,7 +4156,7 @@ be real files (not pipes or similar) as they are opened twice. As corresponding commands for context1. The only difference is that context2 commands are completely disabled in deleted sections, including their arguments. - context2 commands are also the only commands in the preamble, whose argument will + context2 commands are also the only commands in the preamble, whose argument will be processed in word-by-word mode (which only works, if they occur no more than once in the preamble). @@ -4124,15 +4165,15 @@ be real files (not pipes or similar) as they are opened twice. --append-mboxsafecmd=append-file --append-mboxsafecmd="cmd1,cmd2,..." Define safe commands, which additionally need to be protected by encapsulating - in an \\mbox{..}. This is sometimes needed to get around incompatibilities + in an \\mbox{..}. This is sometimes needed to get around incompatibilities between external packages and the ulem package, which is used for highlighting in the default style UNDERLINE as well as CULINECHBAR CFONTSTRIKE - + --config var1=val1,var2=val2,... -c var1=val1,.. Set configuration variables. --c configfile Available variables: +-c configfile Available variables: ARRENV (RegEx) COUNTERCMD (RegEx) FLOATENV (RegEx) @@ -4151,15 +4192,15 @@ be real files (not pipes or similar) as they are opened twice. --add-to-config varenv1=pattern1,varenv2=pattern2 For configuration variables containing a regular expression (essentially those ending - in ENV, and COUNTERCMD) this provides an alternative way to modify the configuration + in ENV, and COUNTERCMD) this provides an alternative way to modify the configuration variables. Instead of setting the complete pattern, with this option it is possible to add an alternative pattern. varenv must be one of the variables listed above that take a regular - expression as argument, and pattern is any regular expression (which might need to be + expression as argument, and pattern is any regular expression (which might need to be protected from the shell by quotation). Several patterns can be added at once by using semi-colons to separate them, e.g. --add-to-config "LISTENV=myitemize;myenumerate,COUNTERCMD=endnote" --packages=pkg1,pkg2,.. - Tell latexdiff that .tex file is processed with the packages in list + Tell latexdiff that .tex file is processed with the packages in list loaded. This is normally not necessary if the .tex file includes the preamble, as the preamble is automatically scanned for \\usepackage commands. Use of the --packages option disables automatic scanning, so if for any @@ -4180,57 +4221,57 @@ be real files (not pipes or similar) as they are opened twice. --show-all Show all of the above - NB For all --show commands, no old.tex or new.tex file needs to be given, and no + NB For all --show commands, no old.tex or new.tex file needs to be given, and no differencing takes place. Other configuration options: --allow-spaces Allow spaces between bracketed or braced arguments to commands - [Default requires arguments to directly follow each other without + [Default requires arguments to directly follow each other without intervening spaces] --math-markup=level Determine granularity of markup in displayed math environments: Possible values for level are (both numerical and text labels are acceptable): - off or 0: suppress markup for math environments. Deleted equations will not - appear in diff file. This mode can be used if all the other modes + off or 0: suppress markup for math environments. Deleted equations will not + appear in diff file. This mode can be used if all the other modes cause invalid latex code. whole or 1: Differencing on the level of whole equations. Even trivial changes - to equations cause the whole equation to be marked changed. This - mode can be used if processing in coarse or fine mode results in + to equations cause the whole equation to be marked changed. This + mode can be used if processing in coarse or fine mode results in invalid latex code. coarse or 2: Detect changes within equations marked up with a coarse - granularity; changes in equation type (e.g.displaymath to equation) + granularity; changes in equation type (e.g.displaymath to equation) appear as a change to the complete equation. This mode is recommended for situations where the content and order of some equations are still being changed. [Default] fine or 3: Detect small change in equations and mark up and fine granularity. This mode is most suitable, if only minor changes to equations are - expected, e.g. correction of typos. + expected, e.g. correction of typos. --graphics-markup=level Change highlight style for graphics embedded with \\includegraphics commands Possible values for level: none,off or 0: no highlighting for figures new-only or 1: surround newly added or changed figures with a blue frame [Default] - both or 2: highlight new figures with a blue frame and show deleted figures + both or 2: highlight new figures with a blue frame and show deleted figures at reduced scale, and crossed out with a red diagonal cross. Use configuration variable SCALEDELGRAPHICS to set size of deleted figures. - Note that changes to the optional parameters will make the figure appear as changed + Note that changes to the optional parameters will make the figure appear as changed to latexdiff, and this figure will thus be highlighted. In some circumstances "Misplaced \\noalign" errors can occur if there are certain types - of changes in tables. In this case please use option --graphics-markup=none as a - work-around. + of changes in tables. In this case please use option --graphics-markup=none as a + work-around. ---no-del Suppress deleted text from the diff. It is similar in effect to the BOLD style, +--no-del Suppress deleted text from the diff. It is similar in effect to the BOLD style, but the deleted text ist not just invisible in the output, it is also not included in the - diff text file. This can be more robust than just making it invisible. + diff text file. This can be more robust than just making it invisible. ---disable-citation-markup ---disable-auto-mbox Suppress citation markup and markup of other vulnerable commands in styles +--disable-citation-markup +--disable-auto-mbox Suppress citation markup and markup of other vulnerable commands in styles using ulem (UNDERLINE,FONTSTRIKE, CULINECHBAR) (the two options are identical and are simply aliases) --enable-citation-markup ---enforce-auto-mbox Protect citation commands and other vulnerable commands in changed sections +--enforce-auto-mbox Protect citation commands and other vulnerable commands in changed sections with \\mbox command, i.e. use default behaviour for ulem package for other packages (the two options are identical and are simply aliases) @@ -4246,14 +4287,14 @@ Miscellaneous options --no-label Suppress inclusion of old and new file names as comment in output file ---visible-label Include old and new filenames (or labels set with --label option) as +--visible-label Include old and new filenames (or labels set with --label option) as visible output --flatten Replace \\input and \\include commands within body by the content of the files in their argument. If \\includeonly is present in the - preamble, only those files are expanded into the document. However, - no recursion is done, i.e. \\input and \\include commands within - included sections are not expanded. The included files are assumed to + preamble, only those files are expanded into the document. However, + no recursion is done, i.e. \\input and \\include commands within + included sections are not expanded. The included files are assumed to be located in the same directories as the old and new master files, respectively, making it possible to organise files into old and new directories. --flatten is applied recursively, so inputted files can contain further @@ -4276,7 +4317,7 @@ Miscellaneous options -h Show this help text. --ignore-warnings Suppress warnings about inconsistencies in length between input - and parsed strings and missing characters. + and parsed strings and missing characters. --verbose -V Output various status information to stderr during processing. @@ -4288,10 +4329,10 @@ Internal options: These options are mostly for automated use by latexdiff-vc. They can be used directly, but the API should be considered less stable than for the other options. ---no-links Suppress generation of hyperreferences, used for minimal diffs +--no-links Suppress generation of hyperreferences, used for minimal diffs (option --only-changes of latexdiff-vc). EOF - exit 0; + exit 0; } =head1 NAME @@ -4317,8 +4358,8 @@ be real files (not pipes or similar) as they are opened twice (unless C<--encodi The program treats the preamble differently from the main document. Differences between the preambles are found using line-based differencing (similarly to the Unix diff command, but ignoring white -spaces). A comment, "S<C<%DIF E<gt>>>" is appended to each added line, i.e. a -line present in C<new.tex> but not in C<old.tex>. Discarded lines +spaces). A comment, "S<C<%DIF E<gt>>>" is appended to each added line, i.e. a +line present in C<new.tex> but not in C<old.tex>. Discarded lines are deactivated by prepending "S<C<%DIF E<lt>>>". Changed blocks are preceded by comment lines giving information about line numbers in the original files. Where there are insignificant differences, the resulting file C<diff.tex> will be similar to @@ -4371,7 +4412,7 @@ curly braces immediately following a command (i.e. a sequence of letters beginning with a backslash) are arguments for that command. As a restriction to condition 1 above it is thus necessary to surround all arguments with curly braces, and to not insert -extraneous spaces. For example, write +extraneous spaces. For example, write \section{\textem{This is an emphasized section title}} @@ -4403,7 +4444,7 @@ but the choice is yours. Any markup within the environment will be removed, and generally everything within the environment will just be taken from the new file. -It is also possible to difference files which do not have a preamble. +It is also possible to difference files which do not have a preamble. In this case, the file is processed in the main document mode, but the definitions of the markup commands are not inserted. @@ -4421,7 +4462,7 @@ the scope of C<\DIFadd>. Added comments are marked by prepending Within deleted blocks text is highlighted with C<\DIFdel>. Deleted comments are marked by prepending "S<C<%DIF E<lt> >>". Non-safe command -and curly braces within deleted blocks are commented out with +and curly braces within deleted blocks are commented out with "S<C<%DIFDELCMD E<lt> >>". @@ -4431,7 +4472,7 @@ and curly braces within deleted blocks are commented out with =head2 Preamble The following options determine the visual markup style by adding the appropriate -command definitions to the preamble. See the end of this section for a description of +command definitions to the preamble. See the end of this section for a description of available styles. =over 4 @@ -4441,15 +4482,16 @@ B<-t markupstyle> Add code to preamble for selected markup style. This option defines C<\DIFadd> and C<\DIFdel> commands. -Available styles: +Available styles: -C<UNDERLINE CTRADITIONAL TRADITIONAL CFONT FONTSTRIKE INVISIBLE -CHANGEBAR CCHANGEBAR CULINECHBAR CFONTCHBAR BOLD PDFCOMMENT> +C<UNDERLINE CTRADITIONAL TRADITIONAL CFONT FONTSTRIKE INVISIBLE +CHANGEBAR CCHANGEBAR CULINECHBAR CFONTCHBAR BOLD PDFCOMMENT +LUAUNDERLINE> [ Default: C<UNDERLINE> ] =item B<--subtype=markstyle> or -B<-s markstyle> +B<-s markstyle> Add code to preamble for selected style for bracketing commands (e.g. to mark changes in margin). This option defines @@ -4462,27 +4504,27 @@ Available styles: C<SAFE MARGIN COLOR DVIPSCOL ZLABEL ONLYCHANGEDPAGE (LABEL)*> =item B<--floattype=markstyle> or B<-f markstyle> -Add code to preamble for selected style which +Add code to preamble for selected style which replace standard marking and markup commands within floats (e.g., marginal remarks cause an error within floats -so marginal marking can be disabled thus). This option defines all +so marginal marking can be disabled thus). This option defines all C<\DIF...FL> commands. Available styles: C<FLOATSAFE TRADITIONALSAFE IDENTICAL> [ Default: C<FLOATSAFE> ] -=item B<--encoding=enc> or +=item B<--encoding=enc> or B<-e enc> Specify encoding of old.tex and new.tex. Typical encodings are -C<ascii>, C<utf8>, C<latin1>, C<latin9>. A list of available encodings can be -obtained by executing +C<ascii>, C<utf8>, C<latin1>, C<latin9>. A list of available encodings can be +obtained by executing C<perl -MEncode -e 'print join ("\n",Encode->encodings( ":all" )) ;' > If this option is used, then old.tex, new.tex are only opened once. [Default encoding is utf8 unless the first few lines of the preamble contain -an invocation C<\usepackage[..]{inputenc}> in which case the +an invocation C<\usepackage[..]{inputenc}> in which case the encoding chosen by this command is asssumed. Note that ASCII (standard latex) is a subset of utf8] @@ -4499,7 +4541,7 @@ C<\DIFaddbeginFL, \DIFaddendFL, \DIFaddFL{..}, (If this option is set B<-t>, B<-s>, and B<-f> options are ignored.) -=item B<--packages=pkg1,pkg2,..> +=item B<--packages=pkg1,pkg2,..> Tell latexdiff that .tex file is processed with the packages in list loaded. This is normally not necessary if the .tex file includes the @@ -4510,13 +4552,13 @@ The following packages trigger special behaviour: =over 8 -=item C<endfloat> +=item C<endfloat> Ensure that C<\begin{figure}> and C<\end{figure}> always appear by themselves on a line. =item C<hyperref> -Change name of C<\DIFadd> and C<\DIFdel> commands to C<\DIFaddtex> and C<\DIFdeltex> and +Change name of C<\DIFadd> and C<\DIFdel> commands to C<\DIFaddtex> and C<\DIFdeltex> and define new C<\DIFadd> and C<\DIFdel> commands, which provide a wrapper for these commands, using them for the text but not for the link defining command (where any markup would cause errors). @@ -4568,17 +4610,17 @@ B<-A exclude-file> or B<--exclude-safecmd="cmd1,cmd2,..."> =item B<--replace-safecmd=replace-file> -=item B<--append-safecmd=append-file> or +=item B<--append-safecmd=append-file> or B<-a append-file> or B<--append-safecmd="cmd1,cmd2,..."> Exclude from, replace or append to the list of regular expressions (RegEx) -matching commands which are safe to use within the +matching commands which are safe to use within the scope of a C<\DIFadd> or C<\DIFdel> command. The file must contain one Perl-RegEx per line (Comment lines beginning with # or % are -ignored). Note that the RegEx needs to match the whole of +ignored). Note that the RegEx needs to match the whole of the token, i.e., /^regex$/ is implied and that the initial -"\" of the command is not included. -The B<--exclude-safecmd> and B<--append-safecmd> options can be combined with the -B<--replace-safecmd> +"\" of the command is not included. +The B<--exclude-safecmd> and B<--append-safecmd> options can be combined with the -B<--replace-safecmd> option and can be used repeatedly to add cumulatively to the lists. B<--exclude-safecmd> and B<--append-safecmd> can also take a comma separated list as input. If a @@ -4591,7 +4633,7 @@ B<-X exclude-file> or B<--exclude-textcmd="cmd1,cmd2,..."> =item B<--replace-textcmd=replace-file> -=item B<--append-textcmd=append-file> or +=item B<--append-textcmd=append-file> or B<-x append-file> or B<--append-textcmd="cmd1,cmd2,..."> Exclude from, replace or append to the list of regular expressions @@ -4599,7 +4641,7 @@ matching commands whose last argument is text. See entry for B<--exclude-safecmd> directly above for further details. -=item B<--replace-context1cmd=replace-file> +=item B<--replace-context1cmd=replace-file> =item B<--append-context1cmd=append-file> or @@ -4608,11 +4650,11 @@ entry for B<--exclude-safecmd> directly above for further details. Replace or append to the list of regex matching commands whose last argument is text but which require a particular context to work, e.g. C<\caption> will only work within a figure -or table. These commands behave like text commands, except when +or table. These commands behave like text commands, except when they occur in a deleted section, when they are disabled, but their argument is shown as deleted text. -=item B<--replace-context2cmd=replace-file> +=item B<--replace-context2cmd=replace-file> =item B<--append-context2cmd=append-file> or @@ -4622,9 +4664,9 @@ As corresponding commands for context1. The only difference is that context2 commands are completely disabled in deleted sections, including their arguments. -context2 commands are also the only commands in the preamble, whose argument will be processed in +context2 commands are also the only commands in the preamble, whose argument will be processed in word-by-word mode (which only works, if they occur no more than once in the preamble). The algorithm currently cannot cope with repeated context2 commands in the preamble, as they occur e.g. for the C<\author> argument in some journal styles (not in the standard styles, though -If such a repetition is detected, the whole preamble will be processed in line-by-line mode. In such a case, use C<--replace-context2cmd> option to just select the commands, which should be processed and are not used repeatedly in the preamble. +If such a repetition is detected, the whole preamble will be processed in line-by-line mode. In such a case, use C<--replace-context2cmd> option to just select the commands, which should be processed and are not used repeatedly in the preamble. @@ -4633,7 +4675,7 @@ If such a repetition is detected, the whole preamble will be processed in line-b =item B<--append-mboxsafecmd=append-file> or B<--append-mboxsafecmd="cmd1,cmd2,..."> Define safe commands, which additionally need to be protected by encapsulating -in an C<\mbox{..}>. This is sometimes needed to get around incompatibilities +in an C<\mbox{..}>. This is sometimes needed to get around incompatibilities between external packages and the ulem package, which is used for highlighting in the default style UNDERLINE as well as CULINECHBAR CFONTSTRIKE @@ -4647,7 +4689,7 @@ in the default style UNDERLINE as well as CULINECHBAR CFONTSTRIKE Set configuration variables. The option can be repeated to set different variables (as an alternative to the comma-separated list). -Available variables (see below for further explanations): +Available variables (see below for further explanations): C<ARRENV> (RegEx) @@ -4677,10 +4719,10 @@ C<SCALEDELGRAPHICS> (Float) =item B<--add-to-config varenv1=pattern1,varenv2=pattern2,...> For configuration variables, which are a regular expression (essentially those ending -in ENV, COUNTERCMD and CUSTOMDIFCMD, see list above) this option provides an alternative way to modify the configuration +in ENV, COUNTERCMD and CUSTOMDIFCMD, see list above) this option provides an alternative way to modify the configuration variables. Instead of setting the complete pattern, with this option it is possible to add an alternative pattern. C<varenv> must be one of the variables listed above that take a regular -expression as argument, and pattern is any regular expression (which might need to be +expression as argument, and pattern is any regular expression (which might need to be protected from the shell by quotation). Several patterns can be added at once by using semi-colons to separate them, e.g. C<--add-to-config "LISTENV=myitemize;myenumerate,COUNTERCMD=endnote"> @@ -4700,7 +4742,7 @@ Show values of configuration variables. Combine all --show commands. -NB For all --show commands, no C<old.tex> or C<new.tex> file needs to be specified, and no +NB For all --show commands, no C<old.tex> or C<new.tex> file needs to be specified, and no differencing takes place. =back @@ -4717,29 +4759,29 @@ might get lumpeded with preceding commands) so should only be used if the default produces erroneous results. (Default requires arguments to directly follow each other without intervening spaces). -=item B<--math-markup=level> +=item B<--math-markup=level> -Determine granularity of markup in displayed math environments: +Determine granularity of markup in displayed math environments: Possible values for level are (both numerical and text labels are acceptable): -C<off> or C<0>: suppress markup for math environments. Deleted equations will not -appear in diff file. This mode can be used if all the other modes +C<off> or C<0>: suppress markup for math environments. Deleted equations will not +appear in diff file. This mode can be used if all the other modes cause invalid latex code. C<whole> or C<1>: Differencing on the level of whole equations. Even trivial changes -to equations cause the whole equation to be marked changed. This -mode can be used if processing in coarse or fine mode results in +to equations cause the whole equation to be marked changed. This +mode can be used if processing in coarse or fine mode results in invalid latex code. C<coarse> or C<2>: Detect changes within equations marked up with a coarse -granularity; changes in equation type (e.g.displaymath to equation) +granularity; changes in equation type (e.g.displaymath to equation) appear as a change to the complete equation. This mode is recommended for situations where the content and order of some equations are still being changed. [Default] C<fine> or C<3>: Detect small change in equations and mark up at fine granularity. This mode is most suitable, if only minor changes to equations are -expected, e.g. correction of typos. +expected, e.g. correction of typos. =item B<--graphics-markup=level> @@ -4751,33 +4793,33 @@ C<none>, C<off> or C<0>: no highlighting for figures C<new-only> or C<1>: surround newly added or changed figures with a blue frame [Default if graphicx package loaded] -C<both> or C<2>: highlight new figures with a blue frame and show deleted figures at reduced +C<both> or C<2>: highlight new figures with a blue frame and show deleted figures at reduced scale, and crossed out with a red diagonal cross. Use configuration variable SCALEDELGRAPHICS to set size of deleted figures. -Note that changes to the optional parameters will make the figure appear as changed +Note that changes to the optional parameters will make the figure appear as changed to latexdiff, and this figure will thus be highlighted. In some circumstances "Misplaced \noalign" error can occur if there are certain types -of changes in tables. In this case please use C<--graphics-markup=none> as a -work-around. +of changes in tables. In this case please use C<--graphics-markup=none> as a +work-around. -=item B<--no-del> +=item B<--no-del> -Suppress deleted text from the diff. It is similar in effect to the BOLD style, -but the deleted text ist not just invisible in the output, it is also not included in the diff text file. -This can be more robust than just making it invisible. +Suppress deleted text from the diff. It is similar in effect to the BOLD style, +but the deleted text ist not just invisible in the output, it is also not included in the diff text file. +This can be more robust than just making it invisible. =item B<--disable-citation-markup> or B<--disable-auto-mbox> -Suppress citation markup and markup of other vulnerable commands in styles +Suppress citation markup and markup of other vulnerable commands in styles using ulem (UNDERLINE,FONTSTRIKE, CULINECHBAR) (the two options are identical and are simply aliases) =item B<--enable-citation-markup> or B<--enforce-auto-mbox> -Protect citation commands and other vulnerable commands in changed sections +Protect citation commands and other vulnerable commands in changed sections with C<\mbox> command, i.e. use default behaviour for ulem package for other packages (the two options are identical and are simply aliases) @@ -4823,18 +4865,18 @@ Suppress inclusion of old and new file names as comment in output file =item B<--visible-label> -Include old and new filenames (or labels set with C<--label> option) as +Include old and new filenames (or labels set with C<--label> option) as visible output. =item B<--flatten> Replace C<\input> and C<\include> commands within body by the content of the files in their argument. If C<\includeonly> is present in the -preamble, only those files are expanded into the document. However, -no recursion is done, i.e. C<\input> and C<\include> commands within -included sections are not expanded. The included files are assumed to +preamble, only those files are expanded into the document. However, +no recursion is done, i.e. C<\input> and C<\include> commands within +included sections are not expanded. The included files are assumed to be located in the same directories as the old and new master files, -respectively, making it possible to organise files into old and new directories. +respectively, making it possible to organise files into old and new directories. --flatten is applied recursively, so inputted files can contain further C<\input> statements. Also handles files included by the import package (C<\import> and C<\subimport>), and C<\subfile> command. @@ -4881,7 +4923,7 @@ Suppress generation of hyperreferences, used for minimal diffs (option --only-ch =back -=head2 Predefined styles +=head2 Predefined styles =head2 Major types @@ -4894,9 +4936,14 @@ The major type determine the markup of plain text and some selected latex comman Added text is wavy-underlined and blue, discarded text is struck out and red (Requires color and ulem packages). Overstriking does not work in displayed math equations such that deleted parts of equation are underlined, not struck out (this is a shortcoming inherent to the ulem package). +=item C<LUAUNDERLINE> + +Added text is underlined and blue, discarded text is struck out and red +(Requires lua-ul package + LuaLaTeX). + =item C<CTRADITIONAL> -Added text is blue and set in sans-serif, and a red footnote is created for each discarded +Added text is blue and set in sans-serif, and a red footnote is created for each discarded piece of text. (Requires color package) =item C<TRADITIONAL> @@ -4937,13 +4984,13 @@ Added text is set in bold face, discarded is not shown. (also see --no-del optio =item C<PDFCOMMENT> -The pdfcomment package is used to underline new text, and mark deletions with a PDF comment. Note that this markup might appear differently or not at all based on the pdf viewer used. The viewer with best support for pdf markup is probably acroread. This style is only recommended if the number of differences is small. +The pdfcomment package is used to underline new text, and mark deletions with a PDF comment. Note that this markup might appear differently or not at all based on the pdf viewer used. The viewer with best support for pdf markup is probably acroread. This style is only recommended if the number of differences is small. =back =head2 Subtypes -The subtype defines the commands that are inserted at the begin and end of added or discarded blocks, irrespectively of whether these blocks contain text or commands (Defined commands: C<\DIFaddbegin, \DIFaddend, \DIFdelbegin, \DIFdelend>) +The subtype defines the commands that are inserted at the begin and end of added or discarded blocks, irrespectively of whether these blocks contain text or commands (Defined commands: C<\DIFaddbegin, \DIFaddend, \DIFdelbegin, \DIFdelend>) =over 10 @@ -4961,7 +5008,7 @@ from the intended position. An alternative way of marking added passages in blue, and deleted ones in red. (It is recommeneded to use instead the main types to effect colored markup, -although in some cases coloring with dvipscol can be more complete, for example +although in some cases coloring with dvipscol can be more complete, for example with citation commands). =item C<DVIPSCOL> @@ -4976,12 +5023,12 @@ although in some cases coloring with dvipscol can be more complete). can be used to highlight only changed pages, but requires post-processing. It is recommend to not call this option manually but use C<latexdiff-vc> with C<--only-changes> option. Alternatively, use the script given within preamble of diff files made using this style. -=item C<ONLYCHANGEDPAGE> +=item C<ONLYCHANGEDPAGE> also highlights changed pages, without the need for post-processing, but might not work reliably if there is floating material (figures, tables). -=item C<LABEL> +=item C<LABEL> is similar to C<ZLABEL>, but does not need the zref package and works less reliably (deprecated). @@ -4989,7 +5036,7 @@ is similar to C<ZLABEL>, but does not need the zref package and works less relia =head2 Float Types -Some of the markup used in the main text might cause problems when used within +Some of the markup used in the main text might cause problems when used within floats (e.g. figures or tables). For this reason alternative versions of all markup commands are used within floats. The float type defines these alternative commands. @@ -5016,7 +5063,7 @@ Make no difference between the main text and floats. =item C<ARRENV> -If a match to C<ARRENV> is found within an inline math environment within a deleted or added block, then the inlined math +If a match to C<ARRENV> is found within an inline math environment within a deleted or added block, then the inlined math is surrounded by C<\mbox{>...C<}>. This is necessary as underlining does not work within inlined array environments. [ Default: C<ARRENV>=S<C<(?:array|[pbvBV]matrix)> > @@ -5036,9 +5083,9 @@ C<|subsubsection|paragraph|subparagraph)> ] This option is for advanced users and allows definition of special versions of commands, which do not work as safe commands. Commands in C<CUSTOMDIFCMD> that occur in added or deleted blocks will be given an ADD or DEL prefix. -The prefixed versions of the command must be defined in the preamble, either by putting them +The prefixed versions of the command must be defined in the preamble, either by putting them in the preamble of at least the new file, or by creating a custom preamble file (Option --preamble). -For example the command C<\blindtext> (from package blindtext) does not interact well with underlining, so that +For example the command C<\blindtext> (from package blindtext) does not interact well with underlining, so that for the standard markup type, it is not satisfactory to define it as a safe command. Instead, a customised versions without underlining can be defined in the preamble: @@ -5052,7 +5099,7 @@ and then latexdiff should be invoked with the option C<-c CUSTOMDIFCMD=blindtext =item C<FLOATENV> -Environments whose name matches the regular expression in C<FLOATENV> are +Environments whose name matches the regular expression in C<FLOATENV> are considered floats. Within these environments, the I<latexdiff> markup commands are replaced by their FL variaties. @@ -5101,17 +5148,17 @@ If C<--graphics-markup=both> is chosen, C<SCALEDELGRAPHICS> is the factor, by wh =item C<VERBATIMENV> -RegEx describing environments like verbatim, whose contents should be taken verbatim. The content of these environments will not be processed in any way: +RegEx describing environments like verbatim, whose contents should be taken verbatim. The content of these environments will not be processed in any way: deleted content is commented out, new content is not marked up [ Default: S<C<comment> > ] =item C<VERBATIMLINEENV> -RegEx describing environments like verbatim, whose contents should be taken verbatim. The content of environments described by VERBATIMLINEENV are compared in +RegEx describing environments like verbatim, whose contents should be taken verbatim. The content of environments described by VERBATIMLINEENV are compared in line mode, and changes are marked up using the listings package. The markup style is set based on the chosen mains markup type (Option -t), or on an analysis of the preamble. -Note that "listings.sty" must be installed. If this file is not found the fallback solution is to +Note that "listings.sty" must be installed. If this file is not found the fallback solution is to treat VERBATIMLINEENV environments treated exactly the same way as VERBATIMENV environments. [ Default: S<C<(?:verbatim[*]?|lstlisting> > ] @@ -5122,30 +5169,40 @@ treat VERBATIMLINEENV environments treated exactly the same way as VERBATIMENV e =over 10 -=item Citations result in overfull boxes +=item Changed citations result in overfull boxes There is an incompatibility between the C<ulem> package, which C<latexdiff> uses for underlining and striking out in the UNDERLINE style, -the default style, and the way citations are generated. In order to be able to mark up citations properly, they are enclosed with an C<\mbox> -command. As mboxes cannot be broken across lines, this procedure frequently results in overfull boxes, possibly obscuring the content as it extends beyond the right margin. The same occurs for some other packages (e.g., siunitx). If this is a problem, you have two possibilities. +the default style, and the way citations are generated. In order to be able to mark up citations properly, they are enclosed with an C<\mbox> +command. As mboxes cannot be broken across lines, this procedure frequently results in overfull boxes, possibly obscuring the content as it extends beyond the right margin. The same occurs for some other packages (e.g., siunitx). If this is a problem, you have several possibilities. 1. Use C<CFONT> type markup (option C<-t CFONT>): If this markup is chosen, then changed citations are no longer marked up -with the wavy line (additions) or struck out (deletions), but are still highlighted in the appropriate color, and deleted text is shown with a different font. Other styles not using the C<ulem> package will also work. +with the wavy line (additions) or struck out (deletions), but are still highlighted in the appropriate color, and deleted text is shown with a different font. Other styles not using the C<ulem> package will also work. 2. Choose option C<--disable-citation-markup> which turns off the marking up of citations: deleted citations are no longer shown, and -added citations are shown without markup. (This was the default behaviour of latexdiff at versions 0.6 and older) - +added citations are shown without markup. (This was the default behaviour of latexdiff at versions 0.6 and older). For custom packages you can define the commands which need to be protected by C<\mbox> with C<--append-mboxsafecmd> and C<--excludemboxsafecmd> options (submit your lists of command as feature request at github page to set the default behaviour of future versions, see section 6) -=item Changes in complicated mathematical equations result in latex processing errors +3. If you are using luatex >= 1.12.0 you can use option LUAUNDERLINE that uses lua-ul instead of ulem for underlining, which does not have this problem (experimental feature). + +=item Changes in complicated mathematical equations result in latex processing errors. + +Try option C<--math-markup=whole>. If even that fails, you can turn off mark up for equations with C<--math-markup=off>. -Try options C<--math-markup=whole>. If even that fails, you can turn off mark up for equations with C<--math-markup=off>. +=item Deleted parts in equations are not struck out but underlined. -=item How can I just show the pages where changes had been made +This is a limitation of the ulem package that implements the strike-out. If you use the amsmath package, then the strike-out command is redefined in such a way that deleted passages are wrapped with C<\text> command; adding C<\usepackage{amsmath}> to your preamble will trigger this behaviour. (If amsmath is not included directly, but imported by another package, latexdiff will not be able to detect its availability; in this case you can give latexdiff a hint with option C<--packages=amsmath>. -Use options -C<-s ZLABEL> (some postprocessing required) or C<-s ONLYCHANGEDPAGE>. C<latexdiff-vc --ps|--pdf> with C<--only-changes> option takes care of + +=item How can I just show the pages where changes had been made? + +Use options C<--s ZLABEL> (some postprocessing required) or C<-s ONLYCHANGEDPAGE>. C<latexdiff-vc --ps|--pdf> with C<--only-changes> option takes care of the post-processing for you (requires zref package to be installed). +=item The character encoding breaks when running latexdiff from powershell. + +This problem is not limited to C<latexdiff> and has to do with the default settings of C<powershell> in Windows. It is recommended to use C<cmd> instead. + =back =head1 BUGS @@ -5158,13 +5215,13 @@ different numbers of inter-argument spaces are treated as significant. =back -Please submit bug reports using the issue tracker of the github repository page I<https://github.com/ftilmann/latexdiff.git>, +Please submit bug reports using the issue tracker of the github repository page I<https://github.com/ftilmann/latexdiff.git>, or send them to I<tilmann -- AT -- gfz-potsdam.de>. Include the version number of I<latexdiff> (from comments at the top of the source or use B<--version>). If you come across latex files that are error-free and conform to the specifications set out above, and whose differencing still does not result in error-free latex, please send me those files, ideally edited to only contain the -offending passage as long as that still reproduces the problem. If your +offending passage as long as that still reproduces the problem. If your file relies on non-standard class files, you must include those. I will not look at examples where I have trouble to latex the original files. @@ -5175,24 +5232,24 @@ L<latexrevise>, L<latexdiff-vc> =head1 PORTABILITY I<latexdiff> does not make use of external commands and thus should run -on any platform supporting Perl 5.6 or higher. If files with encodings +on any platform supporting Perl 5.6 or higher. If files with encodings other than ASCII or UTF-8 are processed, Perl 5.8 or higher is required. The standard version of I<latexdiff> requires installation of the Perl package -C<Algorithm::Diff> (available from I<www.cpan.org> - +C<Algorithm::Diff> (available from I<www.cpan.org> - I<http://search.cpan.org/~nedkonz/Algorithm-Diff-1.15>) but a stand-alone version, I<latexdiff-so>, which has this package inlined, is available, too. I<latexdiff-fast> requires the I<diff> command to be present. =head1 AUTHOR -Version 1.3.3 -Copyright (C) 2004-2022 Frederik Tilmann +Version 1.3.4 +Copyright (C) 2004-2024 Frederik Tilmann This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License Version 3 -Contributors of fixes and additions: V. Kuhlmann, J. Paisley, N. Becker, T. Doerges, K. Huebner, +Contributors of fixes and additions: V. Kuhlmann, J. Paisley, N. Becker, T. Doerges, K. Huebner, T. Connors, Sebastian Gouezel and many others. Thanks to the many people who sent in bug reports, feature suggestions, and other feedback. @@ -5463,13 +5520,14 @@ value underline sqrt (SUPER|SUB)SCRIPT -%%END TEXT COMMANDS +%%END TEXT COMMANDS %%BEGIN CONTEXT1 COMMANDS % Regex matching commands with a text argument (leave out the \), which will fail out of context. These commands behave like text commands, except when they occur in a deleted section, where they are disabled, but their argument is shown as deleted text. caption subcaption -%%END CONTEXT1 COMMANDS +multicolumn +%%END CONTEXT1 COMMANDS %%BEGIN CONTEXT2 COMMANDS % Regex matching commands with a text argument (leave out the \), which will fail out of context. As corresponding commands for context1. The only difference is that context2 commands are completely disabled in deleted sections, including their arguments. @@ -5477,7 +5535,7 @@ title author date institute -%%END CONTEXT2 COMMANDS +%%END CONTEXT2 COMMANDS %% CONFIGURATION variabe defaults %%BEGIN LISTENV CONFIG @@ -5555,9 +5613,16 @@ verbatim[*]? \RequirePackage[normalem]{ulem} \RequirePackage{color}\definecolor{RED}{rgb}{1,0,0}\definecolor{BLUE}{rgb}{0,0,1} \providecommand{\DIFadd}[1]{{\protect\color{blue}\uwave{#1}}} -\providecommand{\DIFdel}[1]{{\protect\color{red}\sout{#1}}} +\providecommand{\DIFdel}[1]{{\protect\color{red}\sout{#1}}} %DIF END UNDERLINE PREAMBLE +%DIF LUAUNDERLINE PREAMBLE +\RequirePackage{lua-ul} +\RequirePackage{color}\definecolor{RED}{rgb}{1,0,0}\definecolor{BLUE}{rgb}{0,0,1} +\providecommand{\DIFadd}[1]{{\protect\color{blue}\underLine{#1}}} +\providecommand{\DIFdel}[1]{{\protect\color{red}\strikeThrough{#1}}} +%DIF END LUAUNDERLINE PREAMBLE + %DIF CTRADITIONAL PREAMBLE \RequirePackage{color}\definecolor{RED}{rgb}{1,0,0}\definecolor{BLUE}{rgb}{0,0,1} \RequirePackage[stable]{footmisc} @@ -5729,7 +5794,7 @@ verbatim[*]? % To show only pages with changes (dvips/dvipdf) % latex diff.tex % latex diff.tex -% dvips -pp `perl -lne 'if (m/\\newlabel{DIFchg[be]\d*}{{.*}{(.*)}}/) { print $1 }' diff.aux | uniq | tr -s \\n ','` diff.dvi +% dvips -pp `perl -lne 'if (m/\\newlabel{DIFchg[be]\d*}{{.*}{(.*)}}/) { print $1 }' diff.aux | uniq | tr -s \\n ','` diff.dvi \typeout{Check comments in preamble of output for instructions how to show only pages where changes have been made} \usepackage[user,abspage]{zref} \newcount\DIFcounterb @@ -5749,10 +5814,10 @@ verbatim[*]? \RequirePackage{etoolbox} \RequirePackage{zref} % redefine label command to write immediately to aux file - page references will be lost -\makeatletter \let\oldlabel\label% Store \label -\renewcommand{\label}[1]{% Update \label to write to the .aux immediately -\zref@wrapper@immediate{\oldlabel{#1}}} -\makeatother +\makeatletter \let\oldlabel\label% Store \label +\renewcommand{\label}[1]{% Update \label to write to the .aux immediately +\zref@wrapper@immediate{\oldlabel{#1}}} +\makeatother \newbool{DIFkeeppage} \newbool{DIFchange} \boolfalse{DIFkeeppage} @@ -5770,7 +5835,7 @@ verbatim[*]? \providecommand{\DIFmodend}{\global\booltrue{DIFkeeppage}\global\boolfalse{DIFchange}} %DIF END ONLYCHANGEDPAGE PREAMBLE -%% FLOAT TYPES +%% FLOAT TYPES %DIF FLOATSAFE PREAMBLE \providecommand{\DIFaddFL}[1]{\DIFadd{#1}} @@ -5802,7 +5867,7 @@ verbatim[*]? %DIF END TRADITIONALSAFE PREAMBLE % see: -% http://tex.stackexchange.com/questions/47351/can-i-redefine-a-command-to-contain-itself +% http://tex.stackexchange.com/questions/47351/can-i-redefine-a-command-to-contain-itself %DIF HIGHLIGHTGRAPHICS PREAMBLE \RequirePackage{settobox} @@ -5848,6 +5913,15 @@ verbatim[*]? %% SPECIAL PACKAGE PREAMBLE COMMANDS +%% Redefine strike out command to wrap in text box if amsmath is used and markup style with ulem is used +%DIF AMSMATHULEM PREAMBLE +\makeatletter +\let\sout@orig\sout +\renewcommand{\sout}[1]{\ifmmode\text{\sout@orig{\ensuremath{#1}}}\else\sout@orig{#1}\fi} +\makeatother +%DIF END AMSMATHULEM PREAMBLE + + % Standard \DIFadd and \DIFdel are redefined as \DIFaddtex and \DIFdeltex % when hyperref package is included. %DIF HYPERREF PREAMBLE @@ -5950,7 +6024,7 @@ verbatim[*]? %DIF END DIFCODE_BOLD %DIF DIFCODE_PDFCOMMENT - + moredelim=[il][\color{white}\tiny]{\%DIF\ <\ }, moredelim=[il][\sffamily\bfseries]{\%DIF\ >\ } %DIF END DIFCODE_PDFCOMMENT diff --git a/Master/texmf-dist/doc/support/latexindent/README b/Master/texmf-dist/doc/support/latexindent/README index 0b58c4ee729..3bd2dbfe981 100644 --- a/Master/texmf-dist/doc/support/latexindent/README +++ b/Master/texmf-dist/doc/support/latexindent/README @@ -1,5 +1,5 @@ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - latexindent.pl, version 3.24.2, 2024-06-15 + latexindent.pl, version 3.24.4, 2024-07-18 PERL script to indent code within environments, and align delimited environments in .tex files. diff --git a/Master/texmf-dist/doc/support/latexindent/latexindent-yaml-schema.json b/Master/texmf-dist/doc/support/latexindent/latexindent-yaml-schema.json index 8f457e916f3..8f0cf208e28 100644 --- a/Master/texmf-dist/doc/support/latexindent/latexindent-yaml-schema.json +++ b/Master/texmf-dist/doc/support/latexindent/latexindent-yaml-schema.json @@ -2,7 +2,7 @@ "$schema": "http://json-schema.org/schema", "$id": "latexindent-yaml-schema.json", "title": "latexindent.pl YAML schema", - "description": "latexindent.pl YAML schema helper, V3.24.2 2024-06-15", + "description": "latexindent.pl YAML schema helper, V3.24.4 2024-07-18", "type": "object", "properties": { "fileExtensionPreference": { diff --git a/Master/texmf-dist/doc/support/latexindent/latexindent.pdf b/Master/texmf-dist/doc/support/latexindent/latexindent.pdf Binary files differindex 60f57e8d37c..19361f5268a 100644 --- a/Master/texmf-dist/doc/support/latexindent/latexindent.pdf +++ b/Master/texmf-dist/doc/support/latexindent/latexindent.pdf diff --git a/Master/texmf-dist/doc/support/latexindent/latexindent.tex b/Master/texmf-dist/doc/support/latexindent/latexindent.tex index e5a2ae3b160..fefde34ec25 100644 --- a/Master/texmf-dist/doc/support/latexindent/latexindent.tex +++ b/Master/texmf-dist/doc/support/latexindent/latexindent.tex @@ -131,6 +131,7 @@ % bibliographies \addbibresource{latex-indent} \addbibresource{contributors} +\BiblatexSplitbibDefernumbersWarningOff % http://tex.stackexchange.com/questions/122135/how-to-add-a-png-icon-on-the-right-side-of-a-tcolorbox-title \newtcolorbox{warning}{parbox=false, @@ -585,14 +586,14 @@ title={example~\thetcbcounter}, fonttitle=\bfseries\sffamily, detach title, - before upper={\llap{\tcbtitle\hspace{5mm}}}, coltitle=black, colback=white, grow to left by=6mm, % % circles and line by the side % - overlay unbroken={% + overlay unbroken and first={% + \node at ([xshift=-8mm,yshift=-4.5mm]interior.north west) {\bfseries example \thetcbcounter}; \path [fill=black] ([xshift=1mm,yshift=3mm]interior.south east) node{\hbox{\rule{1ex}{1ex}}}; }, overlay last={% @@ -859,7 +860,7 @@ throughout this document for details}. \subsection{Quick start}\label{sec:quickstart} - When \texttt{latexindent.pl} reads and writes files, the files are read and written in UTF-8 format by default. + When \texttt{latexindent.pl} reads and writes files, the files are read and written in UTF-8 format by default. That is to say, the encoding format for tex and yaml files needs to be in UTF-8 format. If you'd like to get started with \texttt{latexindent.pl} then simply type @@ -8563,8 +8564,8 @@ perl latexindent-module-installer.pl \begin{commandshell} sudo apt-get install perlbrew perlbrew init -perlbrew install perl-5.39.1 -perlbrew switch perl-5.39.1 +perlbrew install perl-5.40.0 +perlbrew switch perl-5.40.0 sudo apt-get install curl curl -L http://cpanmin.us | perl - App::cpanminus cpanm YAML::Tiny diff --git a/Master/texmf-dist/doc/support/luafindfont/CHANGELOG b/Master/texmf-dist/doc/support/luafindfont/CHANGELOG index 783f804f294..a629f6617a8 100644 --- a/Master/texmf-dist/doc/support/luafindfont/CHANGELOG +++ b/Master/texmf-dist/doc/support/luafindfont/CHANGELOG @@ -1,3 +1,4 @@ +0.14 2024-08-25 - small changes to the output 0.13 2023-06-23 - add exrun:close() for every kpsewhich test 0.12 2023-06-21 - bugfix for undefined exrun (l. 251) - check for empty font list and given font number diff --git a/Master/texmf-dist/doc/support/luafindfont/luafindfont-doc.pdf b/Master/texmf-dist/doc/support/luafindfont/luafindfont-doc.pdf Binary files differindex 65be6ced105..f51c3478b88 100644 --- a/Master/texmf-dist/doc/support/luafindfont/luafindfont-doc.pdf +++ b/Master/texmf-dist/doc/support/luafindfont/luafindfont-doc.pdf diff --git a/Master/texmf-dist/doc/support/luafindfont/luafindfont-doc.tex b/Master/texmf-dist/doc/support/luafindfont/luafindfont-doc.tex index c10483ce5a2..818cd16fbb1 100644 --- a/Master/texmf-dist/doc/support/luafindfont/luafindfont-doc.tex +++ b/Master/texmf-dist/doc/support/luafindfont/luafindfont-doc.tex @@ -1,4 +1,4 @@ - %% $Id: luafindfont-doc.tex 648 2022-11-03 19:58:48Z herbert $ + %% $Id: luafindfont-doc.tex 962 2024-08-25 16:50:54Z herbert $ % \listfiles\setcounter{errorcontextlines}{100} \documentclass[paper=a4,fontsize=11pt,DIV=14,parskip=half-, @@ -81,7 +81,7 @@ \def\setVersion#1{\setVVersion#1!!} \def\setVVersion#1=#2!!{\def\luafindfontVersion{#2}} -\setVersion{version = 0.11}% can be automatically changed by perl +\setVersion{version = 0.14}% can be automatically changed by perl \setkeys{hv}{cleanup={},force} diff --git a/Master/texmf-dist/doc/support/make4ht/README b/Master/texmf-dist/doc/support/make4ht/README index 561d6bd14dd..33ccdb5b815 100644 --- a/Master/texmf-dist/doc/support/make4ht/README +++ b/Master/texmf-dist/doc/support/make4ht/README @@ -1,4 +1,5 @@ % [![Build Status](https://travis-ci.org/michal-h21/make4ht.svg?branch=master)](https://travis-ci.org/michal-h21/make4ht) +% HTML version of the documentation can be found [here](https://www.kodymirus.cz/make4ht/make4ht-doc.html) # Introduction @@ -8,11 +9,12 @@ customized conversion tools. An example of such a tool is [tex4ebook](https://github.com/michal-h21/tex4ebook), a tool for conversion from \TeX\ to ePub and other e-book formats. -See section \ref{sec:htlatex} for some reasons why you should consider to use `make4ht` instead of `htlatex`, -section \ref{sec:output} talks about supported output formats and extensions and section \ref{sec:buildfiles} +See section \ref{sec:htlatex} for some reasons why you should consider to use `make4ht` instead +of `htlatex`, section \ref{sec:output} talks about supported output formats and extensions and section \ref{sec:buildfiles} describes build files, which can be used to execute additional commands or post-process the generated files. + # Usage The basic conversion from \LaTeX\ to `HTML` using `make4ht` can be executed using the following command: @@ -1162,12 +1164,23 @@ Example: options -: command line options for Dvisvgm. The default value is `-n --exact -c 1.15,1.15`. +: command line options for Dvisvgm. The default value is `-n --exact -c ${scale},${scale}`. cpu_cnt : the number of processor cores used for the conversion. The extension tries to detect the available cores automatically by default. +make_command + +: variant of the `make` command used for the parallel conversion of large +number of pages. It receives tvo variables, `process_count` and `make_file`. +Default value is "make -j ${process_count} -f ${make_file}". + +test_make_command + +: command that tests if the selected variant of the `make` command exists. Default value is `make -v`. + + parallel_size : the number of pages used in each Dvisvgm call. The extension detects changed @@ -1176,7 +1189,7 @@ pages. scale -: SVG scaling. +: amount of SVG scaling. The default value is 1.4. ## The `odttemplate` filter and extension diff --git a/Master/texmf-dist/doc/support/make4ht/changelog.tex b/Master/texmf-dist/doc/support/make4ht/changelog.tex index e17af6d5db3..d60bfc51c3c 100644 --- a/Master/texmf-dist/doc/support/make4ht/changelog.tex +++ b/Master/texmf-dist/doc/support/make4ht/changelog.tex @@ -3,6 +3,136 @@ \begin{itemize} \item + 2024/10/22 + + \begin{itemize} + \tightlist + \item + version \texttt{0.4b} released. + \item + test for the existence of the class atribute of tables before + performing string matches in the \texttt{tablerows} DOM filter. + \end{itemize} +\item + 2024/10/21 + + \begin{itemize} + \tightlist + \item + version \texttt{0.4a} released. + \end{itemize} +\item + 2024/09/30 + + \begin{itemize} + \tightlist + \item + remove last empty row in \texttt{longtable} environments. + \end{itemize} +\item + 2024/09/25 + + \begin{itemize} + \tightlist + \item + added \texttt{make4ht-char-def} library to remove dependency on + \texttt{char-def} from ConTeXt. It is used by the \texttt{sectionid} + DOM filter. The library is automatically created from + UnicodeData.txt by \texttt{tools/make\_chardata.lua}. + https://tex.stackexchange.com/q/727202/2891 + \end{itemize} +\item + 2024/09/18 + + \begin{itemize} + \tightlist + \item + print error messages from the \texttt{log} file. + \end{itemize} +\item + 2024/08/22 + + \begin{itemize} + \tightlist + \item + print debug message with XML parsing error context + \end{itemize} +\item + 2024/08/21 + + \begin{itemize} + \tightlist + \item + try the HTML parser for DOM filters if XML parser fails. + \end{itemize} +\item + 2024/06/18 + + \begin{itemize} + \tightlist + \item + changed default scaling in \texttt{dvisvgm\_hashes} to 1.4. + \end{itemize} +\item + 2024/06/17 + + \begin{itemize} + \tightlist + \item + fixed support for index entries that are broken over several lines. + \end{itemize} +\item + 2024/05/29 + + \begin{itemize} + \tightlist + \item + create temporary Lg file for Xtpipes. + https://github.com/michal-h21/make4ht/issues/148\#issuecomment-2136160818 + \item + fixed handling of the generated ODT file, don't copy it + unnecessarily and handle build and output directories. + https://github.com/michal-h21/make4ht/issues/148\#issuecomment-2136160818 + \end{itemize} +\item + 2024/04/23 + + \begin{itemize} + \tightlist + \item + test if referenced files are contained in the \texttt{build-dir} + directory, use the current dir otherwise. + https://github.com/michal-h21/tex4ebook/issues/126 + \end{itemize} +\item + 2024/04/16 + + \begin{itemize} + \tightlist + \item + fixed bug in \texttt{dvisvgm\_hashes} log parsing. On Windows, it + didn't expect \texttt{\textbackslash{}r} characters at the line + ends, they then ended in new SVG filenames. + \end{itemize} +\item + 2024/04/15 + + \begin{itemize} + \tightlist + \item + made the \texttt{make} command used in the \texttt{dvisvgm\_hashes} + extension configurable. https://tex.stackexchange.com/q/715633/2891 + \end{itemize} +\item + 2024/03/29 + + \begin{itemize} + \tightlist + \item + ignore numbers in braces in \texttt{make4ht-indexing} library. + https://tex.stackexchange.com/q/714247/2891 + \end{itemize} +\item 2024/02/22 \begin{itemize} diff --git a/Master/texmf-dist/doc/support/make4ht/make4ht-doc.pdf b/Master/texmf-dist/doc/support/make4ht/make4ht-doc.pdf Binary files differindex 7eacc7bd950..ed8effdfe99 100644 --- a/Master/texmf-dist/doc/support/make4ht/make4ht-doc.pdf +++ b/Master/texmf-dist/doc/support/make4ht/make4ht-doc.pdf diff --git a/Master/texmf-dist/doc/support/make4ht/readme.tex b/Master/texmf-dist/doc/support/make4ht/readme.tex index 9cff4cbeeae..d5392e53114 100644 --- a/Master/texmf-dist/doc/support/make4ht/readme.tex +++ b/Master/texmf-dist/doc/support/make4ht/readme.tex @@ -10,11 +10,10 @@ tools. An example of such a tool is conversion from \TeX~to ePub and other e-book formats. See section \ref{sec:htlatex} for some reasons why you should consider -to use \texttt{make4ht} instead of \texttt{htlatex},\\ -section \ref{sec:output} talks about supported output formats and -extensions and section \ref{sec:buildfiles} describes build files, which -can be used to execute additional commands or post-process the generated -files. +to use \texttt{make4ht} instead of \texttt{htlatex}, section +\ref{sec:output} talks about supported output formats and extensions and +section \ref{sec:buildfiles} describes build files, which can be used to +execute additional commands or post-process the generated files. \hypertarget{usage}{% \section{Usage}\label{usage}} @@ -1279,16 +1278,24 @@ extension}{The dvisvgm\_hashes extension}}\label{the-dvisvgm_hashes-extension}} \begin{description} \item[options] command line options for Dvisvgm. The default value is -\texttt{-n\ -\/-exact\ -c\ 1.15,1.15}. +\texttt{-n\ -\/-exact\ -c\ \$\{scale\},\$\{scale\}}. \item[cpu\_cnt] the number of processor cores used for the conversion. The extension tries to detect the available cores automatically by default. +\item[make\_command] +variant of the \texttt{make} command used for the parallel conversion of +large number of pages. It receives tvo variables, +\texttt{process\_count} and \texttt{make\_file}. Default value is ``make +-j \$\{process\_count\} -f \$\{make\_file\}''. +\item[test\_make\_command] +command that tests if the selected variant of the \texttt{make} command +exists. Default value is \texttt{make\ -v}. \item[parallel\_size] the number of pages used in each Dvisvgm call. The extension detects changed pages in the DVI file and constructs multiple calls to Dvisvgm with only changed pages. \item[scale] -SVG scaling. +amount of SVG scaling. The default value is 1.4. \end{description} \hypertarget{the-odttemplate-filter-and-extension}{% diff --git a/Master/texmf-dist/doc/support/mf2pt1/ChangeLog b/Master/texmf-dist/doc/support/mf2pt1/ChangeLog index a8e6d2d9105..6df8f950676 100644 --- a/Master/texmf-dist/doc/support/mf2pt1/ChangeLog +++ b/Master/texmf-dist/doc/support/mf2pt1/ChangeLog @@ -1,4 +1,15 @@ -2021-12-04 Scott Pakin <pakin@pakin.org> +2024-07-06 Scott Pakin <scott+mf@pakin.org> + + * README, mf2pt1.texi, mf2pt1.mp, mf2pt1.pl: Updated the copyright + year to 2024. + + * mf2pt1.pl: Applied a patch from Werner Lemberg <wl@gnu.org> that + adds extrema later in the FontForge postprocessing script. This + patch originally was submitted as a LilyPond merge request + (https://gitlab.com/lilypond/lilypond/-/merge_requests/2374). + Updated the program version to 2.8. + +2021-12-04 Scott Pakin <scott+mf@pakin.org> * README, mf2pt1.texi: Updated the copyright year to 2021. @@ -7,7 +18,7 @@ already exist. Updated the copyright year to 2021. Updated the version to 2.7. -2021-11-28 Scott Pakin <pakin@pakin.org> +2021-11-28 Scott Pakin <scott+mf@pakin.org> * Makefile, mf2pt1.pl, mf2pt1.texi: Documented that environment variables for programs can now include @@ -18,13 +29,13 @@ commands to be overridden by environment variables that can also include program parameters. -2021-11-27 Scott Pakin <pakin@pakin.org> +2021-11-27 Scott Pakin <scott+mf@pakin.org> * mf2pt1.pl: Introduced a --save-temps option to suppress deletion of intermediate files. -2020-11-27 Scott Pakin <pakin@pakin.org> +2020-11-27 Scott Pakin <scott+mf@pakin.org> * ChangeLog, README, mf2pt1.mp, mf2pt1.pl, mf2pt1.texi: mf2pt1 no longer generates a UniqueID automatically, only when diff --git a/Master/texmf-dist/doc/support/mf2pt1/README b/Master/texmf-dist/doc/support/mf2pt1/README index 0eb57ca8fcf..e101952ff99 100644 --- a/Master/texmf-dist/doc/support/mf2pt1/README +++ b/Master/texmf-dist/doc/support/mf2pt1/README @@ -27,7 +27,7 @@ For installation instructions, see the mf2pt1 manual (mf2pt1.pdf). Copyright and license --------------------- -Copyright (C) 2005-2021 Scott Pakin, scott+mf@pakin.org +Copyright (C) 2005-2024 Scott Pakin, scott+mf@pakin.org This package may be distributed and/or modified under the conditions of the LaTeX Project Public License, either version 1.3c of this diff --git a/Master/texmf-dist/doc/support/mf2pt1/mf2pt1.pdf b/Master/texmf-dist/doc/support/mf2pt1/mf2pt1.pdf Binary files differindex a28895171a0..e702482c745 100644 --- a/Master/texmf-dist/doc/support/mf2pt1/mf2pt1.pdf +++ b/Master/texmf-dist/doc/support/mf2pt1/mf2pt1.pdf diff --git a/Master/texmf-dist/doc/support/mf2pt1/mf2pt1.texi b/Master/texmf-dist/doc/support/mf2pt1/mf2pt1.texi index 9260689d18c..f18ed6694cf 100644 --- a/Master/texmf-dist/doc/support/mf2pt1/mf2pt1.texi +++ b/Master/texmf-dist/doc/support/mf2pt1/mf2pt1.texi @@ -11,7 +11,7 @@ @c %**end of header @copying -Copyright @copyright{} 2005--2021 Scott Pakin +Copyright @copyright{} 2005--2024 Scott Pakin @sp 2 @@ -30,8 +30,8 @@ version 2006/05/20 or later. @end copying -@set VERSION 2.7 -@set DATE 4 December 2021 +@set VERSION 2.8 +@set DATE 6 July 2024 @c Define some fonts we intend to use. @iftex @@ -679,9 +679,9 @@ parameters that @command{mf2pt1} accepts: @noindent @b{if} known @i{ps_output}: -@multitable {@b{if}} {@b{font_underline_thickness}} {@t{"Copyright (C) 2021 Scott Pakin.";}} +@multitable {@b{if}} {@b{font_underline_thickness}} {@t{"Copyright (C) 2005-2024 Scott Pakin.";}} @item @tab @b{font_coding_scheme} @tab @t{"ot1"}; -@item @tab @b{font_comment} @tab @t{"Copyright (C) 2021 Scott Pakin."}; +@item @tab @b{font_comment} @tab @t{"Copyright (C) 2005-2024 Scott Pakin."}; @item @tab @b{font_family} @tab @t{"Kerplotz"}; @item @tab @b{font_fixed_pitch} @tab @b{false}; @item @tab @b{font_identifier} @tab @t{"Kerplotz Light Oblique"}; @@ -708,7 +708,7 @@ The same parameters can also be specified on the command line as follows: @example -mf2pt1 --encoding=ot1 --comment="Copyright (C) 2021 Scott Pakin." +mf2pt1 --encoding=ot1 --comment="Copyright (C) 2005-2024 Scott Pakin." --family=Kerplotz --nofixedpitch --fullname="Kerplotz Light Oblique" --name=Kerplotz-LightOblique --designsize=10 --italicangle=-9.5 --underpos=-100 --underthick=50 --uniqueid=4112233 --version=002.005 @@ -881,7 +881,7 @@ character position the current encoding has designated for the @section Restoring @file{mfplain} defaults @command{mf2pt1} normally redefines @strong{filldraw} as @strong{fill} -and @strong{unfilldraw} and @strong{unfill} because @w{Type 1} fonts +and @strong{unfilldraw} as @strong{unfill} because @w{Type 1} fonts don't allow overlapping curves. Similarly, @command{mf2pt1} redefines @strong{pencircle} as a 20-gon to coerce MetaPost into drawing it using a filled instead of a stroked PostScript path. @@ -957,7 +957,7 @@ more robust way to dump @file{mf2pt1.mem}; for directing me to the overlap-removal code mentioned in @ref{Restrictions}; for supplying the @emph{crossproduct}, @emph{makeline}, and @emph{is_clockwise} functions used by @file{mf2pt1.mp}; for proposing the @copt{bpppix} -command-line option; and for suggesting various features and +command-line option; and for suggesting numerous features and improvements to @command{mf2pt1}. Thanks also go to Werner Lemberg and @iftex diff --git a/Master/texmf-dist/doc/support/pdfjam/VERSION b/Master/texmf-dist/doc/support/pdfjam/VERSION index ab9bd6936f4..cd7061f818c 100644 --- a/Master/texmf-dist/doc/support/pdfjam/VERSION +++ b/Master/texmf-dist/doc/support/pdfjam/VERSION @@ -1 +1 @@ -This is pdfjam 3.11 +This is pdfjam 3.12 diff --git a/Master/texmf-dist/doc/support/pdfjam/tests.zip b/Master/texmf-dist/doc/support/pdfjam/tests.zip Binary files differindex 326cc8e9096..0ff939f4b52 100644 --- a/Master/texmf-dist/doc/support/pdfjam/tests.zip +++ b/Master/texmf-dist/doc/support/pdfjam/tests.zip diff --git a/Master/texmf-dist/doc/support/pdflatexpicscale/README b/Master/texmf-dist/doc/support/pdflatexpicscale/README index 56b00b6b36c..f95ecc2dd0b 100644 --- a/Master/texmf-dist/doc/support/pdflatexpicscale/README +++ b/Master/texmf-dist/doc/support/pdflatexpicscale/README @@ -3,11 +3,11 @@ to a target resolution before creating a PDF document with PdfLaTeX. *Version* -2018-02-12 (version of bundle) +2024-10-18 (version of bundle) For version details check pdflatexpicscale.pdf. *Requirements* -Perl and ImageMagick have to be installed. +Perl and some Perl modules have to be installed - see pdflatexpicscale.pdf. *Basic usage* pdflatex article diff --git a/Master/texmf-dist/doc/support/pdflatexpicscale/pdflatexpicscale.pdf b/Master/texmf-dist/doc/support/pdflatexpicscale/pdflatexpicscale.pdf Binary files differindex 8e42d2a18ff..729034176fb 100644 --- a/Master/texmf-dist/doc/support/pdflatexpicscale/pdflatexpicscale.pdf +++ b/Master/texmf-dist/doc/support/pdflatexpicscale/pdflatexpicscale.pdf diff --git a/Master/texmf-dist/doc/support/pdflatexpicscale/pdflatexpicscale.tex b/Master/texmf-dist/doc/support/pdflatexpicscale/pdflatexpicscale.tex index e3b740a51a9..a54bf283ec7 100644 --- a/Master/texmf-dist/doc/support/pdflatexpicscale/pdflatexpicscale.tex +++ b/Master/texmf-dist/doc/support/pdflatexpicscale/pdflatexpicscale.tex @@ -5,7 +5,7 @@ \usepackage{url} \title{pdflatexpicscale} \author{Peter Willadt\footnote{willadt at t-online.de}} -\date{2018-02-12} %version #version +\date{2024-10-18} %version #version \begin{document} \maketitle @@ -54,39 +54,50 @@ scale graphics according to the output intent. \subsection{Prerequisites} -You have to install ImageMagick and Perl. If you are using Linux, please use -the tools of your distribution, if they are not already installed. As a -windows user, you may probably use the official ImageMagick distribution at -\url{http://www.imagemagick.org/script/download.php}. For Perl, you got more -options. I have tested pdflatexpicscale with ActiveState ActivePerl, but other -distributions should work too. -You also need the following Perl modules: \texttt{File::Basename}, -\texttt{File::Spec}, \texttt{File::Copy}, and \texttt{Getopt::Long}. There are -several ways to get these modules, if you have not got them already: +You \label{section:requisites} have to install Perl version~5, if it is not +installed already. If you are using Linux, I recommend to use the tools of +your distribution. As a windows user, you may probably use Strawberry Perl. +You also need the following Perl modules: +\begin{itemize} +\item \texttt{GD} (at least version 2.2), +\item \texttt{Image::ExifTool}, +\item \texttt{File::Basename}, +\item \texttt{File::Spec}, +\texttt{File::Copy}, and +\item \texttt{Getopt::Long}. +\end{itemize} + +There are no further requirements for the versions of the software to install, +but it may be wise to use recent releases. +There are several ways to get these modules, if you have not got them +already. The most popular are probably: \begin{itemize} \item use your Linux distribution's software manager \item use the Perl CPAN module -\item use ActiveState's \texttt{ppm} software, if you use ActivePerl. +\item use ActiveState's \texttt{ppm} software, if you happen to use + ActivePerl. \end{itemize} -Detailled description of these procedures is beyond the scope of this -document. +Detailed description of these procedures is beyond the scope of this +document. -There are no special requirements for the versions of the software to install, -but it may be wise to use recent versions, as there have been security flaws -with ImageMagick. +As of 2024, no further external software is needed, in contrast to earlier +versions. \subsection{Installation} -If the prerequisites have been fulfilled (which is perhaps standard for a -Linux computer), it is sufficient to move the file -\texttt{pdflatexpicscale.pl} to a place that is included in your PATH and to -make it executable. Of course, there are alternatives. You may perhaps -prefer to type\\ +If pdflatexpicscale.pl is part of your \TeX\ distribution, +chances are good that you only have to install missing Perl modules, if +any. Otherwise the following should apply: + +Having installed Perl and the required modules, it is sufficient to move +the file \texttt{pdflatexpicscale.pl} to a place that is included in your PATH +and to make it executable. Of course, there are alternatives. You may perhaps +prefer to type the following instead: + \texttt{perl /path/to/pdflatexpicscale.pl myarticle}\\ -instead. \section{Basic usage} @@ -127,7 +138,8 @@ Some other text... You hopefully do not have distinct pictures with the same name in the listed folders. With \verb|\graphicspath| you have to use double braces, even if you -use only one directory. +use only one directory. The best place for the \verb|\graphicspath| statement +is probably near the beginning of your \LaTeX\ file. \subsection{Preparing your \LaTeX\ file, Part~2} @@ -172,7 +184,7 @@ again on \texttt{myarticle}. I have told you to use double braces with \verb|\graphicspath|, haven't I? If you still are curious, you can again check the size of \texttt{myarticle.pdf}. -When it gets to preparing a print version, you create a directory for images +When it is time to prepare a print version, you create a directory for images with more detail, say \texttt{printpix}. You reset the \verb|\graphicspath|, run Pdf\LaTeX, issue\\ \texttt{pdflatexpicscale --printdpi=300 --destdir=printpix myarticle}\\ @@ -180,11 +192,10 @@ and set \verb|\graphicspath{{printpix/}}| before the next Pdf\LaTeX\ run. \section{Advanced usage} - \subsection{Excluding files from scaling} You will probably exclude files from scaling when you think that scaling will -do damage. You may achieve this by several means. Before you ask. Enumerating +harm. You may achieve this by several means. Before you ask: Enumerating files to exclude is not really cool, so this is not supported. \begin{enumerate} @@ -208,6 +219,19 @@ directories. Before the first \LaTeX\ run, you say\\ and after pdflatexpicscale is through, you change it to\\ \verb|\graphicspath{{hires/}{printimg/}}| +\subsection{Monochrome Images} + +While \label{section:monochrome}Pdf\TeX\ supports JBIG2 files, +pdflatexpicscale does not. Scaling JBIG2 files down looks like a bad idea, +anyway. + +Scaling monochrome\footnote{\emph{Monochrome} in the technical sense of one + bit per pixel as opposed to grayscale or color images that use only one + color.} images may lead to bad results. I recommend converting them to +grayscale before scaling, as blurred details are perhaps better than missing +details. pdflatexpicsacle will scale B/W images only if their resolution is at +least two times higher as requested. + \subsection{Gory details} pdflatexpicscale reads the log file, not the \LaTeX\ source. So you have to @@ -256,12 +280,16 @@ pictures remain unscaled because they are near the target resolution. Default is 20, that means 20~percent. If target resolution is 300~dpi, files up to 320~dpi get accepted too. Change to 0 if you want no tolerance. +\paragraph{draft/final} Setting one of these options will use reasonable +defaults, if you do not want to use any of the further options. +Please call \texttt{pdflatexpicscale.pl --help} to see concrete values. + \paragraph{verbose} entertains you by showing what the program is about to do. \paragraph{version} shows the software version. -Calling pdflatexpicscale without any options and without a project name will +Calling pdflatexpicscale.pl without any options and without a project name will display a short usage text. \subsection{Printer testing} @@ -335,5 +363,23 @@ this document, the option \texttt{tolerance} had been listed as As the TUGboat article corresponding to pdflatexpicscale is freely available now, the link on page~\pageref{tugboatart} has been adjusted. +\paragraph{2024-10-18} + +Added section~{section:monochrome} with hints for B/W images to +documentation. Also did some minor edits, especially to accompany the +following changes (see section~\ref{section:requisites}). + +As there have been issues with ImagMagick, pdflatexpicscale no longer uses +external software; Perl's GD and Image::ExifTool modules are used instead. + +Added new shortcut options \texttt{--draft} and \texttt{--final}. + +Refactored pdflatexpicscale.pl, hopefully without bad side effects. + % for file version please see line 8 \end{document} + +%%% Local Variables: +%%% mode: latex +%%% TeX-master: t +%%% End: diff --git a/Master/texmf-dist/doc/support/pdflatexpicscale/testprinter.ps b/Master/texmf-dist/doc/support/pdflatexpicscale/testprinter.ps index 900fe5dc8e9..71856a45e4a 100644 --- a/Master/texmf-dist/doc/support/pdflatexpicscale/testprinter.ps +++ b/Master/texmf-dist/doc/support/pdflatexpicscale/testprinter.ps @@ -4,7 +4,7 @@ % PostScript by Example. % First printing, 1992, P. 544 ff % Willadt 2016-07-27 -% version 2018-02-12 #version %version +% version 2024-10-18 #version %version % for information on usage and changes see pdflatexpicscale.pdf /prozente 20 string def diff --git a/Master/texmf-dist/doc/support/sqltex/SQLTeX.pdf b/Master/texmf-dist/doc/support/sqltex/SQLTeX.pdf Binary files differnew file mode 100644 index 00000000000..050e48021df --- /dev/null +++ b/Master/texmf-dist/doc/support/sqltex/SQLTeX.pdf diff --git a/Master/texmf-dist/doc/support/sqltex/SQLTeX.tex b/Master/texmf-dist/doc/support/sqltex/SQLTeX.tex new file mode 100644 index 00000000000..d3fbc8d6673 --- /dev/null +++ b/Master/texmf-dist/doc/support/sqltex/SQLTeX.tex @@ -0,0 +1,1050 @@ +\documentclass{article} +\newcommand{\bs}{\ensuremath{\backslash}} +\newcommand{\vs}{\vspace{3mm}} +\newcommand{\sqltexversion}{3.0} +\newcommand{\sqltexvmsversion}{3\_0} +\usepackage{makeidx} +\usepackage[pdftex + ,pagebackref=true + ,colorlinks=true + ,linkcolor=blue + ,unicode]{hyperref} +\begin{document} +\title{SQL\TeX\ v\sqltexversion} +\date{Sep 20, 2024} +\author{Oscar van Eijk} +\maketitle +\hrulefill +\tableofcontents +\hrulefill + +\section{Introduction} + +SQL\TeX\ is a preprocessor to enable the use of SQL statements in \LaTeX. It is a perl script that reads +an input file containing the SQL commands, and writes a \LaTeX\ file that can be processed with your +\LaTeX\ package. + +The SQL commands will be replaced by their values. It's possible to select a single field for substitution +substitution in your \LaTeX\ document, or to be used as input in another SQL command. + +When an SQL command returns multiple fields and or rows, the values can only be used for substitution +in the document. + +\subsection{Known limitations} + +\begin{itemize} +\item The \LaTeX\ \texttt{\bs includeonly} directive is ignored; all documents included with \texttt{\bs include} will be parsed and written to the output file. +\item Currently, only 9 command- line parameters (1-9), and 10 variables (0-9) can be used in SQL statements. +\item Replace files can hold only 1,000 items. +\end{itemize} + +\section{Installing SQL\TeX} + +Since v3.0, SQL\TeX\ is part of \TeX\ Live and doesn't need further installation. \\ +If you are using a different LaTeX distro, please follow the steps below for your OS. + +Before installing SQL\TeX, you need to have it. The latest version can always be found at +\url{https://github.com/oveas/sqltex}. +The download consists of this do\-cumentation, an installation script for Unix +(\texttt{install}), and the Perl script \texttt{sqltex}, and a replace- file (\texttt{SQLTeX\_r.dat}) for manual installation +on non- unix platforms\footnote{on Unix, this file will be generated by the install script}. + +\subsection{Requirements} + +SQL\TeX\ requires the following software: + +\begin{itemize} +\item Perl v5.10 or higher (\url{http://perl.org/}) +\item Perl-DBI (\url{http://dbi.perl.org/}) +\item The DBI driver for your database\\(see: \url{http://search.cpan.org/search?query=DBD\%3A\%3A\&mode=module}) +\item Getopt::Long (\url{https://metacpan.org/pod/Getopt::Long}) +\item Term::ReadKey (\url{https://metacpan.org/pod/Term::ReadKey}) +\end{itemize} + +\subsection{Installation} + +If you are using a \TeX\ Live distribution, SQL\TeX\ is already available. For all other distros, follow the steps in this section. + +\vs + +First unpack the archive in a location of your choice and continue with one if the subsections below depending on you operating system. + +\subsubsection{Linux} + +Go to the top directory where the archive was unpacked (`\texttt{cd sqltex-\sqltexversion}') and execute the following commands: + +\vs + +\noindent\texttt{\$ ./configure \textit{[options]}\\ +\$ make \\ +\$ \textit{[sudo] }make install} + +\vs + +In the last command, \texttt{sudo} is only required if the install destination (\texttt{PREFIX}, see below) is outside the own user environment. + +\vs + +For \texttt{configure}, the following options are user buy SQL\TeX\ (type \texttt{./configure --help} for a full list): + +\begin{description} +\item[\texttt{--prefix=PREFIX}] install architecture-independent files in PREFIX. Default is \texttt{/usr/local}. +\item[\texttt{--exec-prefix=EPREFIX}] install architecture-dependent files in EPREFIX. Default is \texttt{PREFIX}. +\end{description} + +The directives above are used by the ones below: + +\begin{description} +\item[\texttt{--bindir=DIR}] Location of the SQL\TeX\ script. Default is \texttt{EPREFIX/bin} +\item[\texttt{--sysconfdir=DIR}] Location of the Configuration- and replacefiles. Default is \texttt{PREFIX/etc} +\item[\texttt{--datarootdir=DIR}] Data root, used by the directives below. Default is \texttt{PREFIX/share} +\item[\texttt{--mandir=DIR}] Location of the SQL\TeX\ manpage. Default is \texttt{DATAROOTDIR/man} +\item[\texttt{--docdir=DIR}] Documentation root, used by \texttt{pdfdir} below. Default is \texttt{DATAROOTDIR/doc/sqltex} +\item[\texttt{--pdfdir=DIR}] Location of SQL\TeX.pdf. Default is \texttt{DOCDIR} +\end{description} + +\vs + +After installation, the archive and unpack- directory can be removed. + +\subsubsection{Windows} + +\noindent\hspace{-3mm}\textit{\underline{Note:}}Since v3.0, the binary \texttt{SQLTEX.EXE} for Windows is not included in the distribution anymore\footnote{ It can be generated with any (portable) perl version for Windows, like Strawberry Perl (\url{https://strawberryperl.com/}\label{winexe}), with \texttt{PAR::Packer} (\url{https://metacpan.org/pod/PAR::Packer}) using the command:\\ +\texttt{pp -o sqltex.exe sqltex}} + +\vs + +The files \texttt{sqltex-\sqltexversion\ensuremath{\backslash}sqltex}, \texttt{sqltex-\sqltexversion\ensuremath{\backslash}src\ensuremath{\backslash}SQLTeX.cfg} and \\ \texttt{sqltex-\sqltexversion\ensuremath{\backslash}src\ensuremath{\backslash}SQLTeX\_r.dat} must be placed manually in the directory of your choice, all in the same direcrtory. + + +\subsubsection{OpenVMS} + +On \textsc{OpenVMS} the files must be copied manually to the destination. All files must reside in the same location:\\ +\texttt{\$ COPY [.SQLTEX-\sqltexvmsversion.SRC]SQLTEX. SYS\$SYSTEM:SQLTEX.PL\\ +\$ COPY [.SQLTEX-\sqltexvmsversion.SRC]SQLTEX.CFG SYS\$SYSTEM:\\ +\$ COPY [.SQLTEX-\sqltexvmsversion.SRC]SQLTEX\_R.DAT SYS\$SYSTEM:\\ +\$ SET FILE/PROTECTION=(W:RE) SYS\$SYSTEM:SQLTEX.PL} + +\vs + +Next, define the command \texttt{SQLTEX} by setting a symbol, +either in the \texttt{LOGIN.COM} for all users who need to execute this script, or in some group-- or +system wide login procedure, with the command: \\ +\texttt{\$ SQLTEX :== "PERL SYS\$SYSTEM:SQLTEX.PL"} + +\subsection{Configuration}\label{config} + +The configuration file \texttt{SQLTeX.cfg} is located in \texttt{/usr/local/etc} (linux) or the same location where SQL\TeX\ is installed (all other operating systems and in \TeX\ Live distros)\footnote{ If a 1.x version of SQL\TeX\ is installed on your system, make sure you save the configuration section, which was inline in older versions}. +Multiple configuration files can be created, the command line option \texttt{--configfile} can be used to +select the requested configuration. + +\vs + +\noindent\hspace{-3mm}\textit{\underline{Note:}}\label{cfg:disable} Use of the \texttt{--configfile} commandfile option can be disabled on system wide installations. To do so, the script \texttt{sqltex} must be modified.\\ +At the top of the file (line 4), set the value for \texttt{\$main::ext\_cfgfile\_allowed} to \texttt{0}. + +\vs + +Some values can be overwritten using command line options (see section~\ref{cmdline}). When the command line options are omitted, the values from the requested configuration file will be used. + +\begin{description} + +\item[dbdriver] Database driver. The default is \texttt{mysql}. +Other supported databases are \texttt{Pg}, \texttt{Sybase}, \texttt{Oracle}\footnote{ This requires the configuration setting \texttt{oracle\_sid}}, \texttt{Ingres}, \texttt{mSQL}, \texttt{PostgreSQL} and \texttt{ODBC}\footnote{ The actual driver can specified with the configuration setting \texttt{odbc\_driver}}, but also others might work without modification. \\ + +\vs + +If your database driver is not support, look for the function +\texttt{db\_connect} to add support (and please notify me :) + +\item[oracle\_sid] Oracle Site Identifier, required when the \texttt{Oracle} database driver is selected. + +\item[odbc\_driver] Specification of the ODBC driver. Default is ``\texttt{SQL Server}'' + + +\item[texex] The default file extension for \LaTeX\ file. When SQL\TeX\ is called, the first +parameter should be the name of the input file. If this filename has no extension, +SQL\TeX\ looks for one with the default extension. + +\item[stx] An output file can be given explicitly using the `\texttt{--output}' option. When omitted, +SQL\TeX\ composes an output file name using this string.\\ +E.g, if your input file is called \texttt{db-doc.tex}, SQL\TeX\ will produce an +outputfile with the name \texttt{db-docstx.tex}. + +\item[def\_out\_is\_in] By default, when no output file is specified or an output file without (relative) path is given, the output file will be generated in the current directory.\\ +This behaviour changed in version 2.1. In older version, the location of the output file always was the same as the input file location. To revert to the old behaviour, set \texttt{def\_out\_is\_in} to `\texttt{1}'\footnote{ Note the pre-v2.1 implementation also contained a bug: if the output file name contained an absolute or relative path, this path was always taken as relative from the input file location. In the new implementation, \texttt{def\_out\_is\_in} is ignored if the output file name contains a path.}. + +\item[multi\_rfile]If the commandline option \texttt{--replacementfile} is given, by default the given replacement file will be parsed and after that the default replacement file will be parsed as well.\\ +If only the given replacement file should be parsed skipping the default file, set this value to \texttt{0}. + +\item[rfile\_comment] The comment-sign used in replace files. If this is empty, comments are not allowed in +the replace files. + +\item[rfile\_regexploc] This must be part of the value \texttt{rfile\_regexp} below. + +\item[rfile\_regexp] Explains how a regular expression is identified in the replace files (see section~\ref{regexp}). + +\item[cmd\_prefix]\label{prefix} SQL\TeX\ looks for SQL commands in the input file. Commands are specified in the +same way all \LaTeX\ commands are specified: a backslash (\bs) followed by the +name of the command.\\ +All SQL\TeX\ commands start with the same string. By default, this is the string +\texttt{\textbf{sql}}. When user commands are defined that start with the same +string, this can be changed here to prevent conflicts. + +\item[sql\_open] This string is appended to the \texttt{cmd\_prefix} to +get the complete SQL\TeX\ command for opening a database.\\ +With the default configuration this command is ``\texttt{\bs sqldb}''. + +\item[sql\_field] This string is appended to the \texttt{cmd\_prefix} to +get the complete SQL\TeX\ command to read a single field from the database.\\ +With the default configuration this command is ``\texttt{\bs sqlfield}''. + +\item[sql\_row] This string is appended to the \texttt{cmd\_prefix} to +get the complete SQL\TeX\ command to read one or more rows from the database.\\ +With the default configuration this command is ``\texttt{\bs sqlrow}''. + +\item[sql\_params] This string is appended to the \texttt{cmd\_prefix} to get the complete SQL\TeX\ command to retrieve a list if fields that will be used as parameters (\texttt{\$PAR1}, see section~\ref{params}) in the multidocument environment (see section~\ref{multidoc}).\\ +With the default configuration this command is ``\texttt{\bs sqlparams}''. + +\item[sql\_update] This string is appended to the \texttt{cmd\_prefix} +to get the complete SQL\TeX\ command to update one or more rows in the database.\\ +With the default configuration this command is ``\texttt{\bs sqlupdate}''. + +\item[sql\_start] This string is appended to the \texttt{cmd\_prefix} to get the complete SQL\TeX\ command start a section that will be repeated for every row from an array (see section~\ref{loops}).\\ +With the default configuration this command is ``\texttt{\bs sqlstart}''. + +\item[sql\_use] This string is appended to the \texttt{cmd\_prefix} to get the complete SQL\TeX\ command use a named variable from the array that is currently being processed in a loop context (see section~\ref{loops}).\\ +With the default configuration this command is ``\texttt{\bs sqluse}''. + +\item[sql\_end] This string is appended to the \texttt{cmd\_prefix} to get the complete SQL\TeX\ command to end a loop context (see section~\ref{loops}).\\ +With the default configuration this command is ``\texttt{\bs sqlend}''. + +\item[sqlsystem\_allowed] Set this to ``1'' to allow the use of the \texttt{\bs sqlsystem} command (see section~\ref{sqlsystem}). + +\item[repl\_step] Replacing strings (see section~\ref{replfiles} below) is done two steps, to prevent values from being replaced twice. +This setting---followed by a three-digit integer - ``000'' to ``999''---is used in the first step and replaces values from the first column. +In the second step, values from the second column replace the temporary value. \\ +If the first column in the replace file contains a character sequence that occurs in this temporary value, or if query results might contain the full string followed by three digits, this value might need to be changed in something unique. + +\item[alt\_cmd\_prefix] In loop context, this setting is used internally to differentiate between sql statements to process immediately and sql statements on stack.\\ +Normally, this setting should never change, but if the value for \texttt{cmd\_prefix} has been changed and a conflict is found, the message ``\texttt{Configuration item 'alt\_cmd\_prefix' cannot start with \textit{<conflicting value>}}'' indicates this setting should change as well. + +\end{description} + +\subsection{Create replace files}\label{replfiles} + +Replace files can be used to substitute values in the output of your SQL commands with a different value. This is especially useful when the database +contains characters that are special characters in \LaTeX, like the percent sign (`\%'), underscore (`\_') etc. + +When SQL\TeX\ is installed, it comes with a standard file---\texttt{SQLTeX\_r.dat}---which is located in \texttt{/usr/local/etc}\footnote{ if a replace file with that name already exists, it will be stored there as \texttt{SQLTeX\_r.dat.new}} (linux) or the same location where SQL\TeX\ is installed (all other operating systems and in \TeX\ Live distros). + +\vspace{3mm} + +\noindent Example: +\begin{verbatim} +$ \$ +_ \_ +% \% +& \& +< \texttt{<} +> \texttt{>} +{ \{ +} \} +# \# +~ \~{} +\ \ensuremath{\backslash} +\end{verbatim} + +\vspace{3mm} + +These are all single character replacements, but you can add your own replacements that consist of a single character or a character sequence (or even regular expressions, see section~\ref{regexp}). + +\vs + +To do so, enter a new line with the character(string) that should be replaced, followed by one or more \texttt{TAB}-character(s) (\textit{not} blanks!) and the character(string) it should be replaced with.\\ +That last one can be empty if the input character(string) should be ignored, but the \texttt{TAB} after the input character(string) is mandatory! + +\vs + +If the first non-blank character is a semicolon (`;'), the line is considered a comment line\footnote{ in the default configuration. See the description for \texttt{rfile\_comment} in section~\ref{config} to change of disable comment lines.}. Blank lines are ignored. + +\vspace{3mm} + +The contents of the file are case sensitive, so of you add the line: \\ +\verb+LaTeX \LaTeX\+ \\ +the word ``LaTeX'' will be changed, but ``latex'' is untouched. + +\vspace{3mm} + +Different replace files can be created. To select a different replace file for a certain SQL\TeX\ source, use the commandline option +`\texttt{--replacementfile \textit{filename}}'. To disable the use of replace files, use `\texttt{no-replacementfile}'. + +\subsubsection{Regular expressions}\label{regexp} + +The replace file can include regular expressions, which are recognized by a pattern given in the configuration setting \texttt{rfile\_regexp}. A part of the pattern, configurable as \texttt{rfile\_regexploc}, will be the actual regular expression. + +\vs + +By default, \texttt{rfile\_regexploc} is ``\texttt{...}'' and \texttt{rfile\_regexp} is ``\texttt{re(...)}''. If the sequence of three dots can appear anywhere else in the replace file, \texttt{rfile\_regexploc} can be changed to any other sequence of characters, e.g. ``\texttt{regexpHere}''.\\ +This also requires \texttt{rfile\_regexp} to be changed. Its new value has to be ``\texttt{re(regexpHere)}'' + +\vs + +Both in the default configuration and with the modification example given above, the key for regular expressions is \texttt{re(<\textit{regular expression}>)}, e.g.:\\ +\hspace{3mm}\verb+re(<p.*?>) \paragraph*{}+ \\ +will replace all HTML \texttt{<}p\texttt{>} variants (\texttt{<}p style='font-size: normal'\texttt{>}, \texttt{<}p align='center'\texttt{>} etc) + +\vs + +An example replacement file using regular expressions to handle HTML codes could look like this: + +\noindent\begin{verbatim} +& \& +<strong> \textbf{ +</strong> } +<em> \textit{ +</em> } +re(<br.*?/?>) \\ +re(<p.*?>) \paragraph*{} +</p> \\[0pt] +<sup> $^{ +</sup> }$ +re(<span.*?>) \textsl{ +</span> } +re(<h1.*?>) \section{ +re(<h2.*?>) \subsection{ +re(<h3.*?>) \subsubsection{ +re(</h\d>) } +\end{verbatim} + +\section{Write your SQL\TeX\ file} + +For SQL\TeX, you write your \LaTeX\ document just as you're used to. SQL\TeX\ provides you with +some extra commands that you can include in your file.\\ +The basic format\footnote{in this document, in all examples will be assumed the default values in the +configuration section as described in section~\ref{config}, have not been changed} of an SQL\TeX\ command is: \\ +\texttt{\bs sql\emph{cmd}[options]\{SQL statement\}} + +\vs + +All SQL\TeX\ commands can be specified anywhere in a line, and can span multiple lines. +When SQL\TeX\ executes, the commands are read, executed, and their results---if they return +any---are written to the output: + +\vs + +\begin{minipage}[t]{0.5\textwidth}\textsl{Input file:}\\\texttt{\footnotesize{\bs documentclass[article] \\ +\bs pagestyle\{empty\} \\ +\bs sqldb[oscar]\{mydb\} \\ +\bs begin\{document\} \\ +}}\end{minipage}\hfill\begin{minipage}[t]{0.5\textwidth}\textsl{Output file:}\\\texttt{\footnotesize{\bs documentclass[article] \\ +\bs pagestyle\{empty\} \\ + \\ +\bs begin\{document\} \\ +}}\end{minipage} + +\vs + +Above you see the SQL\TeX\ command \texttt{\bs sqldb} was removed. Only the command was removed, not +the \textsl{newline} character at the end of the line, so an empty line will be printed instead. +The example below shows the output if an SQL\TeX\ command was found on a line with other \LaTeX\ +directives: + +\vs + +\begin{minipage}[t]{0.5\textwidth}\textsl{Input file:}\\\texttt{\footnotesize{\bs documentclass[article] \\ +\bs pagestyle\{empty\}\bs sqldb[oscar]\{mydb\} \\ +\bs begin\{document\} \\ +\hrulefill}}\end{minipage}\hfill\begin{minipage}[t]{0.5\textwidth}\textsl{Output file:}\\\texttt{\footnotesize{\bs documentclass[article] \\ +\bs pagestyle\{empty\} \\ +\bs begin\{document\} \\ +}}\end{minipage} + +\vs + +In these examples the SQL\TeX\ commands did not return a value. When commands actually read from +the database, the returned value is written instead: + +\vs + +\begin{minipage}[t]{0.5\textwidth}\textsl{Input file:}\\\texttt{\footnotesize{This invoice has \bs sqlfield\{SELECT COUNT(*) FROM INVOICE\_LINE \\ +WHERE INVOICE\_NR = 20190062\} lines.\\ +\hrulefill}}\end{minipage}\hfill\begin{minipage}[t]{0.5\textwidth}\textsl{Output file:}\\\texttt{\footnotesize{This invoice has 3 lines \\ +}}\end{minipage} + +\subsection{SQL statements}\label{sqlstatements} + +This document assumes the reader is familiar with SQL commands. This section only tells something about +implementing them in SQL\TeX\ files, especially with the use of command parameters and variables. +Details about the SQL\TeX\ commands will be described in the next sections. + +\vs + +Let's look at a simple example. Suppose we want to retrieve all header information from the database +for a specific invoice. The SQL statement could look something like this: \\ +\texttt{SELECT $\ast$ FROM INVOICE WHERE NR = 20190062;}\\ +To implement this statement in an SQL\TeX\ file, the \texttt{\bs sqlrow} command should be used (see +section~\ref{sqlrow}): + +First, it is important to know that SQL statements should \textit{not} contain the ending semicolon (;) in +any of the SQL\TeX\ commands. The command in SQL\TeX\ would be:\\ +\texttt{\bs sqlrow\{SELECT $\ast$ FROM INVOICE WHERE NR = 20190062\}} + +Next, SQL\TeX\ would be useless if you have to change your input file every time you want to generate +the same document for another invoice. + +\vs + +Therefore, you parameters or variables can be used in your SQL statement. Parameters are given at the command +line (see section~\ref{params}), variables can be defined using the \texttt{\bs sqlfield} command as +described in section~\ref{vars}. + +Given the example above, the invoice number can be passed as a parameter by rewriting the command as: \\ +\texttt{\bs sqlrow\{SELECT $\ast$ FROM INVOICE WHERE NR = \$PAR1\}} \\ +or as a variable with the code line: \\ +\texttt{\bs sqlrow\{SELECT $\ast$ FROM INVOICE WHERE NR = \$VAR0\}} + +Note you have to know what datatype is expected by your database. In the example here the datatype is +\textsc{integer}. If the field ``\textsc{invoice\_nr}'' contains a \textsc{varchar} type, the +\texttt{\$PAR}ameter or \texttt{\$VAR}iable should be enclosed by quotes: \\ +\texttt{\bs sqlrow\{SELECT $\ast$ FROM INVOICE WHERE NR = '\$PAR1'\}} + +\subsection{Opening the database}\label{opendb} + +Before any information can be read from a database, this database should be opened. +This is done with the \texttt{\textbf{\bs sqldb}} command. +\texttt{\bs sqldb} requires the name of the dabatase. Optionally, a username, password and remote database host can be given. \\ +The format of the command is:\\ +\texttt{\bs sqldb[user=\textit{username},passwd=\textit{password},host=\textit{host}]\{database\}} + +The command can be used anywhere in your input file, but should occur before the first command that tries to +read data from the database. + +\vs + +If the keywords \texttt{user}, \texttt{passwd} and \texttt{host} are omitted, SQL\TeX\ assumes the options are given in +this order:\\ +\texttt{\bs sqldb[\textit{username},\textit{password},\textit{host}]\{database\}} + +Default host is localhost, the default user is the current user. + +\vs + +\noindent\hspace{-3mm}\textit{\underline{Note:}} The \texttt{\bs sqldb} command cannot span multiple lines! + +\subsubsection{Prompt for password and/or username} + +If a password is omitted, SQL\TeX\ will try connect to the database without a password, unless the commandline option \texttt{--password} is given (see section \ref{cmdline}). + +\vs + +Forcing a user to enter a database password when SQL\TeX\ runs can be achieved by specifying \texttt{?} as password:\\ +\texttt{\bs sqldb[user=dbUser,passwd=?]\{database\}} + +\vs + +When different database users should be able to use the same SQL\TeX\ file, the username can also be a question mark, forcing SQL\TeX +to prompt for a username:\\ +\texttt{\bs sqldb[user=?,passwd=?]\{database\}} + +\subsection{Reading a single field}\label{sqlfield} + +When a single field of information is to be read from the database, the command \texttt{\textbf{\bs sqlfield}} +is used. By default, the command in the input file is replaced by its result in the output file.\\ +The SQL command is enclosed by curly braces. Square brackets can optionally be used to enter some extra options. +Currently, the only supported option is \texttt{setvar} (see section~\ref{vars}). + +The full syntax or the \texttt{\bs sqlfield} command is:\\ +\texttt{\bs sqlfield[\textit{options}]\{SELECT \textit{fieldname} FROM \textit{tablename} WHERE \textit{your where-clause}\}} \\ +By default, the SQL\TeX\ command is replaced with the value returned by the SQL query. This behaviour +can be changed with options. + + +\subsubsection{Define variables}\label{vars} + +The \texttt{\bs sqlfield} can also be used to set a variable. The value returned by the SQL query is not +displayed in this case. Instead, a variable is created which can be used in any other SQL query later in +the document (see also section~\ref{sqlstatements}). + +Therefore, the option \texttt{\textbf{[setvar=\textit{n}]}} is used, where \textit{n} is an integer between +0 and 9. + +\vs + +Suppose you have an invoice in \LaTeX. SQL\TeX\ is executed to retrieve the invoice header information +from the database for a specific customer. Next, the invoice lines are read from the database. + +You could pass the invoice number as a parameter to SQL\TeX\ for use in your queries, but that could +change every month. It is easier to :\\ +\begin{itemize} +\item pass the customer number as a parameter, +\item retrieve the current date (assuming that is the invoice date as stored in +the database by another program), and store it in a variable: \\ +\texttt{\bs sqlfield[setvar=0]\{SELECT DATE\_FORMAT(NOW(), "\%Y-\%m-\%d")\}} \\ +This creates a variable that can be used as \texttt{\$VAR0}, +\item retrieve the invoice number using the customer number (a command line parameter, +see also section~\ref{params}) and the variable containing the invoice date. +Store this invoice number in \texttt{\$VAR1}: \\ +\texttt{\bs sqlfield[setvar=1]\{SELECT NR FROM INVOICES \\ +WHERE CUST\_NR = '\$PAR1' AND INVOICE\_DATE = '\$VAR0'\}} +\item use \texttt{\$VAR1} to retrieve all invoice information. +\end{itemize} + +\vs + +The SQL queries used here do not display any output in your \LaTeX\ document. + + +\subsection{Reading rows of data}\label{sqlrow} + +When an SQL query returns more information than one single field, the SQL\TeX\ +command \texttt{\textbf{\bs sqlrow}} should be used. As with the \texttt{\bs sqlfield}, +command, SQL\TeX\ replaces the command with the values it returns, but \texttt{\bs sqlrow} +accepts different options for formatting the output. + +\vs + +By default, fields are separated by a comma and a blank (`\texttt{,~}'), and rows by +a newline character (`\texttt{\bs\bs}'). To change this, the options ``\texttt{fldsep}'' +and ``\texttt{rowsep}'' can be used. + +e.g. In a \texttt{tabular} environment the fields should be separated by an ampersand (\texttt{\&}), +perhaps a line should separate the rows of information. (\texttt{\bs\bs~\bs hline}). +To do this, the options can be used with \texttt{\bs sqlrow} as shown here: \\ +\texttt{\bs sqlrow[fldsep=\&,rowsep=\bs\bs~\bs hline]\{SELECT I.NR, A.NR, +A.PRICE, I.AMOUNT, (A.PRICE * I.AMOUNT) FROM ARTICLE A, INVOICE\_LINE I WHERE I.NR = \$VAR1 +AND I.ARTICLE\_NR = A.NR\}} + +\vs + +This will produce an output like: \\ +\texttt{1 \& 9712 \& 12 \& 1 \& 12 \bs\bs~\bs hline +2 \& 4768 \& 9.75 \& 3 \& 29.25 \bs\bs~\bs hline +3 \& 4363 \& 1.95 \& 10 \& 19.5 \bs\bs~\bs hline +4 \& 8375 \& 12.5 \& 2 \& 25 \bs\bs~\bs hline} + +\subsubsection{Output rows on separate lines} + +Some \LaTeX\ packages require input on a separate line. If this output is to be +read from a database, this can be set with the \texttt{rowsep} option using the +fixed text ``\texttt{NEWLINE}''. + +Changing the example from section \ref{sqlrow} above to:\\ +\texttt{\bs sqlrow[fldsep=\&,rowsep=\bs\bs~\bs hline NEWLINE]\{SELECT I.NR, A.NR, +A.PRICE, I.AMOUNT, (A.PRICE * I.AMOUNT) FROM ARTICLE A, INVOICE\_LINE I WHERE I.NR = \$VAR1 +AND I.ARTICLE\_NR = A.NR\}} + +\vs + +would produce the following result: \\ +\texttt{1 \& 9712 \& 12 \& 1 \& 12 \bs\bs~\bs hline \\ +2 \& 4768 \& 9.75 \& 3 \& 29.25 \bs\bs~\bs hline \\ +3 \& 4363 \& 1.95 \& 10 \& 19.5 \bs\bs~\bs hline \\ +4 \& 8375 \& 12.5 \& 2 \& 25 \bs\bs~\bs hline} + + + +\subsubsection{Store data in an array} + + +The \texttt{\bs sqlrow} command can also be used to store the data in an array. The value returned by the SQL query is not displayed in this case. Instead, an array is created which can be used later in the document in a loop context (see section~\ref{loops}). + +Therefore, the option \texttt{\textbf{[setarr=\textit{n}]}} is used, where \textit{n} is an integer between +0 and 9. + +\subsection{Loop context}\label{loops} + +In a loop context, an array is filled with data from the database using \texttt{\bs sqlrow}.\\ +Later in the document, the data can be used in a text block that will be written to the output file once for every record retrieved. + +\vs + +The text block is between the \texttt{\bs sqlstart\{\textit{n}\}} and \texttt{\bs sqlend\{\textit{n}\}} commands, where \textit{n} is the sequence number of the array to use\footnote{ in \texttt{\bs sqlend}, the sequence number is ignored, but required by syntax.}. + +Multiple text blocks can occur in the document, but they can \textit{not} be nested! + +\vs + +In the example below, data for unpaid invoices is stored in an array identified with sequence number 0: + +\texttt{\bs sqlrow[setarr=0]\{SELECT I.NR AS nr\\ +\hspace*{15mm}, I.DUE\_DATE AS date\\ +\hspace*{15mm}, I.TOTAL AS amount\\ +\hspace*{15mm}, C.NAME AS customer\\ +\hspace*{15mm}FROM INVOICE I\\ +\hspace*{15mm}LEFT OUTER JOIN CUSTOMER C\\ +\hspace*{20mm}ON C.NR = I.CUST\_NR\\ +\hspace*{15mm}WHERE I.PAY\_DATE IS NULL\}} + +\vs + +To use this data, a text block must start with: \texttt{\bs sqlstart\{0\}}\\ +Between this command and the first occurrence of \texttt{\bs sqlend\{\}}, an unlimited amount\footnote{ limited by your computer's memory only} of \LaTeX\ text can be written. Within this text, every occurrence of \texttt{\bs sqluse\{<\textit{field name}>\}} will be replaced with the matching field from the current row, e.g.: + +\noindent\begin{verbatim} +\sqlstart{0} +\begin{flushright} +Regarding: invoicenumber \sqluse{nr} +\end{flushright} + +Dear \sqluse{customer}, + +On \today, the invoice with number \sqluse{nr}, payable before +\sqluse{date}, was not yet received by us. + +We kindly request you to pay the amount of \texteuro\sqluse{amount} +as soon as possible. + +\newpage +\sqlend{} +\end{verbatim} + +\subsubsection{If-endif control block} + +In the loop context, parts of the document can be enabled if certain conditions are met, using a control block with \texttt{\bs sqlif\{\textit{condition(s)}\}} and \texttt{\bs sqlendif\{\}}. + +\vs + +\textit{Conditions} can be up to 2 conditions separated by an \textit{and} (\texttt{\&\&}) or \textit{or} (\texttt{||}). + +The condition(s) consist of an left value and an right value seperated by 1 of the following comparisson operators: `\texttt{==}', `\texttt{!=}', `\texttt{<}',. `\texttt{>}', `\texttt{<=}' or `\texttt{>=}'.\\ +Numeric values will be used as is. When the value is text, it is expected to be the name of a field and `\texttt{\bs sqluse\{\}}` will be called to retrieve the value. +\vs + +\noindent Example:\\ +\texttt{\bs sqlif\{article\_nr == 123 \&\& \bs stock < 5\}\\ +Stock is below threshold, please reorder. +}\\ +\bs sqlendif\{\} + +\vs + +Note the conditions are very basic with the following limitations: +\begin{itemize} +\item A maximum of 2 conditions is supported per if-statement. +\item Only numeric comparissons are supported. +\item If-elsif blocks cannot be nested. +\end{itemize} + +When checks are needed that are not supported by SQL\TeX, a workaround can be implemented in the SQL code. + + +\subsection{Get input from external programs}\label{sqlsystem} + +The \texttt{\bs sqlsystem} command can be used to call commands at the operating system or external scripts and use their output in the location where the command was given. Any command arguments can be given in the command line. + +When used in a loop context (see section~\ref{loops}), \texttt{\bs sqluse} can also be used to provide data to the script. If command arguments must be given for database access, the following tags can be used: + +\begin{itemize} +\item[\texttt{<SRV>}] Name of the database server. +\item[\texttt{<USR>}] Username to connect to the database. +\item[\texttt{<PWD>}] Password to connect to the database. +\item[\texttt{<DB>}] Name of the database. +\end{itemize} + +They will be replaced by the credentials for connecting to the database (see section~\ref{opendb}). + + +\vs + +\noindent Example:\\ +\texttt{\bs sqlsystem\{./add\_vat --usr <USR> --db <DB> --pwd <PWD> $\hookleftarrow$ \\ +--inv \bs sqluse\{invoice\_nr\}\}} + +\vs + +By default, use of this command is disallowed. To enable it, set the value of \texttt{sqlsystem\_allowed} to ``1'' in the configuration file (see also section~\ref{config}. + +If the command is disabled, occurances of this command will be replaced by the fixed text ``\texttt{use of the \bs sqlsystem command is disallowed in the configuration}''. + +\vs + +\noindent\hspace{-3mm}\textit{\underline{Note:}} The \texttt{\bs sqlsystem} command cannot span multiple lines! + + +\subsection{Output multiple documents}\label{multidoc} + +A single input file can be created to generate more output files using the \texttt{--multidoc-numbered} or \texttt{--multidoc-named} commandline option. + +The input document must contain the command \texttt{\bs sqlsetparams} without any options. The query that follows can return an unlimited number of rows: \\ +\texttt{\bs sqlsetparams\{SELECT NR, CUST\_NR FROM INVOICES WHERE REMINDERS = \$PAR1\}} + +\vs + +By processing this command, SQL\TeX\ builds a list with all values retrieved and +processes the input file again for each row.\\ +In those runs, the queries are executed as described in the previous sections, +using the returned fields to replace \texttt{\$MPAR\textit{n}} placeholders, where \textit{n} starts with 1 and represents the fields in the order as they have been retrieved:\\ +\texttt{\bs sqlrow\{SELECT * FROM INVOICES WHERE NR = \$MPAR1\}} \\ +\texttt{\bs sqlrow\{SELECT * FROM CUSTOMER WHERE CUST\_NR = \$MPAR2\}} + +\vs + +The options \texttt{--multidoc-numbered} or \texttt{--multidoc-named} cannot be used together.\\ +Without these options, a parameter can be given and a single output +document will be created, ignoring the \texttt{\bs sqlsetparams} command. + +\vs + +With the \texttt{--multidoc-numbered} option, output filenames will be numbered \texttt{\emph{filename}\_1.tex} to \texttt{\emph{filename}\_\emph{n}.tex}.\\ +With the \texttt{--multidoc-named} option, output filenames will be numbered \\\texttt{\emph{filename}\_\emph{parameter}.tex}, where \emph{parameter} is the first value taken from the database (\texttt{\$MPAR1}, the invoice number \texttt{nr} in the example above). \\ +Note the parameter will not be formatted to be filename-friendly!\\ + + +\subsection{Update database records} + +Since version 1.5, SQL\TeX\ supports database updates as well: \\ +\texttt{\bs sqlupdate\{UPDATE INVOICE SET REMINDERS = REMINDERS + 1, +LAST\_REMINDER = NOW() WHERE NR = \$VAR1\}} + +This command accepts no options. + +\vs + +By default, the update statements will be ignored. To actually process them, the commandline options \texttt{--updates} must be given! + +\section{Process your SQL\TeX\ file} + +To process your SQL\TeX\ file and create a \LaTeX\ file with all information read from +the database, call SQL\TeX\ with the parameter(s) and (optional) command\-line options as +described here. + +\subsection{Parameters}\label{params} + +SQL\TeX\ accepts more than one parameter. The first parameter is required; this should +be the input file, pointing to your \LaTeX\ document containing the SQL\TeX\ commands. + +By default, SQL\TeX\ looks for a file with extension `\texttt{.tex}'. + +\vs + +All other parameters are used by the queries, if required. If an SQL query contains the +string \texttt{\$PAR\textit{n}}\footnote{where \textit{n} is a number between 1 and 9. Note +parameter `0' cannot be used, since that contains the filename!}, it is replaced by that parameter +(see also section~\ref{sqlstatements}). + +\subsection{Command line options}\label{cmdline} + +SQL\TeX\ accepts the following command- line options: + +\begin{description} +\item[\texttt{--configfile \textit{file}, -c \textit{file}}] SQL\TeX\ configuration file. Default is \texttt{SQLTeX.cfg} in the systems default location (see section \ref{config}). + +\item[\texttt{--file-extension \textit{string}, -E \textit{string}}] replace input file extension in outputfile: +\texttt{input.tex} will be \texttt{input.\textit{string}}. \\ +For further notes, see option \texttt{--filename-extend} below. + +\item[\texttt{--filename-extend \textit{string}, -e \textit{string}}] add \textit{string} to the output filename: +\texttt{input.tex} will be \texttt{input\textit{string}.tex}. This overwrites +the configuration setting \texttt{stx}. \\ +In \textit{string}, the values between curly braces \{\} will be substituted: +\begin{description} +\item[P\textit{n}] parameter \textit{n} +\item[M] current monthname (\textit{Mon}) +\item[W] current weekday (\textit{Wdy}) +\item[D] current date (\textit{yyyymmdd}) +\item[DT] current date and time (\textit{yyyymmddhhmmss}) +\item[T] current time (\textit{hhmmss}) +\end{description} +e.g., the command\\ +\hspace*{1em}\texttt{sqltex --filename-extend \_\{P1\}\_\{W\} my\_file code}\\ +will read `\texttt{my\_file.tex}' and write `\texttt{myfile\_code\_Tue.tex}'.\\ +The same command, but with option \texttt{---file-extension} would create the outputfile \texttt{my\_file.\_code\_Tue}\\ +The options \texttt{--file-extension} and \texttt{--filename-extend} cannot be used together or with \texttt{--output}. + +\item[\texttt{--force, -f}] force overwrite of existing files. By default, SQL\TeX\ exits with a +warning message it the outputfile already exists. + +\item[\texttt{--help, -h}] print this help message and exit. + +\item[\texttt{--multidoc-numbered, -m}] Multidocument mode; create one document for each parameter that is retrieved +from the database in the input document (see section~\ref{multidoc}). This option cannot be used with \texttt{--output}. + +\item[\texttt{--multidoc-named, -M}] Same as \texttt{--multidoc-numbered}, but with the parameter in the filename instead of a serial number (see section~\ref{multidoc}). + +\item[\texttt{--null-allowed, -N}] \texttt{NULL} return values allowed. By default SQL\TeX\ exits if a +query returns an empty set. + +\item[\texttt{--output \textit{file}, -o \textit{file}}] specify an output file. Cannot be used with \texttt{--file-extension}, +\texttt{--filename-extend} or the \texttt{--multidoc} options. + +\item[\texttt{--skip-empty-lines, -S}] All SQL\TeX\ commands will be removed from the input line or replaced by the corresponding value. The rest of the input line is written to the output file. +This includes lines that only contain a SQL\TeX\ command (and a newline character). This will result in an empty line in the output file.\\ +By specifying this option, these empty lines will be skipped. Lines that were empty in the input will be written. + +\item[\texttt{--write-comments, -C}] \LaTeX\ comments in the input file will be skipped by default. With this option, comments will also be copied to the output file. + +\item[\texttt{--prefix \textit{prefix}, -p \textit{prefix}}] prefix used in the SQL\TeX\ file. Default is \texttt{sql} (see also section~\ref{config} +on page~\pageref{prefix}. This overwrites the configurarion setting \texttt{cmd\_prefix}. + +\item[\texttt{--password \textit{[password]}, -P} \textit{[password]}] database password. The value is optional; if omitted, SQL\TeX\ will prompt for a password. This overwrites the password in the input file. + +\item[\texttt{--quiet, -q}] run in quiet mode. + +\item[\texttt{--replacementfile \textit{replace}, -r \textit{replace}}] Specify a file that contains the replace characters (see section~\ref{replfiles}). \\ +Default is \texttt{SQLTeX{\_}r.dat} in the systems default location (see section \ref{replfiles}). This default file will always be used after the given replacement file, unless \texttt{multi\_rfile} is set to \texttt{0} in the configuration (see secion \ref{config}). + +\item[\texttt{--no-replacementfile, -R}] Do not use a replace file. \texttt{--no-replacementfile} and \texttt{--replacementfile \textit{file}} are handled in the same order as +they appear on the command line, overwriting each other.\\ +For backwards compatibility, \texttt{-rn} is also still supported. + +\item[\texttt{--sqlserver \textit{server}, -s \textit{server}}] SQL server to connect to. Default is \texttt{localhost}. + +\item[\texttt{--updates, -u}] if the input file contains updates, process them. + +\item[\texttt{--username \textit{user}, -U \textit{user}}] database username. This overwrites the username in the input file. + +\item[\texttt{--version, -V}] print version number and exit. +\end{description} + + + +\section{SQL\TeX\ errors and warnings} + +\noindent\textbf{\texttt{no input file specified}} + +\vspace{1mm} + +\noindent SQL\TeX\ was called without any parameters.\\ +\textit{Action:} Specify at least one parameter at the commandline. This parameter should be +the name of your input file. + +\vs + +\noindent\textbf{\texttt{File \textit{input filename} does not exist}} + +\vspace{1mm} + +\noindent The input file does not exist.\\ +\textit{Action:} Make sure the first parameter points to the input file. + +\vs + +\noindent\textbf{\texttt{outputfile \textit{output filename} already exists}} + +\vspace{1mm} + +\noindent The outputfile cannot be created because it already exists.\\ +\textit{Action:} Specify another output filename with command line option \texttt{-e}, +\texttt{-E} or \texttt{-o}, or force an overwrite with option \texttt{-f} (see also section\ref{cmdline}). + +\vs + +\noindent\textbf{\texttt{no database opened at line \textit{line nr}}} + +\vspace{1mm} + +\noindent A query starts at line \textit{line nr}, but at that point no database was opened yet. \\ +\textit{Action:} Add an \texttt{\bs sqldb} command prior to the first query statement. + +\vs + +\noindent\textbf{\texttt{insufficient parameters to substitute variable on line \textit{line nr}}} + +\vspace{1mm} + +\noindent The query starting at line \textit{line nr} uses a parameter in a \textsc{where}- clause with +\texttt{\$PAR\textit{n}}, where \textit{n} is a number bigger than the number of parameters +passed to SQL\TeX\. \\ +\textit{Action:} Specify all required parameters at the command line. + +\vs + +\noindent\textbf{\texttt{trying to substitute with non existing on line \textit{line nr}}} + +\vspace{1mm} + +\noindent The query starting at line \textit{line nr} requires a variable \texttt{\$VAR\textit{n}} in its +\textsc{where}- clause, where \textit{n} points to a variable that has not (yet) been set. \\ +\textit{Action:} Change the number or set the variable prior to this statement. + +\vs + +\noindent\textbf{\texttt{trying to overwrite an existing variable on line \textit{line nr}}} + +\vspace{1mm} + +\noindent At line \textit{line nr}, a \texttt{\bs sqlfield} query tries to set a variable \textit{n} +using the option \texttt{[setvar=\textit{n}]}, but \texttt{\$VAR\textit{n}} already +exists at that point. \\ +\textit{Action:} Change the number. + +\vs + +\noindent\textbf{\texttt{no result set found on line \textit{line nr}}} + +\vspace{1mm} + +\noindent The query starting at line \textit{line nr} returned a \texttt{NULL} value. If the +option \texttt{-N} was specified at the commandline, this is just a warning message. +Otherwise, SQL\TeX\ exits. \\ +\textit{Action:} None. + +\vs + +\noindent\textbf{\texttt{result set too big on line \textit{line nr}}} + +\vspace{1mm} + +\noindent The query starting at line \textit{line nr}, called with \texttt{\bs sqlfield} returned more than one field. \\ +\textit{Action:} Change your query or use \texttt{\bs sqlrow} instead. + +\vs + +\noindent\textbf{\texttt{no parameters for multidocument found on line \textit{line nr}}} + +\vspace{1mm} + +\noindent SQL\TeX\ is executed in multidocument mode, but the statement on line +\textit{line nr} did not provide any parameters for the documents. \\ +\textit{Action:} Check your query. + +\vs + +\noindent\textbf{\texttt{too many fields returned in multidocument mode on \textit{line nr}}} + +\vspace{1mm} + +\noindent In multidocument mode, the lis of parameters retrieved on line +\textit{line nr} returned more than one fields per row. \\ +\textit{Action:} Check your query. + +\vs + +\noindent\textbf{\texttt{start using a non-existing array on line \textit{line nr}}} + +\vspace{1mm} + +\noindent An \texttt{\bs sqlstart} command occurs, but refers to a non-existing array. \\ +\textit{Action:} Check the sequence number of the array filled with \texttt{\bs sqlrow[setarr=\textit{n}]} and retrieved with \texttt{\bs sqlstart\{\textit{n}\}} in your input file. + +\vs + +\noindent\textbf{\texttt{\bs sqluse command encountered outside loop context on line \textit{line nr}}} + +\vspace{1mm} + +\noindent Data from array is used, but the current input file position is not in the context where this data is available.\\ +\textit{Action:} Check the presence and positions of the \texttt{\bs sqlstart} and \texttt{\bs sqlend} commands in your input file. + +\vs + +\noindent\textbf{\texttt{unrecognized command on line \textit{line nr}}} + +\vspace{1mm} + +\noindent At line \textit{line nr}, a command was found that starts with ``\texttt{\bs sql}'', +but this command was not recognized by SQL\TeX\. \\ +\textit{Action:} Check for typos. If the command is a user- defined command, it will +conflict with default SQL\TeX\ commands. Change the SQL\TeX\ command prefix (see section~\ref{config}). + +\vs + +\noindent\textbf{\texttt{no sql statements found in \textit{input filename}}} + +\vspace{1mm} + +\noindent SQL\TeX\ did not find any valid SQL\TeX\ commands. \\ +\textit{Action:} Check your input file. + + +\section{Copyright and disclaimer} + +\noindent\hrulefill \\ +The SQL\TeX\ project is available from GitHub: \url{https://github.com/oveas/sqltex}\\ +For bugs, questions and comments, please use the issue tracker available at \url{https://github.com/oveas/sqltex/issues} + +\vspace{3mm} + +\noindent Copyright\copyright\ 2001-2024 - Oscar van Eijk, Oveas Functionality Provider + +\noindent\hrulefill \\ + +\noindent This software is subject to the terms of the LaTeX Project Public License; +see \url{http://www.ctan.org/tex-archive/help/Catalogue/licenses.lppl.html}. + +\section{History} + +\begin{description} +\item[v3.0] \textit{released: Sep 20, 2024} +\begin{itemize} +\item Made it possible to run SQL\TeX\ directly from the distribution without \texttt{configure} and \texttt{make [install]} to make integration in \TeX\ Live possible. +\item Renamed the script to \texttt{sqltex}. For backwards compatibility, during installation on linux a symbolic link \texttt{SQLTeX} is created. +\item The \texttt{SQLTeX.exe} binary is no longer included in the distribution (see footnote \footref{winexe} on page \pageref{winexe}). +\item Removed support for the \texttt{--use-local-config} commandline option. The options \texttt{--configfile} and \texttt{--replacementfile} can be used instead. +\item Added an option to disable the \texttt{--configfile} command line option (see note on page \pageref{cfg:disable}). +\item Added the \texttt{--skip-empty-lines} and \texttt{--write-comments} commandline options. +\item Added support for multiple replacement files. +\item Fix: ordering in the replacement file. +\end{itemize} + +\item[v2.2] \textit{released: Jul 31, 2024} +\begin{itemize} +\item Extended the default replace file (see \ref{replfiles}) with more special characters (e.g. with diacritics) and HTML tags. +\item Issue \#6 (\url{https://github.com/oveas/sqltex/issues/6}): added support for ODBC drivers +\item Issue \#8 (\url{https://github.com/oveas/sqltex/issues/8}): added support for parameter-driven in \texttt{\bs sqlsetparams} statements (multi-document mode).\\ +\textit{\textbf{Note:}} This requires an update of your input files for multi-document mode that have been created before v2.2. Refer to section \ref{mdocupdates} for details. +\item Added the \texttt{\bs sqlsystem} command. +\item Added the \texttt{\bs sqlif}-\texttt{\bs sqlendif} control block. +\end{itemize} + +\item[v2.1] \textit{released: Jan 21, 2022} +\begin{itemize} +\item Fix bug \#2 (\url{https://github.com/oveas/sqltex/issues/2}): standard path management for output files.\\ +See config item \texttt{def\_out\_is\_in} in section \ref{config} to revert to pre v2.1 behaviour. +\item Fix: help was not displayed on Windows +\item Implemented '?' as password in \texttt{dbopen} +\item Implemented '?' as username in \texttt{dbopen} +\item Implemented long options +\item Allow overwriting variables in multidocument mode +\item Added simple automated regression tests +\item Added a man page for linux users +\item Rewrote the installation procedure, now using \texttt{autotools} on linux. +\item On linux, change the default installation directory to \texttt{/usr/bin} and store the configuration- and replacement files is \texttt{/etc}. +\item Added option \texttt{--use-local-config}. +\end{itemize} + +\item[v2.0] \textit{released: Jan 12, 2016} +\begin{itemize} +\item Fix: Oracle support using ORASID +\item Fix: Ensure replacements are handled in the same order as they appear in the replacements file +\item Separate configuration file(s) +\item Added the options \texttt{-c} and \texttt{-M} +\item Support for regular expressions in replace files +\item Implemented support for the \LaTeX\ \texttt{\bs input} and \texttt{\bs include} directives +\item Implemented loop context +\item Skip commentlines +\item Project moved from local CVS to GitHub +\end{itemize} + +\item[v1.5] \textit{released: Nov 23, 2007} +\begin{itemize} +\item Support for multiple databases +\item Implemented database updates (\texttt{sqlupdate}) +\item Implemented multiple output documents (option \texttt{-m}) +\end{itemize} + +\item[v1.4.1] \textit{released: Feb 15, 2005}\\ +Fix: removed leading whitespaces added to database results before replace + +\item[v1.4] \textit{released: May 2, 2002}\\ +Implemented replace files + +\item[v1.3] \textit{released: Mar 16, 2001}\\ +First public release + +\end{description} + +\subsection{Changes that require updates in your input files} + +\subsubsection{Multi-document mode since v2.2}\label{mdocupdates} + +Up until v2.1, the statement in \texttt{\bs sqlsetparams} could return only one field per row and the statement itself could not handle parameters. The placeholder \texttt{\$PAR1} was reserved for the subsequent statements. + +Since v2.2 it is possible to retrieve multiple values per row. They will replace the placeholders \texttt{\$MPAR\textit{n}} in the subsequent statements, while \texttt{\$PAR\textit{n}} placeholders can now also be used for regular parametes in the \texttt{\bs sqlsetparams} statement itself. + +\vs + +This means, in input documents created before v2.2, all ``\texttt{\$PAR1}'' placeholders must be replaced by ``\texttt{\$MPAR1}''. + +\end{document} diff --git a/Master/texmf-dist/doc/support/texplate/README.md b/Master/texmf-dist/doc/support/texplate/README.md index 43673ed9178..ea0f023a35b 100644 --- a/Master/texmf-dist/doc/support/texplate/README.md +++ b/Master/texmf-dist/doc/support/texplate/README.md @@ -4,19 +4,26 @@ ![Minimum JRE: 8.0](https://img.shields.io/badge/Minimum_JRE-8.0-blue.svg?style=flat-square) ![Current version](https://img.shields.io/badge/dynamic/json.svg?color=blue&label=Latest%20release&query=%24.0.name&url=https%3A%2F%2Fgitlab.com%2Fapi%2Fv4%2Fprojects%2F13793875%2Frepository%2Ftags&style=flat-square) -TeXplate is a tool for creating document structures based on templates. The application name is a word play on _TeX_ and _template_, so the purpose seems quite obvious: we want to provide an easy and straightforward framework for reducing the typical code boilerplate when writing TeX documents. Also note that one can easily extrapolate the use beyond articles and theses: the application is powerful enough to generate _any_ text-based structure, given that a corresponding template exists. +TeXplate is a tool for creating document structures based on templates. The +application name is a word play on _TeX_ and _template_, so the purpose seems +quite obvious: we want to provide an easy and straightforward framework for +reducing the typical code boilerplate when writing TeX documents. Also note that +one can easily extrapolate the use beyond articles and theses: the application +is powerful enough to generate _any_ text-based structure, given that a +corresponding template exists. ## Basic use -Our tool is a typical command line application, so we need to invoke it by simply typing `texplate` in the terminal: +Our tool is a typical command line application, so we need to invoke it by +simply typing `texplate` in the terminal: ```bash $ texplate ______ __ __ ___ __ -/\__ _\ /\ \ /\ \ /\_ \ /\ \__ -\/_/\ \/ __ \ `\`\/'/' _____\//\ \ __ \ \ ,_\ __ - \ \ \ /'__`\`\/ > < /\ '__`\\ \ \ /'__`\ \ \ \/ /'__`\ - \ \ \/\ __/ \/'/\`\\ \ \L\ \\_\ \_/\ \L\.\_\ \ \_/\ __/ +/\__ _\ /\ \ /\ \ /\_ \ /\ \__ +\/_/\ \/ __ \ `\`\/'/' _____\//\ \ __ \ \ ,_\ __ + \ \ \ /'__`\`\/ > < /\ '__`\\ \ \ /'__`\ \ \ \/ /'__`\ + \ \ \/\ __/ \/'/\`\\ \ \L\ \\_\ \_/\ \L\.\_\ \ \_/\ __/ \ \_\ \____\ /\_\\ \_\ \ ,__//\____\ \__/.\_\\ \__\ \____\ \/_/\/____/ \/_/ \/_/\ \ \/ \/____/\/__/\/_/ \/__/\/____/ \ \_\ @@ -55,23 +62,42 @@ Usage: texplate [-c=<configuration>] -o=<output> [-t=<template>] -Provided that TeXplate is properly available in the underlying operating system, we will get a lovely, colorful output in our terminal, along with a couple of scary messages telling that some required options are missing. Our tool provides four options, described as follows. Strictly speaking, there is only one mandatory option. The remainder might be optional, depending on certain scenarios. +Provided that TeXplate is properly available in the underlying operating system, +we will get a lovely, colorful output in our terminal, along with a couple of +scary messages telling that some required options are missing. Our tool provides +four options, described as follows. Strictly speaking, there is only one +mandatory option. The remainder might be optional, depending on certain +scenarios. ### Output -Referred as either`-o` (short representation) or `--output` (long representation), this option holds the output file in which the chosen template will be effectively written. The name is arbitrary, so you can use anything to your heart's desires. Keep in mind, however, that an existing file will be mercilessly overwritten. Also, make sure the path has the proper permissions for writing the output file. +Referred as either`-o` (short representation) or `--output` (long +representation), this option holds the output file in which the chosen template +will be effectively written. The name is arbitrary, so you can use anything to +your heart's desires. Keep in mind, however, that an existing file will be +mercilessly overwritten. Also, make sure the path has the proper permissions for +writing the output file. ### Template -Referred as either `-t` (short representation) or `--template` (long representation), this option holds the reference to the template to be potentially merged with data and properly generated. The provided string should match the template identifier, otherwise TeXplate will raise an error complaining about the missing reference. +Referred as either `-t` (short representation) or `--template` (long +representation), this option holds the reference to the template to be +potentially merged with data and properly generated. The provided string should +match the template identifier, otherwise TeXplate will raise an error +complaining about the missing reference. ### Map -Referred as either `-m` (short representation) or `--map` (long representation), this option holds a map entry, defined as a `key=value` ordered pair (mind the `=` symbol used as entry separator). This option can be used multiple times. The map entry denotes a variable in the template context, where the key is the variable name and the value is set to be the initial state of such variable. +Referred as either `-m` (short representation) or `--map` (long representation), +this option holds a map entry, defined as a `key=value` ordered pair (mind the +`=` symbol used as entry separator). This option can be used multiple times. The +map entry denotes a variable in the template context, where the key is the +variable name and the value is set to be the initial state of such variable. ## Examples -For instance, let us generate a document named `doc1.tex`, based on the standard `article` class: +For instance, let us generate a document named `doc1.tex`, based on the standard +`article` class: ```bash $ texplate -t article -o doc1.tex @@ -103,7 +129,8 @@ Done! Enjoy your template! Written: 112 B ``` -And that is it! We provided the template name (`-t article`) and the output (`-o doc1.tex`). Checking the contents of `doc1.tex`: +And that is it! We provided the template name (`-t article`) and the output (`-o +doc1.tex`). Checking the contents of `doc1.tex`: ```tex \documentclass{article} @@ -116,13 +143,18 @@ And that is it! We provided the template name (`-t article`) and the output (`-o \end{document} ``` -We could enhance the template generation by providing further options to it. Let us say we want to include A4 as the paper size for our document and use XeTeX as engine. The command line is as follows (we omitted the full output for reducing verbosity): +We could enhance the template generation by providing further options to it. Let +us say we want to include A4 as the paper size for our document and use XeTeX as +engine. The command line is as follows (we omitted the full output for reducing +verbosity): ```bash $ texplate -t article -o doc2.tex -m options=a4paper -m xetex=true ``` -For this example, we added two map entries referring to the class option and the support for newer engines (please refer to the user manual for more details on template options). The newly generated `doc2.tex` document is as follows: +For this example, we added two map entries referring to the class option and the +support for newer engines (please refer to the user manual for more details on +template options). The newly generated `doc2.tex` document is as follows: ```tex \documentclass[a4paper]{article} @@ -159,13 +191,20 @@ Checking the contents of `doc3.tex`: \end{document} ``` -And that is it! Make sure to take a look at the user manual to learn more about TeXplate! +And that is it! Make sure to take a look at the user manual to learn more about +TeXplate! ## License -This application is licensed under the [New BSD License](https://opensource.org/licenses/BSD-3-Clause). Please note that the New BSD License has been verified as a GPL-compatible free software license by the [Free Software Foundation](http://www.fsf.org/), and has been vetted as an open source license by the [Open Source Initiative](http://www.opensource.org/). +This application is licensed under the +[New BSD License](https://opensource.org/licenses/BSD-3-Clause). Please note +that the New BSD License has been verified as a GPL-compatible free software +license by the [Free Software Foundation](http://www.fsf.org/), and has been +vetted as an open source license by the +[Open Source Initiative](http://www.opensource.org/). ## The team -TeXplate is brought to you by Ben Frank and Paulo Cereda. If you want to support TeX development by a donation, the best way to do this is donating to the [TeX Users Group](https://www.tug.org/donate.html). - +TeXplate is brought to you by the Island of TeX. If you want to support TeX +development by a donation, the best way to do this is donating to the +[TeX Users Group](https://www.tug.org/donate.html). diff --git a/Master/texmf-dist/doc/support/texplate/texplate-manual.pdf b/Master/texmf-dist/doc/support/texplate/texplate-manual.pdf Binary files differindex 6f20dd4c2f3..96d574ace68 100644 --- a/Master/texmf-dist/doc/support/texplate/texplate-manual.pdf +++ b/Master/texmf-dist/doc/support/texplate/texplate-manual.pdf diff --git a/Master/texmf-dist/doc/support/texplate/texplate-manual.tex b/Master/texmf-dist/doc/support/texplate/texplate-manual.tex index a56911ab727..1de47ab1497 100644 --- a/Master/texmf-dist/doc/support/texplate/texplate-manual.tex +++ b/Master/texmf-dist/doc/support/texplate/texplate-manual.tex @@ -17,7 +17,7 @@ \newcommand{\shortopt}[1]{{\ttfamily-#1}} \newcommand{\longopt}[1]{{\ttfamily{-}{-}#1}} \newcommand{\macro}[1]{{\ttfamily\textbackslash#1}} -\newcommand{\texplateversion}{1.0.4} +\newcommand{\texplateversion}{1.0.6} \title{A gentle introduction to \texplate:\\ a document structure creation tool} \author{Island of \TeX} @@ -624,7 +624,23 @@ Happy \TeX ing with \texplate! \chapter*{Changelog} -\section*{1.0.4 (current)} +\section*{1.0.6 (current)} + +\subsection*{Fixed} + +\begin{itemize} +\item Application version is now retrieved from the manifest (regression fix). +\end{itemize} + +\section*{1.0.5 (2024-08-01)} + +\subsection*{Changed} + +\begin{itemize} +\item Updated dependencies to close a security vulnerability. +\end{itemize} + +\section*{1.0.4 (2021-07-27)} \subsection*{Fixed} diff --git a/Master/texmf-dist/doc/support/tlaunch/Changes b/Master/texmf-dist/doc/support/tlaunch/Changes index 148a5624669..4eddb17e6c4 100644 --- a/Master/texmf-dist/doc/support/tlaunch/Changes +++ b/Master/texmf-dist/doc/support/tlaunch/Changes @@ -1,3 +1,11 @@ +2024-10-07 Siep Kroonenberg <siepo@bitmuis.nl> Release 0.5.5 + + * Bug fixes + +2023-03-07 Siep Kroonenberg <siepo@bitmuis.nl> Release 0.5.4 + + * Transition to 64bit + 2017-06-29 Siep Kroonenberg <siepo@cybercomm.nl> Release 0.5.3 * Remember command-line option: restores file associations on login |