[Checkins] SVN: zope.structuredtext/trunk/ fix state machine in p tag

Laurence Rowe l at lrowe.co.uk
Tue Mar 31 16:20:03 EDT 2009


Log message for revision 98726:
  fix state machine in p tag

Changed:
  U   zope.structuredtext/trunk/convert.py
  U   zope.structuredtext/trunk/src/zope/structuredtext/html.py
  U   zope.structuredtext/trunk/src/zope/structuredtext/regressions/ExtensionClass.ref
  U   zope.structuredtext/trunk/src/zope/structuredtext/regressions/InnerLinks.ref
  U   zope.structuredtext/trunk/src/zope/structuredtext/regressions/Links.ref
  U   zope.structuredtext/trunk/src/zope/structuredtext/regressions/MultiMapping.ref
  U   zope.structuredtext/trunk/src/zope/structuredtext/regressions/examples.ref
  U   zope.structuredtext/trunk/src/zope/structuredtext/regressions/examples1.ref
  U   zope.structuredtext/trunk/src/zope/structuredtext/regressions/index.ref
  U   zope.structuredtext/trunk/src/zope/structuredtext/regressions/table.ref

-=-
Modified: zope.structuredtext/trunk/convert.py
===================================================================
--- zope.structuredtext/trunk/convert.py	2009-03-31 20:12:18 UTC (rev 98725)
+++ zope.structuredtext/trunk/convert.py	2009-03-31 20:20:03 UTC (rev 98726)
@@ -1,16 +1,33 @@
-"""Utility to convert stx to html
+"""Utility to convert stx in regression dir to html
 """
 
 import sys
+import os.path
 from zope.structuredtext import stng
 from zope.structuredtext.document import Document
 from zope.structuredtext.html import HTML
 
-def convert(raw_text):
-    doc = stng.structurize(raw_text)
-    doc = Document()(doc)
-    return HTML()(doc)
+def readFile(dirname,fname):
+    myfile = open(os.path.join(dirname, fname), "r")
+    lines = myfile.readlines()
+    myfile.close()
+    return ''.join(lines)
 
+def writeFile(dirname,fname, data):
+    myfile = open(os.path.join(dirname, fname), "w")
+    myfile.truncate()
+    myfile.write(data)
+
 if __name__ == '__main__':
-    fname = sys.argv[1]
-    print convert(open(fname).read())
+    files = ['index.stx','Acquisition.stx','ExtensionClass.stx',
+            'MultiMapping.stx','examples.stx','Links.stx','examples1.stx',
+            'table.stx','InnerLinks.stx']
+    dirname = sys.argv[1]
+    for f in files:
+        raw_text = readFile(dirname, f)
+        doc = stng.structurize(raw_text)
+        doc = Document()(doc)
+        html = HTML()(doc)
+        
+        reg_fname = f.replace('.stx','.ref')
+        reg_html  = writeFile(dirname , reg_fname, html)

Modified: zope.structuredtext/trunk/src/zope/structuredtext/html.py
===================================================================
--- zope.structuredtext/trunk/src/zope/structuredtext/html.py	2009-03-31 20:12:18 UTC (rev 98725)
+++ zope.structuredtext/trunk/src/zope/structuredtext/html.py	2009-03-31 20:20:03 UTC (rev 98726)
@@ -155,13 +155,16 @@
             if c.getNodeName() in self.paragraph_nestable:
                 if not in_p:
                     output('<p>')
+                    in_p = True
                 self.dispatch(c, level, output)
             else:
-                output('</p>\n')
-                in_p = False
+                if in_p:
+                    output('</p>\n')
+                    in_p = False
                 self.dispatch(c, level, output)
         if in_p:
             output('</p>\n')
+            in_p = False
 
     def link(self, doc, level, output):
         output('<a href="%s">' % doc.href)

Modified: zope.structuredtext/trunk/src/zope/structuredtext/regressions/ExtensionClass.ref
===================================================================
--- zope.structuredtext/trunk/src/zope/structuredtext/regressions/ExtensionClass.ref	2009-03-31 20:12:18 UTC (rev 98725)
+++ zope.structuredtext/trunk/src/zope/structuredtext/regressions/ExtensionClass.ref	2009-03-31 20:20:03 UTC (rev 98726)
@@ -271,7 +271,6 @@
 <p>      If an attribute name is contained in a Python string object,
       rather than a C string object, then the macro <code>Py_FindAttr</code> should
       be used to look up an attribute value.</p>
-</p>
 <h2>    Linking</h2>
 <p>      The extension class mechanism was designed to be useful with
       dynamically linked extension modules.  Modules that implement
@@ -279,7 +278,6 @@
       class library.  The macro <code>PyExtensionClass_Export</code> imports the
       <code>ExtensionClass</code> module and uses objects imported from this module
       to initialize an extension class with necessary behavior.</p>
-</p>
 <h2>    Example: MultiMapping objects</h2>
 <p>      An <a href="MultiMapping.html">example</a>, is provided that illustrates the
       changes needed to convert an existing type to an ExtensionClass.</p>
@@ -412,14 +410,12 @@
         be used to compute an attribute, and calls the function when
         it's <code>__of__</code> method is called:</p>
 <p>          import ExtensionClass</p>
-</p>
 <h5>          class ComputedAttribute(ExtensionClass.Base):</h5>
 <p>            def __init__(self, func): self.func=func</p>
 <p>            def __of__(self, parent): return self.func(parent)</p>
 <p>        Then we can use this class to create computed attributes.  In the
         example below, we create a computed attribute, 'radius':</p>
 <p>          from math import sqrt</p>
-</p>
 <h5>          class Point(ExtensionClass.Base):</h5>
 <p>            def __init__(self, x, y): self.x, self.y = x, y</p>
 <p>            radius=ComputedAttribute(lambda self: sqrt(self.x<strong>2+self.y</strong>2))</p>
@@ -589,10 +585,8 @@
 
 <ul>
 <li>Sub-classing extension classes in Python,</li>
-</p>
 <li>Construction of extension class instances by calling extension
         classes,</li>
-</p>
 <li>Extension classes to provide meta-data, such as unbound methods
         and their documentation string.</li>
 

Modified: zope.structuredtext/trunk/src/zope/structuredtext/regressions/InnerLinks.ref
===================================================================
--- zope.structuredtext/trunk/src/zope/structuredtext/regressions/InnerLinks.ref	2009-03-31 20:12:18 UTC (rev 98725)
+++ zope.structuredtext/trunk/src/zope/structuredtext/regressions/InnerLinks.ref	2009-03-31 20:20:03 UTC (rev 98726)
@@ -9,4 +9,3 @@
 <p>  <a name="ref2">[2]</a> "Python Book" by Guido van Rossum</p>
 </body>
 </html>
-

Modified: zope.structuredtext/trunk/src/zope/structuredtext/regressions/Links.ref
===================================================================
--- zope.structuredtext/trunk/src/zope/structuredtext/regressions/Links.ref	2009-03-31 20:12:18 UTC (rev 98725)
+++ zope.structuredtext/trunk/src/zope/structuredtext/regressions/Links.ref	2009-03-31 20:20:03 UTC (rev 98726)
@@ -21,4 +21,3 @@
   <a href="http://www.zope-is-kewl.com">Link 2</a>  and <a href="http://www.freshmeat.net">one more link - yeah.</a></p>
 </body>
 </html>
-

Modified: zope.structuredtext/trunk/src/zope/structuredtext/regressions/MultiMapping.ref
===================================================================
--- zope.structuredtext/trunk/src/zope/structuredtext/regressions/MultiMapping.ref	2009-03-31 20:12:18 UTC (rev 98725)
+++ zope.structuredtext/trunk/src/zope/structuredtext/regressions/MultiMapping.ref	2009-03-31 20:20:03 UTC (rev 98726)
@@ -413,4 +413,3 @@
   this document.</p>
 </body>
 </html>
-

Modified: zope.structuredtext/trunk/src/zope/structuredtext/regressions/examples.ref
===================================================================
--- zope.structuredtext/trunk/src/zope/structuredtext/regressions/examples.ref	2009-03-31 20:12:18 UTC (rev 98725)
+++ zope.structuredtext/trunk/src/zope/structuredtext/regressions/examples.ref	2009-03-31 20:20:03 UTC (rev 98726)
@@ -31,24 +31,18 @@
 <p><a name="ref1">[1]</a> (The referring text should be a paragraph, not a header, and
 should contain a reference to this footnote, footnote "<a href="#ref1">[1]</a>".)</p>
 <p>  Some hrefs, in a definition list:</p>
-</p>
 <dl>
 <dt>  <u>Regular</u></dt>
 <dd><a href="http://www.zope.org">http://www.zope.org/</a></dd>
-</p>
 <dt>  <u>W/trailing punctuation</u></dt>
 <dd><a href="http://www.zope.org">http://www.zope.org/</a>.</dd>
-</p>
 <dt>  <u>W protocol implicit</u></dt>
 <dd><a href=":locallink">locallink</a></dd>
-</p>
 <dt>  <u>W protocol implicit</u>, alternate</dt>
 <dd>"locallink", :locallink</dd>
 </dl>
-</p>
 <p>  |||| A Simple Two-column Table ||
   || Column A || Column B ||
   || Apples   || Oranges  ||</p>
 </body>
 </html>
-

Modified: zope.structuredtext/trunk/src/zope/structuredtext/regressions/examples1.ref
===================================================================
--- zope.structuredtext/trunk/src/zope/structuredtext/regressions/examples1.ref	2009-03-31 20:12:18 UTC (rev 98725)
+++ zope.structuredtext/trunk/src/zope/structuredtext/regressions/examples1.ref	2009-03-31 20:20:03 UTC (rev 98726)
@@ -13,4 +13,3 @@
 </pre>
 </body>
 </html>
-

Modified: zope.structuredtext/trunk/src/zope/structuredtext/regressions/index.ref
===================================================================
--- zope.structuredtext/trunk/src/zope/structuredtext/regressions/index.ref	2009-03-31 20:12:18 UTC (rev 98725)
+++ zope.structuredtext/trunk/src/zope/structuredtext/regressions/index.ref	2009-03-31 20:20:03 UTC (rev 98726)
@@ -46,4 +46,3 @@
     Python 1.5.1 using Microsoft Visual C++ 5.0 in "Release" mode.</p>
 </body>
 </html>
-

Modified: zope.structuredtext/trunk/src/zope/structuredtext/regressions/table.ref
===================================================================
--- zope.structuredtext/trunk/src/zope/structuredtext/regressions/table.ref	2009-03-31 20:12:18 UTC (rev 98725)
+++ zope.structuredtext/trunk/src/zope/structuredtext/regressions/table.ref	2009-03-31 20:20:03 UTC (rev 98726)
@@ -70,4 +70,3 @@
 </table>
 </body>
 </html>
-



More information about the Checkins mailing list