I am using pypandoc to convert a markdown file to LaTex. My markdown file has a header, for example:
# Header Text #
When pypandoc renders the file as a .tex file, this appears as:
\hypertarget{header-text}{%
\section{Header Text}\label{header-text}}
While this is a nice feature to make it easy to link back to section headers, I don't necessarily want that and would prefer in this case for pypandoc to just generate:
\section{Header Text}
Is there a pandoc setting, or a pypandoc setting, that can be used to turn off the \hypertarget{} feature? I have reviewed the documentation for pandoc and didn't see it anywhere.
There is no such switch. If you want different output, you'd either have to use a pandoc filter or, as @mb21 already noted, post-process the output.
Neither of these options is very good: using a filter to manually define header output will lose you all kinds of other pandoc features, like
--top-level-division
and support for unnumbered headers. Post-processing, on the other hand, tends to be brittle and difficult to get right.Anyway, below is a panflute filter, which will replace headers with a custom command. Save it to a file and pass it to pypandoc via the
filters
option; this should give you the desired output.