latexdiff icon indicating copy to clipboard operation
latexdiff copied to clipboard

\DefineShortVerb not handled properly

Open cousteaulecommandant opened this issue 8 years ago • 2 comments

First of all, sorry in advance if this issue is too much of a "corner case" to be relevant.

Situation: my document uses lots of short fragments of code here and there, so instead of using \verb"..." or \texttt{...} whenever I want to introduce a variable name or short code fragment, I decided it would be a good idea to alias "..." to \verb"...":

\usepackage{fancyvrb}
\DefineShortVerb{\"}
% ...
The "$foo" variable...

Unfortunately, latexdiff isn't aware of this, so whenever I diff two versions of the document, one of which contains "..." while the other doesn't, the result will fail because you can't use \verb inside \DIFadd{...}. Furthermore, if I change the foo variable to the "foo" variable, it gets worse because it'll try to do \DIFadd{"}. So far the workaround has been to manually replace all "..." with \verb"..." before calling latexdiff.

Would it be easy to make latexdiff aware of the \DefineShortVerb command, treating the specified character the same way \verb|...| is treated, or would that be too much work for too little benefit?

cousteaulecommandant avatar Jan 11 '18 14:01 cousteaulecommandant

Thanks for reporting the issue. I have to admit it is maybe a little bit of a specialised request, and so there are some other issues, which I will probably deal with with higher priority.
So if somebody else reads this and would like this fixed, too, please make your voice heard. Otherwise it is hard for me to judge how many people would really benefit from a fix. The solution would probably entail automating your manual procedure, i.e. make this change as one of the first steps of pre-processing the input, and then possibly undoing it right at the end of preprocessing. In this way the normal highlighting for verbatim commands would still work. Two questions about this:

  1. Would it be OK to assume there is no newline between the two quotation marks used as verbatim marker.
  2. Can one assume, the \DefineShortVerb command is given in the preamble and there is only one?

ftilmann avatar Jan 14 '18 22:01 ftilmann

  1. Would it be OK to assume there is no newline between the two quotation marks used as verbatim marker.

Yes; newlines between the verbatim markers seem not to be allowed (same with \verb|...|).

  1. Can one assume, the \DefineShortVerb command is given in the preamble and there is only one?

This is the case in my document, and I would assume one is not going to change the short verb character in the middle of the document; nevertheless the documentation for fancyvrb shows an example for that.

cousteaulecommandant avatar Jan 15 '18 18:01 cousteaulecommandant