Skip to content

Commit

Permalink
use pygments instead of prettify
Browse files Browse the repository at this point in the history
  • Loading branch information
ghewgill committed Jul 30, 2011
1 parent d3c63e2 commit 54c2263
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 1,534 deletions.
8 changes: 4 additions & 4 deletions function.template
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
<html>
<head>
<title>$file - picomath</title>
<link href="../prettify.css" type="text/css" rel="stylesheet" />
<script type="text/javascript" src="../prettify.js"></script>
<style type="text/css">
$style
</style>
</head>
<body onload="prettyPrint()">
<h1><a href="../index.html">picomath</a></h1>
<h2><a href="index.html">$name</a></h2>
<h3>$file</h3>
<pre class="prettyprint lang-$extension">$code</pre>
$code
</body>
</html>
19 changes: 18 additions & 1 deletion gen.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@
import string
import sys

import pygments
import pygments.lexers
import pygments.formatters

import test

Languages = {
Expand All @@ -24,6 +28,12 @@
"tcl": {"name": "Tcl", "suffix": ".tcl"},
}

class UnescapedString:
def __init__(self, s):
self.s = s
def __str__(self):
return self.s

def template(file=None, text=None, vars=None):
"""Super quick and dirty template function"""
if file is not None:
Expand Down Expand Up @@ -82,11 +92,18 @@ def main():
}))
for fn in files:
with open(os.path.join(language, fn + ".html"), "w") as f:
code = open(os.path.join(language, fn)).read()
highlighted = pygments.highlight(
code,
pygments.lexers.get_lexer_by_name(language),
pygments.formatters.HtmlFormatter()
)
f.write(template(file="function.template", vars={
"name": Languages[language]["name"],
"file": fn,
"extension": Languages[language]["suffix"][1:],
"code": open(os.path.join(language, fn)).read(),
"code": UnescapedString(highlighted),
"style": pygments.formatters.HtmlFormatter().get_style_defs(".highlight"),
}))

if __name__ == "__main__":
Expand Down
52 changes: 0 additions & 52 deletions prettify.css

This file was deleted.

Loading

0 comments on commit 54c2263

Please sign in to comment.