markdown-pp
markdown-pp copied to clipboard
Variables
I suggest implementing variables. There might be a header section where variables are defined:
product: GitHub
Then some way to reference in the MD doc, like {{product}}.
+1
@jreese if there's interest, I can work on a quick PR.
If this is going to be implemented, I would like it to follow something like this:
- Use YAML-style "documents" with separators:
- if the first "document" parses as a valid YAML document, it defines variables, otherwise it's treated as MarkdownPP
- all other "documents" are treated as pure MarkdownPP
- MarkdownPP documents are rendered through a template library (I prefer Jinja using the variables from above
- If no YAML/variables defined, then don't render templates at all
- Have a good story for how variables are passed/rendered into sub documents via
!INCLUDE[URL]
and use the same process for defining/rendering variables in those sub documents.
I've actually done something more or less just like this in a different project (Nib), if you'd like inspiration for implementation, or if you'd like to factor that out into a library of some sort.
Anything new about this? Would really need something like that :angel:
Over at https://github.com/SAFETAG/SAFETAG/ ; we use markdown-pp to compile together a ton of files into one guide for HTML/PDF/etc. construction. We'd love to move more content into a YAML-y metadata header; but this would be local to each sub-file rather than global. If there is movement here, it would be great to enable a few other paths for usage of YAML metadata/variables.
A likely difficult (if handy for my use case!), or at least likely to lead to confusing states option: YAML variables are valid until / reset by the next YAML block
A less powerful, but certainly much easier option would be to spit out a table (what github does; see https://github.com/SAFETAG/SAFETAG/blob/master/en/exercises/assessment_plan/index.md for an example of yaml rendered as a table)