[Commits] python.it commit r183 -
www/branches/python/scripts/ht2html
commit a svn.python.it
commit a svn.python.it
Lun 12 Giu 2006 18:52:17 CEST
Author: manlio
Date: Mon Jun 12 18:52:17 2006
New Revision: 183
Modified:
www/branches/python/scripts/ht2html/PDONewGenerator.py
Log:
aggiunto supporto per reST in ht2html
Modified: www/branches/python/scripts/ht2html/PDONewGenerator.py
==============================================================================
--- www/branches/python/scripts/ht2html/PDONewGenerator.py (original)
+++ www/branches/python/scripts/ht2html/PDONewGenerator.py Mon Jun 12 18:52:17 2006
@@ -2,6 +2,7 @@
ht2html Style class per creare python.it.
Stefano Giraldi <e.tino a email.it>
+Manlio Perillo <manlio.perillo a gmail.com> (reST support)
$Id$
"""
@@ -23,6 +24,9 @@
import sys
import time
+# reStructuredText support
+from docutils.core import publish_parts
+
classversion = '0.0.2'
@@ -161,6 +165,7 @@
print cont
def __do_head(self):
+ # XXX TODO use XHTML instead?
"""Return the HTML <head> stuff."""
print '''\
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
@@ -465,6 +470,14 @@
def __grokbody(self):
if self.__body is None:
text = self.__parser.fp.read()
+ if self.__parser.get('Content-Type') == 'text/x-rst':
+ # convert to html
+ # XXX TODO source encoding handling
+ parts = publish_parts(text, writer_name='html')
+ title = parts["html_title"].encode(self.get_charset())
+ body = parts["fragment"].encode(self.get_charset())
+
+ text = title + body
i = text.find('<!--table-stop-->')
if i >= 0:
self.__body = text[:i]
@@ -484,4 +497,4 @@
return '#003366'
def get_charset(self):
- return 'iso-8859-1'
\ No newline at end of file
+ return 'iso-8859-1'
Maggiori informazioni sulla lista
Commits