1. Ronny Pfannschmidt
  2. articledump

Commits

Ronny Pfannschmidt  committed 7130a4c

implement publishing html parts

  • Participants
  • Parent commits 0ded468
  • Branches default

Comments (0)

Files changed (2)

File articledump/restructuredtext.py

View file
-
-from docutils.core import publish_doctree
+from docutils import io
+from docutils.core import publish_doctree, Publisher
+from docutils.readers.doctree import Reader
 from docutils.nodes import docinfo
 from datetime import datetime
 from logbook import Logger
             return datetime.strptime(date, '%Y-%m-%d').date()
 
 
+    def build_html_parts(self):
+        reader = Reader(parser_name='null')
+        pub = Publisher(reader, None, None,
+                    source=io.DocTreeInput(self.document),
+                    destination_class=io.StringOutput)
+        pub.set_writer('html')
+        pub.process_programmatic_settings(None, None, None)
+        pub.set_destination(None, None)
+        pub.publish()
+        parts = pub.writer.parts.copy()
+        del parts['whole']
+        del parts['stylesheet']
+        return parts
+
 
 
 

File testing/test_load_rst.py

View file
 from articledump import load_rst
 import datetime
+import pprint
+
 content = """\
 Test something
 ================
 
 :date: 2011-10-10
 """
-import pprint
+
 def test_load(tmpdir):
     testfile = tmpdir/'test.rst'
     testfile.write(content)
     assert info.title == 'Test something'
     assert info.slug == 'shortone'
     assert info.date == datetime.date(2011, 10, 10)
+    pprint.pprint(info.build_html_parts())
+