pandoc
pandoc copied to clipboard
Fix unintended behavior for template search with custom writer
As noted in #8135, if the writer is latex-foo-bar.md, the default latex template will be used (-foo-bar.md is stripped off as extensions when doing template search). This is unintended behavior and should be fixed.
Is there another way to use a standard template with a custom writer which looks like a legit use case ? If not, should we consider having one before removing this unwanted feature ?
You can specify the template explicitly using --template=default.latex, can't you?
Well ... I guess so. I must confess that after all these years, I am still confused by the way Pandoc manages its data files and configuration. Usually you have by order of priority:
- User files and conf (
.local/share/whatever) - System-wide files and conf (
/usr/share/whatever) - Things which are hardcoded in the application
As far as I understand default.latex would be a mix of 2 and 3; i.e. hard-coded and behaving as if it was a file in some /usr/share/pandoc but not customizable system-wide.
Well this is another topic to be discussed, or not, elsewhere ...
It is customizable; you can add your own default.latex to the templates subdirectory of the user data directory. And, if your version of pandoc is compiled without the embed_data_files flag, you can also substitute the version in /usr/share/pandoc/templates.
Thanks a lot for this. I dont remember seeing anything about /usr/share/pandoc in the doc.
I tested to make a /usr/share/pandoc/templates/default.late (late, not latex ;-) ) but Pandoc failed with Could not find data file templates/default.late so I gess Ubuntu packages you provide does have the embed_data_files flag :-(
There still is an issue though !
The unintended behavior you are about to fix has a little brother: the default pdf engine.
pandoc -t latex-foo-bar.lua -o sample.pdf sample.md selects pdflatex as the pdf-engine.
with -t mylatex-foo-bar.lua it fails with cannot produce pdf output from mylatex-hk-writer.lua
Honestly it works so well that I love it. You are really sure it's unwanted ? :-D
On the pdf issue, see #7898.
All you need to do is explicitly specify --pdf-engine=pdflatex
Thanks @jgm all this makes me challenge pandoc's behaviors I was relying on.
My point with the pdf thing was to emphasis a probably unintended trick with the filter name similar to the template name one. I suspected that fixing the behavior for template will fix the behavior for pdf engine too, so I didn't open a separate issue.
I'll have to check to see whether the two issues are interwoven in that way. But both should be fixed, I think.
See also #8120 for another relevant issue.