1
0
mirror of https://github.com/djohnlewis/stackdump synced 2025-12-07 08:23:25 +00:00

Links in question view are now parsed and links are re-written where possible to point to the stackdump instance. They are also styled differently to highlight this.

Images are also replaced with a placeholder.
This commit is contained in:
Samuel Lai
2012-02-12 21:16:07 +11:00
parent 5bfcfd2f1a
commit 1da980424c
40 changed files with 12745 additions and 4 deletions

View File

@@ -0,0 +1,17 @@
from html5lib import treewalkers
from htmlserializer import HTMLSerializer
from xhtmlserializer import XHTMLSerializer
def serialize(input, tree="simpletree", format="html", encoding=None,
**serializer_opts):
# XXX: Should we cache this?
walker = treewalkers.getTreeWalker(tree)
if format == "html":
s = HTMLSerializer(**serializer_opts)
elif format == "xhtml":
s = XHTMLSerializer(**serializer_opts)
else:
raise ValueError, "type must be either html or xhtml"
return s.render(walker(input), encoding)