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

Generate better stack traces for XML errors in included files #2364

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

ascholerChemeketa
Copy link
Contributor

Currently, if there is a syntax error (e.g. tag mismatch) in an included file, no information is provided about what file has the issue.

Authors writing a book page by page can figure out the location, but it can be maddening after using a tool to do a batch conversion of edit.

This makes sure the trace ends with a pointer directly to the offending file:

  ...
  File "/mnt/f/Programming/thinkcpp-rs/pretext/Chapter1/program.ptx", line 20
lxml.etree.XMLSyntaxError: Opening and ending tag mismatch: p line 17 and li, line 20, column 10

@rbeezer
Copy link
Collaborator

rbeezer commented Jan 14, 2025

This will be a really nice improvement. But I'm seeing some kind of trouble.

Built sample book. Error reporting is much improved with an intentional error added. Then did a before/after HTML build with no errors. All xref seem to not work. As if the @xml:id vanished. Also seeing some changes where stuff with an xml:base is going missing. I understand xml:base to be part of the xi:include/@href mechanism, but otherwise don't have much insight. Not sure I have much more guidance.

@ascholerChemeketa ascholerChemeketa force-pushed the better-xml-include-errors branch 2 times, most recently from e457d66 to 4445d91 Compare January 14, 2025 17:51
@ascholerChemeketa
Copy link
Contributor Author

Sorry, hadn't done full diffs. Bad dev.

I spent a while trying to make EInclude.include work exactly the same as tree.xinclude() (identical output when you dump the src_tree to text right after include AND clean HTML diffs). Couldn't crack it. The documentation does indicate that EInclude is a partial replacement for include. Even if I got something that looked like it was working, I don't know how confident I would be in it.

So, now the approach is use xinclude, but if there is an error with that, redo the work with ElementInclude, let it fail, and then show the stack trace from it.

@ascholerChemeketa ascholerChemeketa force-pushed the better-xml-include-errors branch from 4445d91 to 17848d2 Compare January 14, 2025 17:58
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