-
-
Notifications
You must be signed in to change notification settings - Fork 3.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add a template variable containing the name of the source file #3431
Comments
A reasonable request. But to mention one complexity: pandoc can take multiple input files on the command line. It can also parse from stdin, in which case there are no input files. Both cases would have to be handled as well. |
Right! I just used |
BTW, I tried to do a pull-request myself, but I couldn't figure out where the template variables are set in the code… Any pointers on that? :) |
Thanks for your initial pointer :) I didn't want to patch every single
writer, but I was able to work my way up to where the metadata comes
from :) See pull-request #3439 for what I currently have.
Since this is my first time using Haskell in a project, the last two
days were spent for a lot of reading documentation and understanding the
code, and there will probably still be a couple days to get it working…
;-) I'll raise my voice when I think the pull-request is ready.
- Roland
…On 12.02.2017 12:02, Mauro Bieg wrote:
For the template variable to be available in all formats, I think you'll
ned to make sure it is set in this |doc'|
<https://github.com/jgm/pandoc/blob/master/src/Text/Pandoc/App.hs#L376>.
The |doc'| should be of type |Pandoc meta blocks|, so specifically it
should be in the |meta| of type Meta
<https://github.com/jgm/pandoc-types/blob/master/Text/Pandoc/Definition.hs#L103>.
But I'm not sure where the proper place to set it is...
|
No, the best approach is to set a variable, not metadata. Variables just affect template rendering, which is what you want. Just add it to writerVariables in Text.Pandoc.App. |
@mb21 you're welcome, I learned a lot today! :D That solution was also what had first had in mind, but somehow I didn't follow it. It took less time than expected, and I consider #3439 ready now. I still don't quite understand how exactly the |
I keep several Markdown documents in a Git repository which are rendered to MediaWiki through a custom template. In the MediaWiki template, I want to add a "this file is autogenerated" warning, with a link to the source file in the Git repository. For this reason, it would be nice to have a template variable, e.g.
$filename$
or$jobname$
(inspired by LaTeX), so my template could have:The text was updated successfully, but these errors were encountered: