I'm converting markdown to HTML, and I want to include syntax-highlighted code.
I'm working from some markdown that contains syntax like:
~~~ {.c}
long factorial (int n)
{
long result = 1;
while (n > 1)
result *= n--;
return result;
}
~~~
but I don't know which syntax highlighting extension was used to process this syntax. What's a good extension?
Pandoc can convert between numerous markup and word processing formats, including, but not limited to, various flavors of Markdown, HTML, LaTeX and Word docx.
You can use the program pandoc on the SCF Linux and Mac machines (via the terminal window) to convert from formats such as HTML, LaTeX and Markdown to formats such as HTML, LaTeX, Word, OpenOffice, and PDF, among others.
How can I convert PDFs to other formats using pandoc? You can't. You can try opening the PDF in Word or Google Docs and saving in a format from which pandoc can convert directly.
Pandoc is a command-line tool for converting files from one markup language to another. Markup languages use tags to annotate sections of a document. Commonly used markup languages include Markdown, ReStructuredText, HTML, LaTex, ePub, and Microsoft Word DOCX.
Answer from comments, please edit before giving negative rating.
Pandoc does syntax highlighting automatically. You don't need an external extension.
Just be sure to use the -s
flag so you get a standalane HTML file with the CSS needed for highlighting. You can also use the --highlight-style
option to adjust the coloring scheme.
Note: These comments assume you're using the latest pandoc, 1.9.4.2.
When I add the
-s
option, I get this error message:pandoc -m -t -s slidy 7-functional-design.md -o 7-functional-design.hpart
. I get the same error message if I try adding--highlight-style=haddock
instead.
You want -s -t slidy
instead of -t -s slidy
.
slidy
is the argument for the -t option and needs to come right after it.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With