mirror of
https://github.com/Hopiu/linkchecker.git
synced 2026-05-08 14:44:46 +00:00
wrap should handle line endings os-specific
git-svn-id: https://linkchecker.svn.sourceforge.net/svnroot/linkchecker/trunk/linkchecker@1934 e7d03fd6-7b0d-0410-9947-9c21f3af8025
This commit is contained in:
parent
2b60a133ba
commit
f70ef0198d
2 changed files with 10 additions and 3 deletions
|
|
@ -37,7 +37,11 @@ def unquote (s):
|
|||
return s
|
||||
|
||||
|
||||
_para_ro = re.compile(r"(?:\r\n|\r|\n)(?:(?:\r\n|\r|\n)\s*)+")
|
||||
_para_mac = r"(?:%(sep)s)(?:(?:%(sep)s)\s*)+" % {'sep': '\r'}
|
||||
_para_posix = r"(?:%(sep)s)(?:(?:%(sep)s)\s*)+" % {'sep': '\n'}
|
||||
_para_win = r"(?:%(sep)s)(?:(?:%(sep)s)\s*)+" % {'sep': '\r\n'}
|
||||
_para_ro = re.compile("%s|%s|%s" % (_para_mac, _para_posix, _para_win))
|
||||
|
||||
def get_paragraphs (text):
|
||||
"""A new paragraph is considered to start at a line which follows
|
||||
one or more blank lines (lines containing nothing or just spaces).
|
||||
|
|
|
|||
|
|
@ -48,11 +48,14 @@ class TestStrFormat (unittest.TestCase):
|
|||
# testing width <= 0
|
||||
self.assertEquals(linkcheck.strformat.wrap(s, -1), s)
|
||||
self.assertEquals(linkcheck.strformat.wrap(s, 0), s)
|
||||
s2 = "11 22%(sep)s33 44%(sep)s55" % {'sep': os.linesep}
|
||||
l = len(os.linesep)
|
||||
gap = " "*l
|
||||
s2 = "11%(gap)s22%(sep)s33%(gap)s44%(sep)s55" % \
|
||||
{'sep': os.linesep, 'gap': gap}
|
||||
# splitting lines
|
||||
self.assertEquals(linkcheck.strformat.wrap(s2, 2), s)
|
||||
# combining lines
|
||||
self.assertEquals(linkcheck.strformat.wrap(s, 5), s2)
|
||||
self.assertEquals(linkcheck.strformat.wrap(s, 4+l), s2)
|
||||
|
||||
def test_remove_markup (self):
|
||||
"""test markup removing"""
|
||||
|
|
|
|||
Loading…
Reference in a new issue