jenkins-bot has submitted this change and it was merged. ( https://gerrit.wikimedia.org/r/434301 )
Change subject: Add 'startcolon' rule in textlib.py ......................................................................
Add 'startcolon' rule in textlib.py
startcolon is a rule that will be used to detect lines that start with a colon or more, the colon handles the indentation in the rendered version.
Change-Id: I3393515099874ab7db4e679efaaa3c630727908a --- M pywikibot/textlib.py M tests/textlib_tests.py 2 files changed, 5 insertions(+), 0 deletions(-)
Approvals: John Vandenberg: Looks good to me, approved jenkins-bot: Verified
diff --git a/pywikibot/textlib.py b/pywikibot/textlib.py index 9ba2b5f..17480c4 100644 --- a/pywikibot/textlib.py +++ b/pywikibot/textlib.py @@ -258,6 +258,8 @@ # lines that start with a space are shown in a monospace font and # have whitespace preserved. 'startspace': re.compile(r'(?m)^ (.*?)$'), + # lines that start with a colon or more will be indented + 'startcolon': re.compile(r'(?m)^:(.*?)$'), # tables often have whitespace that is used to improve wiki # source code readability. # TODO: handle nested tables. diff --git a/tests/textlib_tests.py b/tests/textlib_tests.py index 648bcb1..45c79c6 100644 --- a/tests/textlib_tests.py +++ b/tests/textlib_tests.py @@ -1193,6 +1193,9 @@ self.assertEqual(textlib.replaceExcept(' xA ', 'x', 'y', ['startspace'], site=self.site), ' xA ') + self.assertEqual(textlib.replaceExcept(':xA ', 'x', 'y', + ['startcolon'], site=self.site), + ':xA ') self.assertEqual(textlib.replaceExcept('<table>x</table>', 'x', 'y', ['table'], site=self.site), '<table>x</table>')
pywikibot-commits@lists.wikimedia.org