JunoLab / Weave.jl

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

Allow YAML header in output file #300

Closed JonasIsensee closed 4 years ago

JonasIsensee commented 4 years ago

Hi,

here's another small PR, this time concerning #197 . I modified the function strip_headerto look for a field called output_header in the YAML header given in the input file. If it exists, its contents are then reexported into YAML and added as a header for the output file.

A test is added as well. What are your thoughts ? I have not added anything in the documentation yet because I wasn't sure where it would fit best.

aviatesk commented 4 years ago

nice, will give a review on this (and the other one) this weekend 😉

aviatesk commented 4 years ago

Thanks @JonasIsensee , when trying to review this, I finally crafted #305 by myself 😅 How about only striping Weave headers when generating markdown ? AFAIU, all the other output format expects no header YAML at this point.

JonasIsensee commented 4 years ago

Hi, your suggestion sounds good. Just to make sure: The header could also be preserved when converting a jupyter notebook to .jmd?

aviatesk commented 4 years ago

no, afaiu there's no YAML header spec in notebooks. Could you elaborate your idea ?

JonasIsensee commented 4 years ago

What you are saying is probably correct but my use case is the following:

I do numerical simulations in jupyter notebooks along with extensive markdown explanations. Once finished (or after updates) I use weave to export this to markdown for use in a jekyll website. Jekyll needs a yaml header. I don't want to edit my output markdown files, so i put the YAML in the first notebook cell.

So for maximal flexibility I would like there to be a way to preserve the header during weaving (and maybe during conversion between jmd and notebook)

aviatesk commented 4 years ago

ah I see. If you put a YAML header in the first markdown cell, and weaving (or converting) your notebook into markdown, then the YAML header will be preserved as the other markdown contents. Well, the YAML header will look weird in the Jupyter notebook frontend, since there is no spec for YAML rendering.

JonasIsensee commented 4 years ago

Yeah, it looks a bit odd but I don't mind if it allows me to not have to edit all output files every single time after re-exporting.

aviatesk commented 4 years ago

okay close in favor of #305