lierdakil / pandoc-crossref

Pandoc filter for cross-references
https://lierdakil.github.io/pandoc-crossref/
GNU General Public License v2.0
911 stars 72 forks source link

Influence of code page in MSYS2 bash shell in Windows 10 #385

Open sdbbs opened 1 year ago

sdbbs commented 1 year ago

Not sure if this is really a bug - but I just noticed it, and I thought I should report it (maybe there should be a note in documentation):

I typically use pandoc through the MSYS2 bash shell, running in Windows Terminal on Windows 10.

I've recently had some crossref problems, so I thought I'd check the version and help:

$ pandoc-crossref.exe --version
pandoc-crossref v0.3.10.0 git commit 2b62c009b52ea8b65e58666fe2fa0c8963a5002e (HEAD) built with Pandoc v2.13, pandoc-types v1.22 and GHC 8.10.4

$ pandoc-crossref.exe --help
pandoc-crossref - Pandoc filter for cross-references
....
  --man                    Show manpage
...

And there I noticed the --man option for the first time, so I thought I'd try it:

$ pandoc-crossref.exe --man
pandoc-crossref is a pandoc filter for numbering figures, equations,
tables and cross-references to them.
...
Default settings will produce the following equivalent Markdown from
example above:

    <div id="fig:figureRef" class="subfigures">

    ![a](image1.png){#fig:figureRefA}

    ![b](image2.png){#fig:figureRefB}

    Figure 1: Caption of figure. a pandoc-crossref.exe: <stdout>: commitAndReleaseBuffer: invalid argument (invalid character)

Now looking at that "invalid argument (invalid character)", that certainly does not look like a man page text - so looks like the program itself crashed while generating the man page! And since it says "invalid character", I eventually suspected the code page of the terminal/shell:

$ chcp.com
Active code page: 437

UTF-8 in Windows is code page 65001 - so I changed to that, and suddenly the --man command line option prints the entire man page:

$ chcp.com 65001
Active code page: 65001

$ pandoc-crossref.exe --man
pandoc-crossref is a pandoc filter for numbering figures, equations,
tables and cross-references to them.
...
Default settings will produce the following equivalent Markdown from
example above:

    <div id="fig:figureRef" class="subfigures">

    ![a](image1.png){#fig:figureRefA}

    ![b](image2.png){#fig:figureRefB}

    Figure 1: Caption of figure. a — subfigure 1 caption, b — subfigure 2
    caption

    </div>
...
License

This program is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 2 of the License, or (at your
option) any later version.

Good, it works now - just wanted to jot this down, as it is not really obvious ...