From 9bb518cc76f3d902378942ebcaff3a450026fa8a Mon Sep 17 00:00:00 2001 From: Sunil Mohan Adapa Date: Tue, 25 Aug 2020 11:14:00 -0700 Subject: [PATCH] doc: wikiparser: Parse content inside a comment Signed-off-by: Sunil Mohan Adapa Reviewed-by: James Valleroy --- doc/scripts/wikiparser.py | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/doc/scripts/wikiparser.py b/doc/scripts/wikiparser.py index f3314a368..3bfd301e4 100644 --- a/doc/scripts/wikiparser.py +++ b/doc/scripts/wikiparser.py @@ -480,7 +480,9 @@ class Admonition(Element): class Comment(Text): def to_docbook(self, context=None): - return f'{escape(self.content)}' + item_xml = [item.to_docbook(context) for item in self.content] + xml = ' '.join(item_xml) + return f'{xml}' class BeginInclude(Element): @@ -945,7 +947,10 @@ TableItem([Paragraph([PlainText('3')])])])])] 'border:1px solid black;width: 80%')] >>> parse_wiki('/* comment */') - [Comment('comment')] + [Comment([PlainText('comment')])] + + >>> parse_wiki('/* comment http://example.com */') + [Comment([PlainText('comment '), Url('http://example.com')])] >>> parse_wiki('## BEGIN_INCLUDE') [BeginInclude()] @@ -1349,6 +1354,7 @@ PlainText('dialog.')])])])] match = re.match(r'\/\* (.+) \*\/', line) if match: content = match.group(1) + content = parse_plain_text(content) elements.append(Comment(content)) continue @@ -1532,9 +1538,13 @@ ListItem([Paragraph([PlainText('second item')])])])]) 'first item\ second item' - >>> generate_inner_docbook([Comment('comment')]) + >>> generate_inner_docbook([Comment([PlainText('comment')])]) 'comment' + >>> generate_inner_docbook([Comment([PlainText('comment'), \ +Url('http://example.com')])]) + 'comment ' + >>> generate_inner_docbook([Category('CategoryFreedomBox')]) ''