Skip to content

Commit aaafe47

Browse files
committed
undoing some things that will continue on a feature branch.
1 parent 219b146 commit aaafe47

File tree

3 files changed

+16
-24
lines changed

3 files changed

+16
-24
lines changed

tests/test_github_issues.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,9 +93,9 @@ def test_github_issue_36():
9393
assert result == expect
9494

9595
def test_github_issue_37():
96-
text = '* xxx\n* yyy\n*blah*\n* test'
96+
text = '# xxx\n# yyy\n*blah*'
9797
result = textile.textile(text)
98-
expect = '\t<ul>\n\t\t<li>xxx</li>\n\t\t<li>yyy<br />\n<strong>blah</strong></li>\n\t\t<li>test</li>\n\t</ul>'
98+
expect = '\t<p>\t<ol>\n\t\t<li>xxx</li>\n\t\t<li>yyy</li>\n\t</ol><br />\n<strong>blah</strong></p>'
9999
assert result == expect
100100

101101
def test_github_issue_40():

textile/core.py

Lines changed: 13 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
from textile.utils import (decode_high, encode_high, encode_html, generate_tag,
2828
has_raw_text, is_rel_url, is_valid_url, list_type, normalize_newlines,
2929
parse_attributes, pba)
30-
from textile.objects import Block, List, Table
30+
from textile.objects import Block, Table
3131

3232

3333
try:
@@ -297,7 +297,7 @@ def textileLists(self, text):
297297
return pattern.sub(self.fTextileList, text)
298298

299299
def fTextileList(self, match):
300-
text = re.split(r'\n(?=[*#;:]+\s)', match.group(), flags=re.M)
300+
text = re.split(r'\n(?=[*#;:])', match.group(), flags=re.M)
301301
# import pdb; pdb.set_trace()
302302
pt = ''
303303
result = []
@@ -310,15 +310,15 @@ def fTextileList(self, match):
310310

311311
m = re.search(r"^(?P<tl>[#*;:]+)(?P<st>_|\d+)?(?P<atts>{0})[ .]"
312312
"(?P<content>.*)$".format(cls_re_s), line, re.S)
313-
tl, start, atts, content = m.groups()
314-
attributes = parse_attributes(atts)
315-
content = content.strip()
316-
if '\n' in content:
317-
content = content.replace('\n', '<br />\n')
313+
if m:
314+
tl, start, atts, content = m.groups()
315+
content = content.strip()
316+
else:
317+
result.append(line)
318+
break
319+
318320
nl = ''
319321
ltype = list_type(tl)
320-
if i == 0:
321-
_list = List('{0}l'.format(ltype), attributes)
322322
tl_tags = {';': 'dt', ':': 'dd'}
323323
litem = tl_tags.get(tl[0], 'li')
324324

@@ -343,7 +343,6 @@ def fTextileList(self, match):
343343
# put together the start attribute if needed
344344
if len(tl) > len(pt) and start is not None:
345345
start = ' start="{0}"'.format(self.olstarts[tl])
346-
_list.attributes['start'] = str(self.olstarts[tl])
347346

348347
# This will only increment the count for list items, not
349348
# definition items
@@ -371,19 +370,12 @@ def fTextileList(self, match):
371370
# item, else just create the item
372371
if tl not in ls:
373372
ls[tl] = 1
374-
if i == 0:
375-
_list.add_item(litem, content)
376-
else:
377-
itemtag = ("\n{0}\t<{1}>{2}".format(tabs, litem, content) if
378-
showitem else '')
379-
_sublist = List(litem, attributes)
380-
line = "<{0}l{1}{2}>{3}".format(ltype, atts, start, itemtag)
381-
_sublist.add_item(litem, content)
382-
line = _sublist.process()
373+
itemtag = ("\n{0}\t<{1}>{2}".format(tabs, litem, content) if
374+
showitem else '')
375+
line = "<{0}l{1}{2}>{3}".format(ltype, atts, start, itemtag)
383376
else:
384377
line = ("\t<{0}{1}>{2}".format(litem, atts, content) if
385378
showitem else '')
386-
_list.add_item(litem, content, attributes)
387379
line = '{0}{1}'.format(tabs, line)
388380

389381
if len(nl) <= len(tl):
@@ -408,7 +400,7 @@ def fTextileList(self, match):
408400
#else:
409401
#line = "{0}\n".format(line)
410402
result.append(line)
411-
return self.doTagBr(litem, _list.process())
403+
return self.doTagBr(litem, "\n".join(result))
412404

413405
def doTagBr(self, tag, input):
414406
return re.compile(r'<({0})([^>]*?)>(.*)(</\1>)'.format(re.escape(tag)),

textile/objects/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22
from .list import List
33
from .table import Table
44

5-
__all__ = ['Block', 'List', 'Table']
5+
__all__ = ['Block', 'Table']

0 commit comments

Comments
 (0)