JunoLab / Weave.jl

Scientific reports/literate programming for Julia
http://weavejl.mpastell.com
MIT License
830 stars 96 forks source link

Provide public APIs to customize internal execution/format logic #308

Open JonasIsensee opened 4 years ago

JonasIsensee commented 4 years ago

Hi,

I'm currently trying to use Weave to export a bunch of jupyter notebooks to pdf. The very basic exporting with md2pdf or md2tex works but I struggle with customization. As an example: There is an output format texminted implemented already but when I use it, I get a .tex file where only the code has been put into minted environments. All markdown is unchanged → not a valid .tex file. Therefore at this time there is no usable way to use e.g. md2tex to export to tex with minted environments.

I've used the debugger to step through the weaving process and right now it seems that the structure is not very customizable and maybe some work would be needed. Would it be useful to optionally let the user pass a self-configured JMarkdown2tex object?

As always, I'm willing to help but I would very much appreciate some feedback first. What are your thoughts?

aviatesk commented 4 years ago

sorry for being so late to reply, and thanks for your issue report. and yeah, currently we only provider very crude support for latex ...

As for the issue that tex and texminted output formats are not really a valid tex file, it seems clearly to be an internal bug. I found our formatter (, well, "formatter" is honestly really bad naming, rather we should call "renderer") doesn't do any task to convert our internal format (WeaveDoc) to tex file, while there is such a conversion done for md2tex format. (if interested, see https://github.com/JunoLab/Weave.jl/blob/b8b9b095b7d2196a04fb8d2b868743b5143d55ba/src/format.jl and check there is only format_hoge functions defined for md2tex and md2html formats) I think we need to define/overload functions to render tex for tex and texminted formats there as well, and then they will produce valid tex files.

And for output customization, As for formats that Weave already supports, users can have their own templates (, which uses Mustache.jl's template format) and that will allow basic rendering customization, but if they aren't satisfied with how we run chunks, render chunks, then they want to have their own formats. To provide customization (rather than directly changing Weave internal), I think we refactor internal APIs first. And then we may be able to export some public API functions, which are supposed to be overloaded by each user to define their own output formats. Internal API refactors are undergoing, and hopefully we can be able to think about publishing some internal APIs in the future.

aviatesk commented 4 years ago

Let's focus on providing public APIs for customization for this issue. For issues around tex and texminted formats, let's continue on another issue