jenkins-bot merged this change.

View Change

Approvals: John Vandenberg: Looks good to me, approved jenkins-bot: Verified
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(-)

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>')

To view, visit change 434301. To unsubscribe, visit settings.

Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-MessageType: merged
Gerrit-Change-Id: I3393515099874ab7db4e679efaaa3c630727908a
Gerrit-Change-Number: 434301
Gerrit-PatchSet: 2
Gerrit-Owner: Rafidaslam <rafidteam@gmail.com>
Gerrit-Reviewer: John Vandenberg <jayvdb@gmail.com>
Gerrit-Reviewer: Zoranzoki21 <zorandori4444@gmail.com>
Gerrit-Reviewer: jenkins-bot <>