pandoc-include-code icon indicating copy to clipboard operation
pandoc-include-code copied to clipboard

Code Not Included With GitHub Flavored Markdown (gfm)

Open bloudraak opened this issue 6 years ago • 1 comments

Consider the following file hello.c

#include <stdio>
int main()
{
    fprintf(stdout, "Hello World\n");
}

Consider the following markdown document sample.md

Sample Code

```{include=hello.c}

```

Build a PDF using

pandoc --toc \
       --filter ~/.cabal/bin/pandoc-include-code \
       -f gfm \
       -o sample.pdf \
       sample.md 

Open the PDF and notice that the contents of hello.c was not included.

If you call it as follows:

pandoc --toc \
       --filter ~/.cabal/bin/pandoc-include-code \
       -f markdown \
       -o sample.pdf \
       sample.md 

then the content of hello.c is included.

bloudraak avatar Jul 26 '19 03:07 bloudraak

@bloudraak, I don’t think it’s a pandoc-include-code issue. Since gfm (GitHub Flavored Markdown) doesn’t allow attributes in curly braces, an extension is required. Try gfm+attributes. I can’t check it with a PDF engine, but it definetely works with AsciiDoc, HTML, OpenDocument Text, etc.

pandoc \
  --toc \
  --filter ~/.cabal/bin/pandoc-include-code \
  -f gfm+attributes \
  -o sample.html \
  sample.md

edukisto avatar Oct 22 '20 01:10 edukisto