-
Notifications
You must be signed in to change notification settings - Fork 76
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Option to include a hook to call a user-supplied script for cleanup prior to --flatten #165
Comments
It does sound like it would be, in principle, a fairly easy thing to do. So the script should run (separately) on the old and new master file in modifies these files destructively, or works as a filter (i.e. taking stdin and outputting stdout)? Would it need options? If options are allowed I could see trouble with option arguments containing spaces but otherwise one could pass command and its options as a quoted string to latexdiff. |
I was envisioning filter, no options. (If a site maintainer wanted to use this highly specific bailout, it would be on them to write the filter script as they need to. If they need different behavior, they pass a different script name to latexdiff.) Minimum example: we have a highly structured document system for producing technical specifications, from authors who don't know LaTeX. Frankly, they're terrified of it. (I know, I know, Word refugees, what are you going to do.) As part of making sure they deal with as little structure as possible, and instead concentrate on content, we allow for optional sections, etc, but we can't do: \section{Optional Section} If they haven't provided myoptionalsection.tex, or it's empty, then we don't want the section included at all. So we have the following: \iffileemptyelse{myoptionalsection} I'm sure you can see where this goes wrong. flatten ignores the custom command and tries to handle the input, for a file that may not be there, leading to a fatal error, and if it's there and empty, ends up injecting a section we don't want. The cleanup script executes these ifthenelse conditionals, and replaces them with the appropriate clause. flatten then handles the \input commands as expected. The other customization is for local change tracking notes. They are critical for communication between authors, but should not appear in the final rendered document, or be considered for diffs. Assume the command that wraps these is \mycomment, is there an existing way of having latexdiff ignore their contents completely? I have suspected there is, and I just missed it. Edit: I'm happy to help with implementation and generate a pull request. |
Added a new option:
The filter script must be written to accept pipe input, and write to stdout. Within Question: move filtering just after assignment of |
Yes, I think it would make sense to offer this functionality independently of flatten. I don't see a pull request yet, but I presume that's intentional. |
I never answered this. The contents should be ignored by default for all , but a new \mycomment would be wrapped by \DIFaddbegin and \DIFaddend commands. In the default style those commands don't do anything so I am wondering why you get problems with this |
Yes, pull was waiting on hook placement discussion. Will move, test, and submit pull request. mycomment issue was that it needed to be stripped, filter script takes care of that. No further issue there, thanks. |
I want to add my usecase to this issue, referring to the initial question of @ftilmann Hopefully, my comment adds value to this (slightly dated) conversation. I dynamically generate files which will be included in my tex file. Therefore, I run two commands in bash prior to invoking latex. With
Possible workarounds are:
In my case, the best solution I can think of is an option [1] example dot file with generated output at |
@jasonmccsmith since your pull request #172 has been merged, can this issue be closed or was there a problem left that the PR didn't cover? |
I have custom commands that cause fits with flatten, and I'd like to remove the commands myself prior to latexdiff attempting to flatten files.
I was doing this in a custom script above invoking latexdiff, but my organization has now (finally) converted to a git backend for document versioning, and we'd like to use latexdiff-vc. The cleanup has to occur between the git checkout, and the flattening.
The heavyhanded approach is to add the code directly to sub flatten in latexdiff, and it works well, but we'd prefer to not have to fiddle with updates to latexdiff. Instead, we realized that we can't be the only ones in this boat, and would it instead be more useful to all to have a new option offering a script to be run prior to flatten. Input text, output text.
Using a git-hook isn't a great option, because we would only need this cleanup for use with latexdiff, and the rest of our workflow relies on the offensive bits.
Thoughts? Will be editing sub flatten in situ in the meantime.
The text was updated successfully, but these errors were encountered: