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

Support for sourcepos extension recursively, to provide sync-preview. #50

Open
belonesox opened this issue May 3, 2024 · 3 comments
Open

Comments

@belonesox
Copy link
Contributor

belonesox commented May 3, 2024

I am working on vscode extension that provide WYSIWYM/Latex-convinienient way
to work on complex markdown documentation with inclusions
using pandoc-include (with my patch to support it).
And with back/forward syncing like that (small demo):

demo-screencast.mp4

The key feature from pandoc core is core sourcepos extension that can add JSON-tags "datapos" to output.
The problem is that pandoc-include does "not inherit" filters from main document.

So to support it, I wrote couple of fast LUA filters:

  • desourcepos.lua — special LUA-filter to remove sourcepos tags to read "pure" inclusion command in pandoc-include.
  • filename-sourcepos.lua — special LUA-filter to add filename to sourcepos tags when we including files in pandoc-include

And add supporting PANDOC_SOURCE_FORMAT environment variable, if it exists, that would mean that we use this format for included files, and add special processing to add included filename to sourcepos tags.

First, before we get into PR, I want to discuss whether this approach looks good.

@DCsunset
Copy link
Owner

DCsunset commented May 5, 2024

I'm not very familiar with the sourcepos extension, but what you are trying to do seems to be passing a few more options to the pandoc command when parsing other files. Is that correct?

@belonesox
Copy link
Contributor Author

belonesox commented May 5, 2024

Yes, in short, if you dont want to dive into supporting sourcepos extension:

  • pass some options to parse included files (including setting variable to included filename)
  • pass some options to "reverse parse" when we looking for "!include"

@DCsunset
Copy link
Owner

DCsunset commented May 5, 2024

As for passing options, I believe we can make it more general, like supporting template variables {filename} in pandoc-options. We can also add an option to support setting arbitrary env variables.

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

No branches or pull requests

2 participants