diff options
author | 2011-06-22 08:50:32 +0200 | |
---|---|---|
committer | 2011-06-22 08:50:32 +0200 | |
commit | 29193394995ad2aa7a3aa6a0a9da16b6fbe9a370 (patch) | |
tree | 0c6b17ef0a161d96b114a4bb122bd35b481355b4 /setup.py | |
parent | Add a simple HTML skel to the doc output. (diff) | |
download | pms-test-suite-29193394995ad2aa7a3aa6a0a9da16b6fbe9a370.tar.gz pms-test-suite-29193394995ad2aa7a3aa6a0a9da16b6fbe9a370.tar.bz2 pms-test-suite-29193394995ad2aa7a3aa6a0a9da16b6fbe9a370.zip |
Grep title from Markdown header.
Diffstat (limited to 'setup.py')
-rwxr-xr-x | setup.py | 19 |
1 files changed, 17 insertions, 2 deletions
@@ -34,7 +34,20 @@ class DocCommand(Command): sys.exit(1) class PMSTSExts(markdown.Extension): + class TitleGrepper(markdown.treeprocessors.Treeprocessor): + def __init__(self, ska): + self._ska = ska + + def run(self, root): + for c in root: + if c.tag == "h1": + self._ska.title = c.text + break + return root + class HTMLSkelAdder(markdown.postprocessors.Postprocessor): + title = '' + def run(self, text): return '''<?xml version="1.0" encoding="utf-8"?> <html xmlns="http://www.w3.org/1999/xhtml"> @@ -42,12 +55,14 @@ class DocCommand(Command): <title>%s</title> </head> <body> -''' % 'XXX' + text + ''' +''' % self.title + text + ''' </body> </html>''' def extendMarkdown(self, md, md_globals): - md.postprocessors.add('htmlskeladder', self.HTMLSkelAdder(), '_end') + ska = self.HTMLSkelAdder() + md.postprocessors.add('htmlskeladder', ska, '_end') + md.treeprocessors.add('titlegrepper', self.TitleGrepper(ska), '_end') m = markdown.Markdown(extensions = [PMSTSExts()]) for f in self.docs: |