Skip to content

Instantly share code, notes, and snippets.

@Kedrigern
Created November 29, 2013 15:56
Show Gist options
  • Save Kedrigern/7707722 to your computer and use it in GitHub Desktop.
Save Kedrigern/7707722 to your computer and use it in GitHub Desktop.
Syntax highlight and markdown via Pandox
#!/bin/bash
header="header.html.part"
for input in *.md; do
output="${input%.md}.html"
echo "input: $input output $output"
pandoc --no-highlight -o "$output" -H "$header" "$input"
sed -i 's/<pre\([a-zA-Z0-9="";:-\ ]*\)><code>/<pre\1>/g
s/<\/code><\/pre>/<\/pre>/g' "$output"
done;
<script type="text/javascript" src="http://alexgorbatchev.com/pub/sh/current/scripts/shCore.js"></script>
<script type="text/javascript" src="http://alexgorbatchev.com/pub/sh/current/scripts/shBrushJScript.js"></script>
<link type="text/css" rel="stylesheet" href="http://alexgorbatchev.com/pub/sh/current/styles/shCoreDefault.css"/>
<script type="text/javascript">SyntaxHighlighter.all();</script>

Markdown test file

Example of converting markdown via Pandoc with extendet support of highlight code in html.

Headings

heading 3

heading 4

heading 5
heading 6

Code pretty print

For pretty print I am using SyntaxHighlither and some post script. Result:

/**
 * @param {int} a
 * @param {int} b
 * @return {int}
 **/
function sub(a, b) {
	return a - b;
}

/**
 * @class A
 */
function A() {
	
}

/**
 * Some method of class A
 */
A.prototype.method1 = function() {

}

Tables

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment