kristapsdz / lowdown

simple markdown translator
https://kristaps.bsd.lv/lowdown
ISC License
294 stars 36 forks source link

Query about metadata #113

Open leath-dub opened 1 year ago

leath-dub commented 1 year ago

Hey, first off love this project, great work on this!

Anyhow I using the lowdown library and wonder if there is a way to add metadata that would enable you to prepend and append html to the output. I know that in MultiMarkdown, you have HTML Header and HTML Footer.

If there is no way to do this, is there an alternative solution to the problem ? would you know where I can make a patch in the code ? (where is the metadata handler ?), thanks for your time :).

EDIT: also wonder if there would be a way to override the tags that lowdown adds in, allowing you to provide your own boilerplate

kristapsdz commented 1 year ago

There are such keys in other formatters (e.g., HTML Header), however, they're really poorly thought out: there's no mention as to where in the header they're noted, or whether they replace other media-specific metadata (e.g., title), etc. In general, the metadata concept of markdown is fragmented and poorly documented (with exception to lowdown ofc, which tries hard to document everything).

What I suggest is using lowdown to generate the "body" of the document, then writing your own header and footer and using a Makefile or similar to cat them together . E.g.,

% cat >output.html <<!!
<html>
 <head>
  <title>foo</title>
 </head>
 <body>
!!
% lowdown -thtml yourdoc.md >>output.html
% cat >>output.html <<!!
 </body>
</html>
!!

This can be done using the library by passing FILE pointers and dumping into them before and after the renderer.