Skip to content

Commit befb940

Browse files
authored
Merge pull request #87 from slimadvies/master
Allow text blocks with spaces around first newline
2 parents f87892a + b349498 commit befb940

File tree

3 files changed

+13
-2
lines changed

3 files changed

+13
-2
lines changed

CHANGELOG.textile

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
1+
12
h1. Textile Changelog
23

4+
h2. Development
5+
* Bugfixes:
6+
** Allow text blocks with spaces around first and last newlines
7+
38
h2. Version 4.0.3
49
* Update supported Python versions to 3.8 - 3.12 ("#83":https://github.com/textile/python-textile/issues/83)
510
* Replace html5lib with nh3 for html sanitization

tests/test_textile.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff 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+
result = textile.textile(' \n Testing 1 2 3 \n ', html_type='html5')
249+
expect = ' Testing 1 2 3 \n '
250+
assert result == expect

textile/core.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -442,9 +442,9 @@ def block(self, text):
442442

443443
tag = 'p'
444444
atts = cite = ext = ''
445-
446445
out = []
447-
446+
block = Block(self, tag, atts, ext, cite, '') # init block
447+
block.eat = False # don't eat the next line after init block
448448
for line in text:
449449
# the line is just whitespace, add it to the output, and move on
450450
if not line.strip():

0 commit comments

Comments
 (0)