phyllisstein / Pandown

A powerful, versatile, highly Subliminal Pandoc build wrapper for ST2/3
64 stars 12 forks source link

pandoc-crossref not working #33

Open TAKeanice opened 5 years ago

TAKeanice commented 5 years ago

I have an issue using pandoc-crossref (http://lierdakil.github.io/pandoc-crossref/) as a filter. It can be added using "filter": "pandoc-crossref" or "filter": ["pandoc-crossref"] in the pandoc-config.json. However, there seems to be some preprocessing that escapes some of the crossref syntax. A simple example would be using an image in Markdown with crossref-specific options:

![](some_image.png){#fig:image width=10%}

which includes the image but escapes the curly braces, so crossref cannot interpret them any more as parameters. This is visible when doing latex output, where the output is as follows:

\includegraphics{some_image.png}\{\#fig:image width=10\%\}

I suspect something with citations to get in the way, because the documentation warns about the order of applying citeproc and crossref (first crossref, then citeproc). I do not understand the pandown codebase yet, otherwise I would open a pull request.

TAKeanice commented 5 years ago

By comparison, when using plain pandoc from command line

pandoc -F pandoc-crossref test.md -o test.tex

the latex output is correct

\includegraphics[width=0.1\textwidth,height=\textheight]{some_image.png}

as is the generated pdf when setting -o test.pdf as output argument.

TAKeanice commented 5 years ago

I got another hint from my experiments: Adding pandoc-citeproc as a filter before pandoc-crossref has the same effect as building with pandown. However, I could not find the place where pandoc-citeproc is applied in the pandown build process.

phyllisstein commented 5 years ago

Hey there! Forgive my delay in responding. I've been mercifully, but inconveniently, a little unplugged from GitHub lately.

My gut suspicion is that the root of your issue lies in Pandown's CriticMarkup support, which is a super unsophisticated bundle of regex copypasta I grabbed from their repos and don't fully understand myself. CriticMarkup processing is (or ought to be) disabled by default, though, so I'm going to take a deeper look tonight.

In the meantime, there's a setting called preprocess_critic that'll short-circuit the processor. Try adding the following to Pandown.sublime-settings:

{
    "preprocess_critic": false
}

It should be at the first level of your settings JSON, rather than nested in pandoc_arguments or command_arguments. (Boy this code is a mess!)

It'd also be a big help in reproducing the bug if you could drop any applicable config files in this thread or in a gist. Thanks for being so patient!

TAKeanice commented 5 years ago

I am really thankful for all your advice (also the direct response via e-mail)! I will give an overview of what I did to solve everything shortly.