[ovs-dev] [PATCH] nroff: Allow comments in more contexts.
Ben Pfaff
blp at nicira.com
Wed Aug 26 15:11:31 UTC 2015
Reported-by: Russell Bryant <rbryant at redhat.com>
Signed-off-by: Ben Pfaff <blp at nicira.com>
---
python/build/nroff.py | 11 ++++++++---
1 file changed, 8 insertions(+), 3 deletions(-)
diff --git a/python/build/nroff.py b/python/build/nroff.py
index 1611c49..537bfd5 100644
--- a/python/build/nroff.py
+++ b/python/build/nroff.py
@@ -98,10 +98,11 @@ def inline_xml_to_nroff(node, font, to_upper=False):
def pre_to_nroff(nodes, para, font):
s = para + '\n.nf\n'
for node in nodes:
- if node.nodeType != node.TEXT_NODE:
+ if node.nodeType == node.TEXT_NODE:
+ for line in node.data.split('\n'):
+ s += escape_nroff_literal(line, font) + '\n.br\n'
+ elif node.nodeType != node.COMMENT_NODE:
fatal("<pre> element may only have text children")
- for line in node.data.split('\n'):
- s += escape_nroff_literal(line, font) + '\n.br\n'
s += '.fi\n'
return s
@@ -221,6 +222,8 @@ def block_xml_to_nroff(nodes, para='.PP'):
else:
s += ".IP %d. .25in\n" % i
s += block_xml_to_nroff(li_node.childNodes, ".IP")
+ elif li_node.nodeType == node.COMMENT_NODE:
+ pass
elif (li_node.nodeType != node.TEXT_NODE
or not li_node.data.isspace()):
raise error.Error("<%s> element may only have <li> children" % node.tagName)
@@ -243,6 +246,8 @@ def block_xml_to_nroff(nodes, para='.PP'):
if prev == 'dd':
s += '.IP\n'
prev = 'dd'
+ elif li_node.nodeType == node.COMMENT_NODE:
+ continue
elif (li_node.nodeType != node.TEXT_NODE
or not li_node.data.isspace()):
raise error.Error("<dl> element may only have <dt> and <dd> children")
--
2.1.3
More information about the dev
mailing list