Dillute long URIs with zero-width spaces
Change-Id: I6e5a3c432f1ebcba207278a40c12d8ad46c6870e
This commit is contained in:
parent
cd5dcbd1f8
commit
371bcdb048
@ -188,7 +188,11 @@ def unwrap_text(text):
|
||||
|
||||
def format_text(s):
|
||||
s = cgi.escape(re.sub(re.compile('\n{2,}', flags=re.MULTILINE), '\n', s))
|
||||
s = re.sub(r'([/\/\*=~]{1,2}|--|\+\+)', r'\1​', s)
|
||||
|
||||
def replace_dots(match_obj):
|
||||
return re.sub(r'([\./]+)', r'\1​', match_obj.group(0))
|
||||
|
||||
s = re.sub(r'((?:\w+[\./]+)+\w+)', replace_dots, s)
|
||||
return s
|
||||
|
||||
|
||||
|
@ -60,8 +60,22 @@ class TestUtils(testtools.TestCase):
|
||||
def test_format_text_split_long_link(self):
|
||||
original = ('https://blueprints.launchpad.net/stackalytics/+spec/'
|
||||
'stackalytics-core')
|
||||
expected = ('https://​blueprints.launchpad.net/​'
|
||||
'stackalytics/​+spec/​stackalytics-core')
|
||||
expected = ('https://blueprints.​launchpad.​net'
|
||||
'/​stackalytics/+spec/​stackalytics-core')
|
||||
|
||||
self.assertEqual(expected, utils.format_text(original))
|
||||
|
||||
def test_format_text_split_full_class_path(self):
|
||||
original = 'tests.unit.benchmark.scenarios.test_base'
|
||||
expected = ('tests.​unit.​benchmark.​'
|
||||
'scenarios.​test_base')
|
||||
|
||||
self.assertEqual(expected, utils.format_text(original))
|
||||
|
||||
def test_format_text_split_full_class_path_middle_line(self):
|
||||
original = 'some text tests.unit.benchmark.scenarios.test_base wide'
|
||||
expected = ('some text tests.​unit.​benchmark.​'
|
||||
'scenarios.​test_base wide')
|
||||
|
||||
self.assertEqual(expected, utils.format_text(original))
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user