Skip to content

Commit

Permalink
Always treat children of examples as examples
Browse files Browse the repository at this point in the history
There was supposedly logic in both HTML and docbook to treat children
after the first one as something different, but it couldn't possibly
be triggered (nothing ever advanced the counter)! So just take that
out. I couldn't come up with an example that could produce multiple
children anyway.
  • Loading branch information
jamadden committed Aug 21, 2017
1 parent 9d520e5 commit 17bf031
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 20 deletions.
17 changes: 6 additions & 11 deletions src/zope/structuredtext/docbook.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,18 +135,13 @@ def numbered(self, doc, level, output):
self._list(doc, level, output, 'orderedlist')

def example(self, doc, level, output):
i = 0
for c in doc.getChildNodes():
if i == 0:
output('<programlisting>\n<![CDATA[\n')
##
## eek. A ']]>' in your body will break this...
##
output(prestrip(c.getNodeValue()))
output('\n]]></programlisting>\n')
else:
getattr(self, self.element_types[c.getNodeName()])(
c, level, output)
output('<programlisting>\n<![CDATA[\n')
##
## eek. A ']]>' in your body will break this...
##
output(prestrip(c.getNodeValue()))
output('\n]]></programlisting>\n')

def paragraph(self, doc, level, output):
output('<para>\n\n')
Expand Down
12 changes: 3 additions & 9 deletions src/zope/structuredtext/html.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,16 +138,10 @@ def numbered(self, doc, level, output):
self._list(doc, level, output, "ol")

def example(self, doc, level, output):
i = 0
for c in doc.getChildNodes():
if i == 0:
output('\n<pre>\n')
output(escape(c.getNodeValue()))
output('\n</pre>\n')
# XXX: Nothing ever changes the value of i!
else:
getattr(self, self.element_types[c.getNodeName()])(
c, level, output)
output('\n<pre>\n')
output(escape(c.getNodeValue()))
output('\n</pre>\n')

def paragraph(self, doc, level, output):
output('<p>')
Expand Down

0 comments on commit 17bf031

Please sign in to comment.