1

How to make pandoc md to xelatex conversion understand that the code structure is within an enumeration list. The minimal code I've got in my markdown file.

* Test your code 
* Don't use structures like this

  ```cpp
  //Bad structure
  //More bad structures
  ```

  As this will cause problems.

This code correctly displays on github with the code being properly indented with respect to the list. But using a relatively simple

pandoc --latex-engine=xelatex README.md -o test.pdf

makes a mess out of it. The best thing I achieved it to actually display the code with breaking of enumeration. My other attempts would usually break the code display.

2 Answers 2

1

The following code looks OK to me. I have used a fenced code block, but it should also work with backticks.

- Test your code 
- Don't use structures like this

  ~~~ {.cpp}
  // printf("hello world");
  // prints("hello World");
  ~~~

  as this will cause problems.

I have converted this code with the above call and it looks OK to me.

1

Triple backticks are an extension to the original markdown syntax and Github and Pandoc don't implement them in a completely compatible way. In Pandoc, both the starting and ending triple backticks need to start at the left margin. In an enumeration, the left margin starts with an indentation of 4 spaces. Inside the code block, however, the left margin starts at position 0. So you need to write

* Test your code
* Don't use structures like this

    ```cpp
//Bad structure
//More bad structures
    ```

    As this will cause problems.

That doesn't work for me with GitHub's markup tool though: it doesn't recognize cpp as a language attribute, it treats it as the first line of code. The indentation makes a difference however: with your two spaces the code block terminates the enumeration, whereas with my four spaces the code block and the following text line remain in the enumeration. I think that's a bug in my version of one of the dependencies of the tool though, since the ```language syntax is definitely supported on Github.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .