Skip to content

Instantly share code, notes, and snippets.

@yoavram
Created December 13, 2012 23:39
Show Gist options
  • Save yoavram/4281136 to your computer and use it in GitHub Desktop.
Save yoavram/4281136 to your computer and use it in GitHub Desktop.
Comparing Code highlighters in JS
<html>
<head>
<!-- LaTeX support-->
<!--extensions: ["tex2jax.js"],
jax: ["input/TeX", "output/HTML-CSS"],
tex2jax: {
inlineMath: [ ['$','$'], ["\\(","\\)"] ],
displayMath: [ ['$$','$$'], ["\\[","\\]"] ],
processEscapes: true
},-->
<script type="text/x-mathjax-config">
MathJax.Hub.Config({
"HTML-CSS": { availableFonts: ["STIX", "TeX"] }
});
</script>
<script type="text/javascript"
src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_HTML">
</script>
<!-- google code prettifier http://code.google.com/p/google-code-prettify/ -->
<link href="http://blog.yoavram.com/static/prettify.css" type="text/css" rel="stylesheet" />
<script type="text/javascript" src="http://blog.yoavram.com/static/prettify.js"></script>
<!-- syntax highlighter -->
<link href="http://alexgorbatchev.com/pub/sh/current/styles/shThemeDefault.css" rel="stylesheet" type="text/css" />
<script src="http://alexgorbatchev.com/pub/sh/current/scripts/shCore.js" type="text/javascript"></script>
<script src="http://alexgorbatchev.com/pub/sh/current/scripts/shAutoloader.js" type="text/javascript"></script>
<script src="http://alexgorbatchev.com/pub/sh/current/scripts/shBrushPython.js" type="text/javascript"></script>
<!-- SHJS -->
<script type="text/javascript" src="http://shjs.sourceforge.net/sh_main.min.js"></script>
<script type="text/javascript" src="http://shjs.sourceforge.net/lang/sh_python.min.js"></script>
<link href="http://shjs.sourceforge.net/css/sh_the.css" rel="stylesheet" type="text/css" />
<!-- highlight.js-->
<link rel="stylesheet" href="http://yandex.st/highlightjs/7.2/styles/googlecode.min.css">
<script src="http://yandex.st/highlightjs/7.2/highlight.min.js"></script>
<script>hljs.initHighlightingOnLoad();</script>
</head>
<body onload="sh_highlightDocument();prettyPrint()">
<div class="container offset1">
<h1>Hello math</h1>
<h2>MathJax</h2>
<div class="row-fluid">
<div class="span10">
When \(a \ne 0\), there are two solutions to \(ax^2 + bx + c = 0\) and they are $$x = {-b \pm \sqrt{b^2-4ac} \over 2a}.$$
</div>
</div>
<h1>Hello Python</h1>
<h2>syntaxhighlighter</h2>
<div class="row-fluid">
<div class="span8">
<pre class='brush: python'>
#!/usr/bin/python
"""
xml2html: Convert XML to HTML
*** SUPERSEDED by pyslt ***
Uses SAX (event-based parsing).
***LICENSE***
"""
_ID = '$Id: xml2html-1.01-1.py,v 1.1.1.1 2000/01/15 14:37:46 ecoaccess Exp $'
import sys, copy
from xml.sax.drivers.drv_xmlproc_val import *
class myParser(SAX_XPValParser):
"""XML parser."""
psl = None
def handle_doctype(self, rootname, pub_id, sys_id):
self.dtd_handler.doctypeDecl(rootname, pub_id, sys_id, self.psl)
</pre>
</div>
</div>
<h2>shjs</h2>
<div class="row-fluid">
<div class="span8">
<pre class="sh_python">
#!/usr/bin/python
"""
xml2html: Convert XML to HTML
*** SUPERSEDED by pyslt ***
Uses SAX (event-based parsing).
***LICENSE***
"""
_ID = '$Id: xml2html-1.01-1.py,v 1.1.1.1 2000/01/15 14:37:46 ecoaccess Exp $'
import sys, copy
from xml.sax.drivers.drv_xmlproc_val import *
class myParser(SAX_XPValParser):
"""XML parser."""
psl = None
def handle_doctype(self, rootname, pub_id, sys_id):
self.dtd_handler.doctypeDecl(rootname, pub_id, sys_id, self.psl)
</pre>
</div>
</div>
<h2>google code prettifier</h2>
<div class="row-fluid">
<div class="span8">
<pre class="prettyprint">
class Voila {
public:
// Voila
static const string VOILA = "Voila";
// will not interfere with embedded tags.
}
</pre>
</div>
</div>
<h2>highlight.js</h2>
<div class="row-fluid">
<div class="span8">
<pre><code>
#!/usr/bin/python
"""
xml2html: Convert XML to HTML
*** SUPERSEDED by pyslt ***
Uses SAX (event-based parsing).
***LICENSE***
"""
_ID = '$Id: xml2html-1.01-1.py,v 1.1.1.1 2000/01/15 14:37:46 ecoaccess Exp $'
import sys, copy
from xml.sax.drivers.drv_xmlproc_val import *
class myParser(SAX_XPValParser):
"""XML parser."""
psl = None
def handle_doctype(self, rootname, pub_id, sys_id):
self.dtd_handler.doctypeDecl(rootname, pub_id, sys_id, self.psl)
</code></pre>
</div>
</div>
</div>
<!-- syntax highlighter -->
<script type="text/javascript">
SyntaxHighlighter.all()
</script>
</body>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment