Skip to content
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

Add --root argument and %!TEX root support #242

Merged
merged 4 commits into from
Oct 28, 2023

Conversation

vmartinv
Copy link
Contributor

This should address #131 following the suggested approach in this comment, that is:

  • Leave the basic sub-file behavior as it is now
  • Add support for the !TEX root magic comment (Error with inputs and includes #81 (comment)) so that one can check sub-files individually
  • Add the --root file.tex command line option that does the same thing
  • In the Readme, refer users to the tools mentioned in the SO thread if this behavior is not enough for them

Implementation details

  • When using the %!TEX root directive, the path provided should be treated as relative to the current file.
  • When using the --root argument, the path provided should be treated relative to the working directory.

Hence the implementation of these two features are a bit different.

Corner case

Due to the current logic if you for example supply both %!TEX root = ../root.tex and --root dir/root.tex options, it might generate incorrect paths: dir/../child.tex. But I don't think this should happen often. I can add additional logic to ignore the %!TEX root if --root is supplied, but is it necessary? There's no need to supply --root if the directives are present.

@vmartinv
Copy link
Contributor Author

vmartinv commented Oct 28, 2023

Also, note that this diff moves the path resolving logic inside LatexCleaner, this is because in the future I want the --clean command to also expand the includes, so the cleaner will need to be able to locate the files.

@sylvainhalle sylvainhalle merged commit d95e56c into sylvainhalle:master Oct 28, 2023
@sylvainhalle
Copy link
Owner

Thanks, this was one feature I was reluctant to dig into. I'm glad someone did it for me! ;-)

@vmartinv vmartinv deleted the root branch October 28, 2023 20:46
vmartinv added a commit to vmartinv/textidote that referenced this pull request Oct 31, 2023
* Add --root argument and %!TEX root support

* Make code cleaner

* Fix typo
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants