jgm / djot.js

JavaScript implementation of djot
MIT License
146 stars 16 forks source link

Expose overrides as a cli flag #32

Open matklad opened 1 year ago

matklad commented 1 year ago

https://github.com/jgm/djot.js/pull/4 added an ability to customize html rendering. It only added programmatic API, but we should expose this as a CLI as well.

I think a good name for the flag would be --html-template slides.js (might also rename "overrides" to "template" in the API).

jgm commented 1 year ago

The concept of a "template" is used in pandoc (and many other places) for something that would get filled by the fragment created by renderHTML to produce a "standalone" document. See the User's Guide In pandoc these templates can have variables that are filled, e.g., by metadata or programatically. I think it would be confusing to use the name "template" for this different thing, so I'd prefer to stick with "overrides" (or maybe there's a better name).

jgm commented 1 year ago

Note that you can take advantage of pandoc's templates already:

djot -t pandoc | pandoc -f json -s --metadata title="Foo bar" --metadata author="You" -o my.html

should give you nice output.

matklad commented 1 year ago

I think it would be confusing to use the name "template" for this different thing, so I'd prefer to stick with "overrides" (or maybe there's a better name).

On the one hand, yes, on the other hand, I feel like overrides are not that different, as they are a generalization of the idea. Pandoc's template is an an override for the root doc element essentially.

From another angle, asciidoctor-web is using --template-require argument for this same thing: https://github.com/Mogztter/asciidoctor-web-pdf#custom-layout.

No super-strong opinion here. An obvious solution is to expose --overrides cli flag and punt on the naming for now.