文書の整形
import ssd
text = '''
===========
Ttitle
==========
It's a test of [SSD](http://return0.dyndns.org/s/ssd/).
Heading2
===========
- list.
- list.
- list.
- list.
- list.
- list.
- list.
1. list
2. list
3. list
Heading3
----------------
>>[Quote](http://example.net/)
Quotation.
'''
item = ssd.process(text)
text = """<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>%(title)s</title>
</head>
<body>
%(body)s
</body>
</html>
""" % item
print text
独自のカスタマイズ
from ssd.processor import Processor
from ssd.sel import Sel
import re
class Test(Sel):
reg = re.compile(r"^(.+)$", re.S)
def process(self, match):
return "<p>%s</p>\n" % match.group(1)
p = Processor()
p.add("block", Test)
text = """It's a test document.
this line is same paragraph.
another paragraph."""
print p.process(text)["body"]