summaryrefslogtreecommitdiff
path: root/helpcontent2/to-wiki/wikiconv2.py
diff options
context:
space:
mode:
Diffstat (limited to 'helpcontent2/to-wiki/wikiconv2.py')
-rwxr-xr-xhelpcontent2/to-wiki/wikiconv2.py42
1 files changed, 23 insertions, 19 deletions
diff --git a/helpcontent2/to-wiki/wikiconv2.py b/helpcontent2/to-wiki/wikiconv2.py
index e1057ec251..6f5f80761d 100755
--- a/helpcontent2/to-wiki/wikiconv2.py
+++ b/helpcontent2/to-wiki/wikiconv2.py
@@ -495,7 +495,7 @@ class TableCell(ElementBase):
if parser.follow_embed:
self.embed_href(parser, fname, id)
elif name == 'paragraph':
- self.parse_child(TableContentParagraph(attrs, self))
+ parser.parse_localized_paragraph(TableContentParagraph(attrs, self), attrs, self)
elif name == 'section':
self.parse_child(Section(attrs, self))
else:
@@ -546,7 +546,7 @@ class ListItem(ElementBase):
if parser.follow_embed:
self.embed_href(parser, fname, id)
elif name == 'paragraph':
- self.parse_child(ListItemParagraph(attrs, self))
+ parser.parse_localized_paragraph(ListItemParagraph(attrs, self), attrs, self)
else:
self.unhandled_element(parser, name)
@@ -1096,36 +1096,40 @@ class ParserBase:
def get_variable(self, id):
return self.head_obj.get_variable(id)
- def parse_paragraph(self, attrs, obj):
- ignore_this = False
- try:
- if attrs['role'] == 'heading' and int(attrs['level']) == 1 \
- and self.ignore_heading and self.follow_embed:
- self.ignore_heading = False
- ignore_this = True
- except:
- pass
-
+ def parse_localized_paragraph(self, paragraph, attrs, obj):
+ localized_text = ''
try:
localized_text = get_localized_text(self.filename, attrs['id'])
except:
pass
- if ignore_this:
- obj.parse_child(Ignore(attrs, obj, 'paragraph'))
- elif localized_text != '':
+ if localized_text != '':
# parse the localized text
- localized_para = Paragraph(attrs, obj)
text = u'<?xml version="1.0" encoding="UTF-8"?><localized>' + localized_text + '</localized>'
ParserBase(self.filename, self.follow_embed, self.embedding_app, \
self.current_app, self.wiki_page_name, \
- localized_para, text.encode('utf-8'))
+ paragraph, text.encode('utf-8'))
# add it to the overall structure
- obj.objects.append(localized_para)
+ obj.objects.append(paragraph)
# and ignore the original text
obj.parse_child(Ignore(attrs, obj, 'paragraph'))
else:
- obj.parse_child(Paragraph(attrs, obj))
+ obj.parse_child(paragraph)
+
+ def parse_paragraph(self, attrs, obj):
+ ignore_this = False
+ try:
+ if attrs['role'] == 'heading' and int(attrs['level']) == 1 \
+ and self.ignore_heading and self.follow_embed:
+ self.ignore_heading = False
+ ignore_this = True
+ except:
+ pass
+
+ if ignore_this:
+ obj.parse_child(Ignore(attrs, obj, 'paragraph'))
+ else:
+ self.parse_localized_paragraph(Paragraph(attrs, obj), attrs, obj)
class XhpParser(ParserBase):
def __init__(self, filename, follow_embed, embedding_app, wiki_page_name):