File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+
12h1. Textile Changelog
23
4+ h2. Version 4.0.4
5+
6+ * Bugfixes:
7+ ** Allow text blocks with spaces around first and last newlines
8+
39h2. Version 4.0.3
410* Update supported Python versions to 3.8 - 3.12 ("#83":https://github.com/textile/python-textile/issues/83)
511* Replace html5lib with nh3 for html sanitization
Original file line number Diff line number Diff line change @@ -242,3 +242,9 @@ def test_relURL():
242242 t = textile .Textile ()
243243 t .restricted = True
244244 assert t .relURL ("gopher://gopher.com/" ) == '#'
245+
246+
247+ def test_whitespace_at_beginning_and_end ():
248+ expect = textile .textile (' \n Testing 1 2 3 \n ' , html_type = 'html5' )
249+ result = '\t <p>Testing 1 2 3</p>'
250+ assert result == expect
Original file line number Diff line number Diff line change @@ -442,9 +442,8 @@ def block(self, text):
442442
443443 tag = 'p'
444444 atts = cite = ext = ''
445-
446445 out = []
447-
446+ block = None
448447 for line in text :
449448 # the line is just whitespace, add it to the output, and move on
450449 if not line .strip ():
Original file line number Diff line number Diff line change @@ -149,7 +149,9 @@ def list_type(list_string):
149149
150150def normalize_newlines (string ):
151151 out = re .sub (r'\r\n?' , '\n ' , string )
152- out = re .compile (r'^[ \t]*\n' , flags = re .M ).sub ('\n ' , out )
152+ # strip spaces around first and last newline
153+ out = re .compile (r'^[ \t]*\n[ \t]*' , flags = re .M ).sub ('\n ' , out )
154+ out = re .compile (r'[ \t]*\n[ \t]*$' , flags = re .M ).sub ('\n ' , out )
153155 out = out .strip ('\n ' )
154156 return out
155157
You can’t perform that action at this time.
0 commit comments