Jan Erik Moström
2014-Sep-23 12:43 UTC
Source code highlighting in Markdown (currently Multimarkdown)
I'm using a script to convert a set of markdown files to static web sites - sites for various courses I'm teaching. This script uses multimarkdown to do the actual conversion. Since I mostly teach various programming courses I would like to have syntax highlighting of the source code I present. What is the best way to do this? I'm producing sites that is either: + Static webpages where I can decide everything (almost) + HTML that is included in a CMS where I have very very very very little control of how things should be displayed. I can basically enter HTML code in a field and hope that it turns out OK What recommendations do have for doing this? I can for example see that multimarkdown uses fenced code blocks that assumes that I have the ability to use a javascript library to do the actual syntax hightlighting. Which would work in the first case but probably not in the second.
John MacFarlane
2014-Sep-23 15:09 UTC
Source code highlighting in Markdown (currently Multimarkdown)
+++ Jan Erik Mostr?m [Sep 23 14 14:43 ]:>I'm using a script to convert a set of markdown files to static web >sites - sites for various courses I'm teaching. This script uses >multimarkdown to do the actual conversion. > >Since I mostly teach various programming courses I would like to have >syntax highlighting of the source code I present. > >What is the best way to do this?Pandoc will highlight fenced code blocks, no external libraries required. And it will work the same whether the output is HTML, EPUB, LaTeX/PDF, or Word. Pandoc has a somewhat different set of features than multimarkdown (https://github.com/jgm/pandoc/wiki/Pandoc-vs-Multimarkdown) but will emulate most of the mmd syntax if you use `-f markdown_mmd`. So it might suit your needs. John
Alan Hogan
2014-Sep-23 16:24 UTC
Source code highlighting in Markdown (currently Multimarkdown)
Jan, It seems like you might already know of highlight.js: https://highlightjs.org/ <https://highlightjs.org/> I understand that this may not seem to address use case #2, but since highlight.js supports node.js, you can probably use it in your build scripts (instead of in the browser). Note also that some Markdown flavors, such as Github Flavored Markdown and the sort-of fork CommonMark, have syntaxes for explicitly declaring which kind of code you?ve embedded into your document: https://jgm.github.io/stmd/spec.html#info-string <https://jgm.github.io/stmd/spec.html#info-string> It looks like this: ```css * { font-family: "jokewood" !important; } ``` You can compare various flavors? output of this code, here: http://ajh.us/babelmark2-fenced-code-with-info-string> On Sep 23, 2014, at 5:43 AM, Jan Erik Mostr?m <lists at mostrom.pp.se> wrote: > > I'm using a script to convert a set of markdown files to static web > sites - sites for various courses I'm teaching. This script uses > multimarkdown to do the actual conversion. > > Since I mostly teach various programming courses I would like to have > syntax highlighting of the source code I present. > > What is the best way to do this? > > I'm producing sites that is either: > > + Static webpages where I can decide everything (almost) > + HTML that is included in a CMS where I have very very very very > little control of how things should be displayed. I can basically > enter HTML code in a field and hope that it turns out OK > > What recommendations do have for doing this? > > I can for example see that multimarkdown uses fenced code blocks that > assumes that I have the ability to use a javascript library to do the > actual syntax hightlighting. Which would work in the first case but > probably not in the second. > _______________________________________________ > Markdown-Discuss mailing list > Markdown-Discuss at six.pairlist.net > https://pairlist6.pair.net/mailman/listinfo/markdown-discuss-------------- next part -------------- An HTML attachment was scrubbed... URL: <https://pairlist6.pair.net/pipermail/markdown-discuss/attachments/20140923/9ea5360b/attachment-0001.html>
Waylan Limberg
2014-Sep-23 22:17 UTC
Source code highlighting in Markdown (currently Multimarkdown)
Jan, Python-Markdown offers a [codehilite] extension which may meet your needs as well. Python-Markdown also offers a number of other [extensions] which provide similar functionality to MMD. As an aside, our CodeHilite Extension wraps the [Pygments] code highlighting library. Pygments also offers a command line script. You could possibly pass you HTML generated by MMD through the Pygments script and get highlighted code that way. As Pygments is implemented in Python, Python-Markdown can easily remove that step with no need to call an outside process (as some tools do). Waylan [codehilite]: https://pythonhosted.org/Markdown/extensions/code_hilite.html [extensions]: https://pythonhosted.org/Markdown/extensions/index.html [Pygments]: http://pygments.org/ -----Original Message----- From: Markdown-Discuss [mailto:markdown-discuss-bounces at six.pairlist.net] On Behalf Of Jan Erik Mostr?m Sent: Tuesday, September 23, 2014 8:43 AM To: Discussion related to Markdown. Subject: Source code highlighting in Markdown (currently Multimarkdown) I'm using a script to convert a set of markdown files to static web sites - sites for various courses I'm teaching. This script uses multimarkdown to do the actual conversion. Since I mostly teach various programming courses I would like to have syntax highlighting of the source code I present. What is the best way to do this? I'm producing sites that is either: + Static webpages where I can decide everything (almost) HTML that is + included in a CMS where I have very very very very little control of how things should be displayed. I can basically enter HTML code in a field and hope that it turns out OK What recommendations do have for doing this? I can for example see that multimarkdown uses fenced code blocks that assumes that I have the ability to use a javascript library to do the actual syntax hightlighting. Which would work in the first case but probably not in the second. _______________________________________________ Markdown-Discuss mailing list Markdown-Discuss at six.pairlist.net https://pairlist6.pair.net/mailman/listinfo/markdown-discuss