Open full view…

Code syntax highlighting

Fri, 22 Jan 2016 16:10:46 GMT

When writing guides for code, markdown is a nice choice. Code syntax highlighting is impossible to find in a markdown editor!

Mike Ward
Fri, 22 Jan 2016 16:15:43 GMT

This feature is on my "some day" list. The editor supports it, but weaving it in with the current markdown syntax highlighting presents some challenges.

Wed, 27 Jan 2016 16:04:39 GMT

I have the same question. This post shows how you can edit HTML template to enable Latex, and I made it work. Is there any way we can do this the same way?

Mike Ward
Wed, 27 Jan 2016 16:05:48 GMT

Mathjax is already enabled in Markdown Edit

Sun, 01 May 2016 20:27:56 GMT

Anyone succeeded integrating Syntax Highlighting Engine? I tried this: Had no success.

Mike Ward
Sun, 01 May 2016 21:47:09 GMT

I think there's some confusion here. Syntax highlighting on the editor side is what I'm referring to. Syntax highlighting in the Preview (HTML) is a different issue. Preview gets refreshed every time the document changes. That means the syntax highlighting has to be reapplied. There's an event triggered when the preview updates.

Mon, 05 Sep 2016 15:43:05 GMT

Hi Mike, any chance to have this issue in the work: I really miss the Code Block Syntax Highlighting. Thank You.

Mike Ward
Tue, 06 Sep 2016 14:04:47 GMT

Someday :)

Tue, 06 Sep 2016 16:22:10 GMT

I see. Is there an hand made solution for the meantime? Thank You.

Mike Ward
Tue, 06 Sep 2016 17:03:24 GMT

GitHub markdown supports syntax highlighting. Would that work?

Wed, 07 Sep 2016 14:56:19 GMT

Where can I try it? Does it support C / C++ / MATLAB Syntax Highlighting? Thank You.

Mike Ward
Wed, 07 Sep 2016 15:25:30 GMT

According to Pandoc it should work on fenced code blocks by specifying the language, but it's not for some reason. I'll investigate --- pandoc.exe 1.17.2 Compiled with texmath, highlighting-kate 0.6.2. Syntax highlighting is supported for the following languages: abc, actionscript, ada, agda, apache, asn1, asp, awk, bash, bibtex, boo, c, changelog, clojure, cmake, coffee, coldfusion, commonlisp, cpp, cs, css, curry, d, diff, djangotemplate, dockerfile, dot, doxygen, doxygenlua, dtd, eiffel, elixir, email, erlang, fasm, fortran, fsharp, gcc, glsl, gnuassembler, go, hamlet, haskell, haxe, html, idris, ini, isocpp, java, javadoc, javascript, json, jsp, julia, kotlin, latex, lex, lilypond, literatecurry, literatehaskell, llvm, lua, m4, makefile, mandoc, markdown, mathematica, matlab, maxima, mediawiki, metafont, mips, modelines, modula2, modula3, monobasic, nasm, noweb, objectivec, objectivecpp, ocaml, octave, opencl, pascal, perl, php, pike, postscript, prolog, pure, python, r, relaxng, relaxngcompact, rest, rhtml, roff, ruby, rust, scala, scheme, sci, sed, sgml, sql, sqlmysql, sqlpostgresql, tcl, tcsh, texinfo, verilog, vhdl, xml, xorg, xslt, xul, yacc, yaml, zsh ---

Wed, 07 Sep 2016 15:39:11 GMT

Hi, Hi tried: ```matlab Some Code.... Some Code.... Some Code.... ``` The PDF didn't yield any Syntax Highlighting. I will try for C as well. By the way, is there a way to integrate Syntax Highlighting for the Preview? Something like MathJax for the Math?

Mike Ward
Wed, 07 Sep 2016 23:20:24 GMT

Turns out Pandoc does inject styling info into the code blocks but you have to generate the doc in `--standalone` mode to get the colors. I grabbed all the different code block styles Pandoc generates and put them in a [gist]( Copy and paste into the head of you `user_template.html` and uncomment one of the style blocks. I'll add this to the default template in MDE.