I am writing a document in LaTeX and I need to add some Markdown code fragments with highlighted syntax. Right now I'm using listings library for all my code fragments but listings doesn't support markdown as language. I'm not able to find any custom Markdown language extension or configuration to use. Is there anyone who was facing the same problem? Is there any custom Markdown syntax highlighting setup for listings to use?

  • 2
    Section 12.4 of the documentation sends you to section 5.16.
    – Johannes_B
    May 7 '18 at 10:09

Take a look on the manual on CTAN. In particular the section you are looking for is 5.16 Language definitions. The basic usage is something like

  [[〈base dialect〉]{〈and base language〉}]
  {〈key=value list〉}
  [[〈list of required aspects (keywordcomments,texcs,etc.)〉]]

In particular, look for the string and morestring tag. The first step should be to cast correctly italic, bold and nested italic-bold strings. Also cast correctly the titles should be easy. A slighty more difficult would be to correctly cast lists and tables. You can also look at the original markdown syntax by John Gruber and the syntax of github markdown as reference. If you want to do a very good job I suggest you to impement them both as dialects of markdown language. If you are successful yo can also send the result to the author in order to be included in the next version.

If you have troubles post your work so far and we'll try to help you.

Happy coding!!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.