adityam / filter

ConTeXt module to process contents of a start-stop environment through an external program
47 stars 10 forks source link

process LaTeX fragments? #58

Closed denismaier closed 2 years ago

denismaier commented 2 years ago

Is it possible to process LaTeX fragments with this? Of course, I could use pandoc but that may add too much unnecessary complexity.

denismaier commented 2 years ago

Use case: I'm thinking about converting my LaTeX training docs to context, but I'll need to have code examples in there and show the results.

adityam commented 2 years ago

You mean something like this TeX.SE example? This only shows the result, but you can show the results via \typebuffer or using the vim module for syntax highlighting.

denismaier commented 2 years ago

Yes, that looks intersting. Thanks for the hint. So, you'll just need to define wrapper commands that will construct a valid latex document?

adityam commented 2 years ago

Yes. The way to think about it is as follows. The \start<filter> ... \stop<filter> environment writes a file with the following content:

and then runs the filtercommand. So, if you can generate a valid LaTeX file such that running pdflatex gives you a cropped PDF, it is easy to include it back in ConTeXt.