Closed lukesmurray closed 4 years ago
You can do this:
## References
::: #refs
:::
Thank you for the solution! That does get me the desired header level (although for future readers I needed brackets)
## References
::: {#refs}
:::
However, my use case is publishing a site with many pages. The downside of the proposed approach is I need to add those lines to every markdown document on my site, which is not very DRY, and if there are no references on a page then I get a needless section title.
Its very nice that the reference-section-title
can be set in one place (data file), and that the reference section and title are only added to the output document when needed. A flag or setting to set the section level would provide a DRY way of keeping these behaviors while avoiding the issue of multiple h1
tags.
That being said I know this is open source so if you feel there isn't enough justification to add a new flag feel free to close this.
As you said, you could also use a filter. Just make sure that it runs after pandoc-citeproc, so it can operate on the result. Filters are run in the order in which they are given on the command line.
Here's a possible solution which shifts the References header level:
function Header (h)
if h.identifier == 'references' then
h.level = 2
return h
end
end
Filter is a good solution!
Thanks for helping me out. A filter is much cleaner than a flag. For posterity the final filter I used just replaces all level 1 headers with level 2 headers.
function Header (elem)
if elem.level == 1 then
elem.level = 2
return elem
end
end
In my case this is fine since I don't want any level 1 headers.
@lukesmurray If that's what you want you may also be able to use --shift-heading-level-by=1
Thanks @jgm. I ended up using a combo of what you and Tarleb suggested. I used --shift-heading-level-by=-1
. That flag makes the first # heading
the metadata title. I then use a filter to add 1 to the rest of the headings regardless of their level. The references header becomes an h2
tag which I desire and the rest of my headings have the same level as what I indicate in my markdown.
I've sort of hacked in the markdown style I want (which is only possible cause I only target html output). Thanks for making everything so configurable :rocket:.
# Title
## Heading
## Heading
The header level for the
reference-section-title
is h1. I personally prefer to only have one h1 tag on a page and pandoc normally makes the title an h1 tag. Is it possible to set the default level to h2 through an existing flag. Could pandoc-citeproc add support for something similar to the pandoc flag--shift-heading-level-by
.Alternatively I would be happy to use a filter to replace the h1 with an h2 but I'm not sure how to hook a filter into the citeproc output.
Please let me know if there is a better place to ask this question.
Thank you