markdown-pp icon indicating copy to clipboard operation
markdown-pp copied to clipboard

Variables

Open bumper314 opened this issue 8 years ago • 5 comments

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}}.

bumper314 avatar Mar 10 '16 14:03 bumper314

+1

leotrs avatar Jul 01 '16 23:07 leotrs

@jreese if there's interest, I can work on a quick PR.

leotrs avatar Jul 22 '16 14:07 leotrs

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.

amyreese avatar Jul 22 '16 18:07 amyreese

Anything new about this? Would really need something like that :angel:

julesmaregiano avatar Apr 30 '19 11:04 julesmaregiano

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)

joncamfield avatar Jul 11 '19 18:07 joncamfield