litedown icon indicating copy to clipboard operation
litedown copied to clipboard

Allow template to be passed via `meta` argument?

Open TimTaylor opened this issue 1 year ago • 4 comments

Would it be worth allowing a template to be passed via the meta argument of mark? I've not thought too hard about this, and you likely have good reason for the current implementation, but I wonder if this would be a nice intermediate step between the yaml header and the global option approaches.

TimTaylor avatar Jul 03 '24 08:07 TimTaylor

Thanks for the suggestion! Previously I actually had a template argument for mark() but removed it later, since my brain started to hurt when I had three ways to provide templates for mark(). I can reconsider it if you tell me more about your use case. The only use case I can think of is to programmatically generate multiple reports using the same Markdown input with different templates.

yihui avatar Jul 03 '24 15:07 yihui

I can reconsider it if you tell me more about your use case.

Mine is a (very) basic static-site generator that walked a directory structure looking for markdown files and associated template files (a single html file for each directory). Hard-coding the template in to the yaml felt repetitive but I can enforce a standard name for the template and reset the global option for each directory. Appreciate you wanting to keep the code simple so please don't feel pressured (it's easy enough for me to make the current set-up work).

Cheers

TimTaylor avatar Jul 03 '24 15:07 TimTaylor

Thanks for the explanation! I'll think more about it. The current overriding mechanism for meta, options, and template is a little messy. That said, occasionally I feel the need for the template argument in mark() by myself, too. I also briefly thought about the case of using different templates for different directories in a website project when I was writing litedown::fuse_site().

yihui avatar Jul 03 '24 16:07 yihui

Oh interesting. I should probably explore fuse_site a bit more before continuing down my rabbit hole.

TimTaylor avatar Jul 03 '24 16:07 TimTaylor