diff options
Diffstat (limited to 'sandbox/richard')
-rw-r--r-- | sandbox/richard/ZReST/Makefile | 15 | ||||
-rw-r--r-- | sandbox/richard/ZReST/README.txt | 48 | ||||
-rw-r--r-- | sandbox/richard/ZReST/TODO.txt | 6 | ||||
-rw-r--r-- | sandbox/richard/ZReST/ZReST.py | 288 | ||||
-rw-r--r-- | sandbox/richard/ZReST/__init__.py | 27 | ||||
-rw-r--r-- | sandbox/richard/ZReST/dtml/manage_addZReSTForm.dtml | 45 | ||||
-rw-r--r-- | sandbox/richard/ZReST/dtml/manage_editForm.dtml | 88 | ||||
-rw-r--r-- | sandbox/richard/ZReST/refresh.txt | 1 | ||||
-rw-r--r-- | sandbox/richard/ZReST/version.txt | 1 | ||||
-rw-r--r-- | sandbox/richard/pythonpoint/example_slides.txt | 38 | ||||
-rw-r--r-- | sandbox/richard/pythonpoint/pythonpoint.py | 328 | ||||
-rw-r--r-- | sandbox/richard/pythonpoint/readme.txt | 5 | ||||
-rwxr-xr-x | sandbox/richard/pythonpoint/rst2pythonpoint.py | 25 |
13 files changed, 0 insertions, 915 deletions
diff --git a/sandbox/richard/ZReST/Makefile b/sandbox/richard/ZReST/Makefile deleted file mode 100644 index 1f78c66e8..000000000 --- a/sandbox/richard/ZReST/Makefile +++ /dev/null @@ -1,15 +0,0 @@ -FILES = ZReST.py __init__.py refresh.txt version.txt TODO.txt README.txt -DTML = dtml/manage_addZReSTForm.dtml dtml/manage_editForm.dtml -VERSION := $(shell cat version.txt) - -all: ${FILES} ${DTML} - rm -rf dist - mkdir dist - mkdir dist/ZReST - mkdir dist/ZReST/dtml - cp ${FILES} dist/ZReST - cp ${DTML} dist/ZReST/dtml - (cd dist; tar zcf ZReST-${VERSION}.tgz ZReST) - mv dist/ZReST-${VERSION}.tgz . - rm -rf dist - diff --git a/sandbox/richard/ZReST/README.txt b/sandbox/richard/ZReST/README.txt deleted file mode 100644 index 89766f9d6..000000000 --- a/sandbox/richard/ZReST/README.txt +++ /dev/null @@ -1,48 +0,0 @@ ----------------------------------- -ReStructuredText Document for Zope ----------------------------------- - -Requirements -============ - -To use this product, you will need: - -python2.1+ - see http://www.python.org/ -Zope 2.5+ - see http://www.zope.org/ -A docutils snapshot from later than 21 August 2002 - see http://docutils.sourceforge.net/#development-snapshots - -Installation -============ - -To install this product, unpack it so the ZReST directory is in the Zope -lib/python/Products directory. You should then restart Zope. - -You will now be able to add objects of type "ReStructuredText Document". - -Usage -===== - -See the docutils user documentation section: - - http://docutils.sourceforge.net/docs/index.html#user - -I recommend starting with the ReST "primer": - - http://docutils.sourceforge.net/docs/user/rst/quickstart.html - - -Footnotes -========= - -This product was written by Richard Jones, rjones@ekit-inc.com. - -Please direct questions about ReStructureText to the `Docutils mailing -lists`_. - -.. _Docutils mailing lists: - http://docutils.sourceforge.net/docs/user/mailing-lists.html - -This package is placed in the Public Domain. diff --git a/sandbox/richard/ZReST/TODO.txt b/sandbox/richard/ZReST/TODO.txt deleted file mode 100644 index 6860c9423..000000000 --- a/sandbox/richard/ZReST/TODO.txt +++ /dev/null @@ -1,6 +0,0 @@ -* charset configuration, defaulting to 'latin-1' - -* add "level" and "header" args to render / as_html - - - level indicates the header level to start at - - header boolean turns page header tags on/off diff --git a/sandbox/richard/ZReST/ZReST.py b/sandbox/richard/ZReST/ZReST.py deleted file mode 100644 index e130cf18e..000000000 --- a/sandbox/richard/ZReST/ZReST.py +++ /dev/null @@ -1,288 +0,0 @@ -# -# $Id$ -# -''' ReStructuredText Product for Zope - -This Product stores two texts - a "source" text in ReStructureText format, -and a HTML "formatted" version of that text. - -''' -import docutils.core, docutils.io - -from Globals import InitializeClass, DTMLFile -from OFS.SimpleItem import Item -from OFS.PropertyManager import PropertyManager -from OFS.History import Historical, html_diff -from Acquisition import Implicit -from Persistence import Persistent -from AccessControl import ClassSecurityInfo -from AccessControl import ModuleSecurityInfo -from DateTime.DateTime import DateTime -modulesecurity = ModuleSecurityInfo() - -modulesecurity.declareProtected('View management screens', - 'manage_addZReSTForm') -manage_addZReSTForm = DTMLFile('dtml/manage_addZReSTForm', globals()) - -modulesecurity.declareProtected('Add Z Roundups', 'manage_addZReST') -def manage_addZReST(self, id, file='', REQUEST=None): - """Add a ZReST product """ - # validate the instance_home - self._setObject(id, ZReST(id)) - self._getOb(id).manage_upload(file) - if REQUEST: - return self.manage_main(self, REQUEST) - -class Warnings: - def __init__(self): - self.messages = [] - def write(self, message): - self.messages.append(message) - -class ZReST(Item, PropertyManager, Historical, Implicit, Persistent): - '''An instance of this class provides an interface between Zope and - ReStructuredText for one text. - ''' - meta_type = 'ReStructuredText Document' - security = ClassSecurityInfo() - - def __init__(self, id): - self.id = id - self.title = id - self.stylesheet = 'default.css' - self.report_level = '2' - self.source = self.formatted = '' - - # define the properties that define this object - _properties = ( - {'id':'stylesheet', 'type': 'string', 'mode': 'w', - 'default': 'default.css'}, - {'id':'report_level', 'type': 'string', 'mode': 'w', 'default': '2'}, - ) - property_extensible_schema__ = 0 - - # define the tabs for the management interface - manage_options= ( {'label': 'Edit', 'action':'manage_main'}, - {'label': 'View', 'action':'index_html'}, - {'label': 'Source', 'action':'source_txt'}, - ) \ - + PropertyManager.manage_options \ - + Historical.manage_options \ - + Item.manage_options - - # access to the source text and formatted text - security.declareProtected('View', 'index_html') - def index_html(self, REQUEST=None): - ''' Getting the formatted text - ''' - REQUEST.RESPONSE.setHeader('content-type', 'text/html') - return self.formatted - security.declareProtected('View', 'source_txt') - def source_txt(self, REQUEST=None): - ''' Getting the source text - ''' - REQUEST.RESPONSE.setHeader('content-type', 'text/plain') - return self.source - - # edit form, which is also the primary interface - security.declareProtected('Edit ReStructuredText', 'manage_editForm') - manage_main = DTMLFile('dtml/manage_editForm', globals()) - - # edit action - security.declareProtected('Edit ReStructuredText', 'manage_edit') - def manage_edit(self, data, SUBMIT='Change',dtpref_cols='50', - dtpref_rows='20', REQUEST=None): - '''Alias index_html to roundup's index - ''' - if self._size_changes.has_key(SUBMIT): - return self._er(data, SUBMIT, dtpref_cols, dtpref_rows, REQUEST) - if data != self.source: - self.source = data - self.render() - - if REQUEST: - message="Saved changes." - return self.manage_main(self, REQUEST, manage_tabs_message=message) - - # handle edit window size changes - _size_changes = { - 'Bigger': (5,5), - 'Smaller': (-5,-5), - 'Narrower': (0,-5), - 'Wider': (0,5), - 'Taller': (5,0), - 'Shorter': (-5,0), - } - def _er(self, data, SUBMIT, dtpref_cols, dtpref_rows, REQUEST): - dr,dc = self._size_changes[SUBMIT] - rows=max(1,int(dtpref_rows)+dr) - cols=max(40,int(dtpref_cols)+dc) - e=(DateTime('GMT') + 365).rfc822() - resp=REQUEST['RESPONSE'] - resp.setCookie('dtpref_rows',str(rows),path='/',expires=e) - resp.setCookie('dtpref_cols',str(cols),path='/',expires=e) - return self.manage_main(self, REQUEST, __str__=self.quotedHTML(data), - dtpref_cols=cols, dtpref_rows=rows) - security.declarePrivate('quotedHTML') - def quotedHTML(self, - text=None, - character_entities=( - (('&'), '&'), - (("<"), '<' ), - ((">"), '>' ), - (('"'), '"'))): #" - if text is None: text=self.read_raw() - for re,name in character_entities: - if text.find(re) >= 0: text=name.join(text.split(re)) - return text - - - # handle uploads too - security.declareProtected('Edit ReStructuredText', 'manage_upload') - def manage_upload(self, file='', REQUEST=None): - ''' Replaces the current source with the upload. - ''' - if isinstance(file, type('')): - self.source = file - else: - self.source = file.read() - self.render() - - if REQUEST: - message="Saved changes." - return self.manage_main(self, REQUEST, manage_tabs_message=message) - - security.declarePrivate('render') - def render(self): - ''' Render the source to HTML - ''' - # format with strings - pub = docutils.core.Publisher() - pub.set_reader('standalone', None, 'restructuredtext') - pub.set_writer('html') - - # go with the defaults - pub.get_settings() - - # this is needed, but doesn't seem to do anything - pub.settings._destination = '' - - # use the stylesheet chosen by the user - pub.settings.stylesheet = self.stylesheet - - # set the reporting level to something sane - pub.settings.report_level = int(self.report_level) - - # don't break if we get errors - pub.settings.halt_level = 6 - - # remember warnings - pub.settings.warning_stream = Warnings() - - # input - pub.source = docutils.io.StringInput( - source=self.source, encoding=pub.settings.input_encoding) - - # output - not that it's needed - pub.destination = docutils.io.StringOutput( - encoding=pub.settings.output_encoding) - - # parse! - document = pub.reader.read(pub.source, pub.parser, pub.settings) - self.warnings = ''.join(pub.settings.warning_stream.messages) - - if document.children: - item = document.children[0] - if item.tagname == 'title': - self.title = str(item.children[0]) - - # do the format - self.formatted = pub.writer.write(document, pub.destination) - - - security.declareProtected('Edit ReStructuredText', 'PUT', 'manage_FTPput') - def PUT(self, REQUEST, RESPONSE): - ''' Handle HTTP PUT requests - ''' - data = REQUEST.get('BODY', '') - if data != self.source: - if data.startswith('.. '): - data = data.splitlines() - new = [] - for i in range(len(data)): - line = data[i] - if not line.startswith('.. '): - break - if line.startswith('.. stylesheet='): - self.stylesheet = line.split('=')[1] - elif line.startswith('.. report_level='): - self.report_level = line.split('=')[1] - else: - pass # ignore - data = '\n'.join(new) + '\n'.join(data[i:]) - self.source = data - self.render() - RESPONSE.setStatus(204) - return RESPONSE - - manage_FTPput = PUT - - def manage_FTPget(self): - ''' Get source for FTP download - ''' - self.REQUEST.RESPONSE.setHeader('Content-Type', 'text/plain') - s = [ - '.. This is a ReStructuredText Document. Initial comment lines ' - '(".. ") will be stripped.', - '.. stylesheet='+self.stylesheet, - '.. report_level='+self.report_level - ] - if self.warnings: - s.append('.. ') - s.append('.. ' + '\n.. '.join(self.warnings.splitlines())) - s.append('.. ') - return '\n'.join(s) + '\n' + self.source - - def __str__(self): - ''' Stringfy .. return the source - ''' - return self.quotedHTML(self.source) - - def PrincipiaSearchSource(self): - ''' Support for searching - the document's contents are searched. - ''' - return self.source - - def manage_historyCompare(self, rev1, rev2, REQUEST, - historyComparisonResults=''): - return ZReST.inheritedAttribute('manage_historyCompare')( - self, rev1, rev2, REQUEST, - historyComparisonResults=html_diff(rev1.source, rev2.source)) - -InitializeClass(ZReST) -modulesecurity.apply(globals()) - - -# -# $Log$ -# Revision 1.6 2002/11/28 03:44:50 goodger -# updated -# -# Revision 1.5 2002/11/05 05:27:56 goodger -# fixed Reader name -# -# Revision 1.4 2002/10/18 05:10:33 goodger -# Refactored names (options -> settings; etc.); updated. -# -# Revision 1.3 2002/08/15 05:02:41 richard -# pull out the document title too -# -# Revision 1.2 2002/08/15 04:36:56 richard -# FTP interface and Reporter message snaffling -# -# Revision 1.1 2002/08/14 05:15:37 richard -# Zope ReStructuredText Product -# -# -# -# vim: set filetype=python ts=4 sw=4 et si diff --git a/sandbox/richard/ZReST/__init__.py b/sandbox/richard/ZReST/__init__.py deleted file mode 100644 index e3feaf4ae..000000000 --- a/sandbox/richard/ZReST/__init__.py +++ /dev/null @@ -1,27 +0,0 @@ -# -# $Id$ -# -__version__='1.0' - -# product initialisation -import ZReST -def initialize(context): - context.registerClass( - ZReST, meta_type = 'ReStructuredText Document', - constructors = ( - ZReST.manage_addZReSTForm, ZReST.manage_addZReST - ) - ) - - -# -# $Log$ -# Revision 1.2 2002/08/15 04:36:56 richard -# FTP interface and Reporter message snaffling -# -# Revision 1.1 2002/08/14 05:15:37 richard -# Zope ReStructuredText Product -# -# -# -# vim: set filetype=python ts=4 sw=4 et si diff --git a/sandbox/richard/ZReST/dtml/manage_addZReSTForm.dtml b/sandbox/richard/ZReST/dtml/manage_addZReSTForm.dtml deleted file mode 100644 index 971e63160..000000000 --- a/sandbox/richard/ZReST/dtml/manage_addZReSTForm.dtml +++ /dev/null @@ -1,45 +0,0 @@ -<dtml-var manage_page_header> - -<dtml-var "manage_form_title(this(), _, form_title='Add ReStructureText Document')"> - -<p class="form-help"> -You may optionally select a file to upload from your local computer by -clicking the <em>Browse</em> button. -</p> - -<form action="manage_addZReST" method="post" enctype="multipart/form-data"> -<table cellspacing="0" cellpadding="2" border="0"> - <tr> - <td align="left" valign="top"> - <div class="form-label"> - Id - </div> - </td> - <td align="left" valign="top"> - <input type="text" name="id" size="40" /> - </td> - </tr> - <tr> - <td align="left" valign="top"> - <div class="form-optional"> - File - </div> - </td> - <td align="left" valign="top"> - <input type="file" name="file" size="25" value="" /> - </td> - </tr> - <tr> - <td align="left" valign="top"> - </td> - <td align="left" valign="top"> - <div class="form-element"> - <input class="form-element" type="submit" name="submit" - value=" Add " /> - </div> - </td> - </tr> -</table> -</form> - -<dtml-var manage_page_footer> diff --git a/sandbox/richard/ZReST/dtml/manage_editForm.dtml b/sandbox/richard/ZReST/dtml/manage_editForm.dtml deleted file mode 100644 index e302893f9..000000000 --- a/sandbox/richard/ZReST/dtml/manage_editForm.dtml +++ /dev/null @@ -1,88 +0,0 @@ -<dtml-var manage_page_header> -<dtml-var manage_tabs> - -<p class="form-help"> -You may edit the source for this document using the form below. You -may also upload the source for this document from a local file. Click -the <em>browse</em> button to select a local file to upload. -</p> - -<dtml-if warnings> -<pre class="system-msg"> -&dtml-warnings; -</pre> -</dtml-if> - -<p class="form-help"><strong>Help:</strong> ReStructuredText - <a href="http://docutils.sourceforge.net/docs/rst/quickstart.html">primer</a> - for beginners, - <a href="http://docutils.sourceforge.net/docs/rst/quickref.html">quick - reference</a> for the more advanced and - <a href="http://docutils.sourceforge.net/rst.html">home page</a> for all - the details. -</p> - -<form action="manage_edit" method="post"> -<table cellpadding="2" cellspacing="0" width="100%" border="0"> - -<dtml-with keyword_args mapping> -<tr> - <td align="left" valign="top" colspan="2"> - <div style="width: 100%;"> - <textarea name="data:text" wrap="off" style="width: 100%;"<dtml-if - dtpref_cols> cols="<dtml-var dtpref_cols>"<dtml-else - > cols="50"</dtml-if><dtml-if dtpref_rows> rows="<dtml-var - dtpref_rows>"<dtml-else> rows="20"</dtml-if>><dtml-var - __str__></textarea> - </div> - </td> -</tr> -</dtml-with> - -<tr> - <td align="left" valign="top" colspan="2"> - <div class="form-element"> - <dtml-if wl_isLocked> - <em>Locked by WebDAV</em> - <dtml-else> - <input class="form-element" type="submit" name="SUBMIT" value="Save Changes"> - </dtml-if> - - <input class="form-element" type="submit" name="SUBMIT" value="Taller"> - <input class="form-element" type="submit" name="SUBMIT" value="Shorter"> - <input class="form-element" type="submit" name="SUBMIT" value="Wider"> - <input class="form-element" type="submit" name="SUBMIT" value="Narrower"> - </div> - </td> -</tr> -</table> -</form> - -<form action="manage_upload" method="post" enctype="multipart/form-data"> -<table cellpadding="2" cellspacing="0" border="0"> -<tr> - <td align="left" valign="top"> - <div class="form-label"> - File - </div> - </td> - <td align="left" valign="top"> - <input type="file" name="file" size="25" value=""> - </td> -</tr> -<tr> - <td></td> - <td align="left" valign="top"> - <div class="form-element"> - <dtml-if wl_isLocked> - <em>Locked by WebDAV</em> - <dtml-else> - <input class="form-element" type="submit" value="Upload File"> - </dtml-if> - </div> - </td> -</tr> -</table> -</form> - -<dtml-var manage_page_footer> diff --git a/sandbox/richard/ZReST/refresh.txt b/sandbox/richard/ZReST/refresh.txt deleted file mode 100644 index 01ee0fa7b..000000000 --- a/sandbox/richard/ZReST/refresh.txt +++ /dev/null @@ -1 +0,0 @@ -This is a flag that tells Zope that the product may be auto-refreshed. diff --git a/sandbox/richard/ZReST/version.txt b/sandbox/richard/ZReST/version.txt deleted file mode 100644 index d3827e75a..000000000 --- a/sandbox/richard/ZReST/version.txt +++ /dev/null @@ -1 +0,0 @@ -1.0 diff --git a/sandbox/richard/pythonpoint/example_slides.txt b/sandbox/richard/pythonpoint/example_slides.txt deleted file mode 100644 index 8633bafcc..000000000 --- a/sandbox/richard/pythonpoint/example_slides.txt +++ /dev/null @@ -1,38 +0,0 @@ -Presentation Cover ------------------- - -*Richard Jones, Another Author* - -http://docutils.sf.net/ is cool. - -*Some very important conference, March 2002* - -Second slide ------------- - -- blah, blah blah blah blah. blah, blah blah blah blah. -- blah, blah blah blah blah. - -Another slide -------------- - -bare para blah, blah blah blah blah. blah, blah blah blah blah. - -definition term - blah, blah blah blah blah. blah, blah blah blah blah. -another one - note, don't have more than one para in here! - -bare para blah, blah blah blah blah. blah, blah blah blah blah. - -Another slide -------------- - -hi, another para - -- ooh, bullet points -- yeah! -- woo! **bold** and *italics* are OK! - -don't nest _anything_ ... PLATYPUS can't deal with it. That means no -indented bullets, no multiple paras in bullets or definitions... diff --git a/sandbox/richard/pythonpoint/pythonpoint.py b/sandbox/richard/pythonpoint/pythonpoint.py deleted file mode 100644 index 8854ae114..000000000 --- a/sandbox/richard/pythonpoint/pythonpoint.py +++ /dev/null @@ -1,328 +0,0 @@ -import cStringIO, cgi, sys, urllib -import docutils.core, docutils.io -from docutils import writers, nodes, languages - -class Writer(writers.Writer): - - settings_spec = () - settings_default_overrides = {} - output = None - - def translate(self): - visitor = DumbPythonPointFormatter(self.document) - self.document.walkabout(visitor) - self.output = visitor.astext() - #self.head_prefix = visitor.head_prefix - #self.head = visitor.head - #self.body_prefix = visitor.body_prefix - #self.body = visitor.body - #self.body_suffix = visitor.body_suffix - -class DumbPythonPointFormatter(nodes.NodeVisitor): - - def __init__(self, document): - nodes.NodeVisitor.__init__(self, document) - self.section = 0 - self.closers = [] - self.slidenum = 0 - self.body = [] - self.w = self.body.append - self.suppress_para = 0 - - def astext(self): - return ''.join(self.body) - - def visit_reference(self, node): - pass - def depart_reference(self, node): - pass - - def visit_document(self, node): - self.w('<presentation>\n' - '<stylesheet module="modern" function="getParagraphStyles"/>\n' - '<section name="Main">\n') - def depart_document(self, node): - self.w('</section>\n' - '</presentation>\n') - - def visit_section(self, node): - if node['names']: - name = node.attributes['names'][0] - else: - name = node.attributes['dupnames'][0] - self.slidenum += 1 - self.w('<slide id="Slide%03d" title="%s">\n' - '<frame x="90" y="72" width="600" height="432" leftmargin="12"' - 'rightmargin="0">\n'%(self.slidenum, name)) - def depart_section(self, node): - self.w('</frame>\n</slide>\n') - - def visit_title(self, node): - self.w('<para style="Heading2">') - self.suppress_para = 1 - def depart_title(self, node): - self.suppress_para = 0 - self.w('</para>\n') - - def visit_paragraph(self, node): - if not self.suppress_para: self.w('<para style="BodyText">') - def depart_paragraph(self, node): - if not self.suppress_para: self.w('</para>\n') - - # Simple lists - def visit_bullet_list(self, node): - pass - def depart_bullet_list(self, node): - pass - def visit_enumerated_list(self, node): - pass - def depart_enumerated_list(self, node): - pass - - def visit_list_item(self, node): - self.w('<para style="Bullet">') - self.suppress_para = 1 - def depart_list_item(self, node): - self.suppress_para = 0 - self.w('</para>\n') - - # Definition List - def visit_definition_list(self, node): - pass - def depart_definition_list(self, node): - pass - def visit_definition_list_item(self, node): - pass - def depart_definition_list_item(self, node): - pass - - def visit_term(self, node): - self.w('<para><b>') - def depart_term(self, node): - self.w('</b>') - - def visit_classifier(self, node): - self.w('<i>') - def depart_classifier(self, node): - self.w('</i>') - - def visit_definition(self, node): - self.w('</para>\n<para style="Definition">') - self.suppress_para = 1 - def depart_definition(self, node): - self.suppress_para = 0 - self.w('</para>\n') - - def visit_field(self, node): - self.w('<para>') - def depart_field(self, node): - self.w('</para>\n') - - def visit_field_body(self, node): - self.suppress_para = 1 - return - def depart_field_body(self, node): - self.suppress_para = 0 - - def visit_field_list(self, node): - return - def depart_field_list(self, node): - return - - def visit_field_name(self, node): - self.w('<b>') - - def depart_field_name(self, node): - self.w(':') - self.w('</b>') - - # Literal Block - def visit_literal_block(self, node): - self.w('<prefmt style="Code">') - self.suppress_para = 1 - def depart_literal_block(self, node): - self.suppress_para = 0 - self.w('</prefmt>\n') - - # Block Quote - def visit_block_quote(self, node): - self.w('<para style="Indent">') - def depart_block_quote(self, node): - self.w('</para>\n') - - def visit_image(self, node): - ''' EMPTY - uri CDATA #REQUIRED - alt CDATA #IMPLIED - height NMTOKEN #IMPLIED - width NMTOKEN #IMPLIED - scale NMTOKEN #IMPLIED - ''' - attrs = node.attributes - l = ['src="%(uri)s"'%attrs] - # TODO: scale - self.w('<image filename="%s"/>'%node.attributes['uri']) - def depart_image(self, node): - pass - - # - # Tables: - # NOT IN DOM YET - # - def visit_table(self, node): - ''' - +------------------------+------------+----------+----------+ - | Header row, column 1 | Header 2 | Header 3 | Header 4 | - | (header rows optional) | | | | - +========================+============+==========+==========+ - | body row 1, column 1 | column 2 | column 3 | column 4 | - +------------------------+------------+----------+----------+ - | body row 2 | Cells may span columns. | - +------------------------+------------+---------------------+ - | body row 3 | Cells may | - Table cells | - +------------------------+ span rows. | - contain | - | body row 4 | | - body elements. | - +------------------------+------------+---------------------+ - ''' - self.w('<table border=1>\n') - def depart_table(self, node): - self.w('</table>\n') - - def visit_tgroup(self, node): - pass - def depart_tgroup(self, node): - pass - - def visit_colspec(self, node): - pass - def depart_colspec(self, node): - pass - - def visit_row(self, node): - self.body.append(self.starttag(node, 'tr', '')) - - def depart_row(self, node): - self.body.append('</tr>\n') - - def visit_thead(self, node): - self.thead = 1 - def depart_thead(self, node): - self.thead = 0 - def visit_tbody(self, node): - self.thead = 1 - def depart_tbody(self, node): - self.thead = 0 - - def visit_entry(self, node): - if self.thead: - s = 'th ' - else: - s = 'td ' - attrs = node.attributes - if attrs.has_key('morecols'): - s = s + 'colspan=%d '%(attrs['morecols']+1) - if attrs.has_key('morerows'): - s = s + 'rowspan=%d '%(attrs['morerows']+1) - self.w('<%svalign="top" align="left">'%s) - - def depart_entry(self, node): - if self.thead: - self.w('</th>\n') - else: - self.w('</td>\n') - - def visit_emphasis(self, node): - self.w('<i>') - def depart_emphasis(self, node): - self.w('</i>') - - def visit_strong(self, node): - self.w('<b>') - def depart_strong(self, node): - self.w('</b>') - - def visit_interpreted(self, node): - pass #raise NotImplementedError, node - def depart_interpreted(self, node): - pass #raise NotImplementedError, node - - def visit_literal(self, node): - self.w('<div style="Code">') - def depart_literal(self, node): - self.w('</div>') - - def visit_reference(self, node): - attrs = node.attributes - doc = self.document - ok = 1 - if attrs.has_key('refuri'): - self.w('<a href="%s">'%attrs['refuri']) - elif doc.explicit_targets.has_key(attrs['refname']): - # an external reference has been defined - ref = doc.explicit_targets[attrs['refname']] - if ref.attributes.has_key('refuri'): - self.w('<a href="%s">'%ref.attributes['refuri']) - else: - self.w('<a href="#%s">'%attrs['refname']) - elif doc.implicit_targets.has_key(attrs['refname']): - # internal reference - name = attrs['refname'] - self.w('<a href="#%s">'%urllib.quote(name)) - else: - self.w('<span class="formatter_error">target "%s" ' - 'undefined</span>'%attrs['refname']) - - def depart_reference(self, node): - self.w('</a>') - - def visit_footnote_reference(self, node): - raise NotImplementedError, node - - def visit_substitution_reference(self, node): - pass - def depart_substitution_reference(self, node): - pass - - def visit_problematic(self, node): - raise NotImplementedError, node - def depart_problematic(self, node): - raise NotImplementedError, node - - def visit_system_message(self, node): - print >>sys.stderr, '%s: %s'%(node.attributes['type'], node[0][0].data) - def depart_system_message(self, node): - pass - - def visit_comment(self, node): - pass - def depart_comment(self, node): - pass - - def visit_Text(self, node): - self.w(cgi.escape(node.data)) - def depart_Text(self, node): - pass - -def main(filename, debug=0): - pub = docutils.core.Publisher() - pub.set_reader('standalone', None, 'restructuredtext') - pub.writer = Writer() - pub.get_settings() - pub.settings._destination = '' - pub.source = docutils.io.StringInput(source=open(filename).read(), - encoding='latin-1') - pub.destination = docutils.io.StringOutput(encoding='latin-1') - document = pub.reader.read(pub.source, pub.parser, pub.settings) - pub.apply_transforms(document) - - if debug == 1: - print document.pformat() - else: - print pub.writer.write(document, pub.destination) - -if __name__ == '__main__': - if len(sys.argv) > 2: - main(sys.argv[1], debug=1) - else: - main(sys.argv[1]) - diff --git a/sandbox/richard/pythonpoint/readme.txt b/sandbox/richard/pythonpoint/readme.txt deleted file mode 100644 index 6a8c91255..000000000 --- a/sandbox/richard/pythonpoint/readme.txt +++ /dev/null @@ -1,5 +0,0 @@ -This generates an XML slideshow usable by PythonPoint_. - -.. _PythonPoint: http://www.reportlab.org/python_point.html - -See the example slides.stx for information - and restrictions. diff --git a/sandbox/richard/pythonpoint/rst2pythonpoint.py b/sandbox/richard/pythonpoint/rst2pythonpoint.py deleted file mode 100755 index becb88155..000000000 --- a/sandbox/richard/pythonpoint/rst2pythonpoint.py +++ /dev/null @@ -1,25 +0,0 @@ -#!/usr/bin/env python - -# Author: Felix Wiemann -# Contact: Felix_Wiemann@ososo.de -# Revision: $Revision$ -# Date: $Date$ -# Copyright: This module has been placed in the public domain. - -""" -A minimal front end to the Docutils Publisher, producing PythonPoint XML. -""" - -try: - import locale - locale.setlocale(locale.LC_ALL, '') -except: - pass - -from docutils.core import publish_cmdline, default_description - - -description = ('Generates PythonPoint documents from standalone reStructuredText ' - 'sources. ' + default_description) - -publish_cmdline(writer_name='pythonpoint', description=description) |