-
Notifications
You must be signed in to change notification settings - Fork 12
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
Support for sourcepos for latex output #29
base: main
Are you sure you want to change the base?
Conversation
I suspect they won't like it, because there are bound to be cases where the comments change the meaning of the LaTeX source, e.g. if one ends up in some verbatim environment. |
7e81f26
to
78d97f6
Compare
Can you try it again? I tried to now insert the comment at each linebreak, except for within verbatim. |
I see a couple of spots where it emits
|
Thanks, I updated it to remove those. |
4b73740
to
b0ef509
Compare
This is working nicely now. I'd be happy with this change. One other thought about suggesting it for cmark: users of cmark don't need this, since it's not that hard to insert new code between parsing and rendering if you are working in C. A way to do that in your package without running external C code would be to offer the R interface in two steps: one to parse, one to render to some format. The return from the parse step could be an R list object that contains all the information from the parse tree, and the rendering step could use that as input and rebuild a new parse tree from it. (Pandoc used to do this by generating JSON and then reinterpreting it, but I don't think there's a need for that here.) If you're interested in pursuing this I'd be happy to try to write it, or to test it if you write it. |
I think it would be very difficult to convert the entire cmark parse-tree structure into an R object that users can manipulate, and then even more difficult to convert an arbitrarily modified R list back to the parse tree for cmark. I don't think there is a reliable way to do this honestly, there would be many ways the user can accidentally corrupt the parse tree. If you want to manipulate the parsed document, the best way is to use the xml representation of the parse tree using tinkr rather than trying to convert everything to R lists and back. |
Thanks, I was unaware of |
Requested by @dmurdoch. Fixes #28
If we have settled on the format, we should try to upstream this in cmark.