Skip to content

Commit db7cd11

Browse files
committed
cleanup fBlock.
1 parent 5eb647e commit db7cd11

1 file changed

Lines changed: 30 additions & 24 deletions

File tree

textile/core.py

Lines changed: 30 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -628,8 +628,11 @@ def block(self, text):
628628
def fBlock(self, tag, atts, ext, cite, content):
629629
att = atts
630630
attributes = parse_attributes(att)
631-
output = {'outer_tag': '', 'inner_tag': '', 'outer_atts': OrderedDict(),
632-
'inner_atts': OrderedDict(), 'content': content, 'eat': False}
631+
outer_tag = ''
632+
inner_tag = ''
633+
outer_atts = OrderedDict()
634+
inner_atts = OrderedDict()
635+
eat = False
633636

634637
if tag == 'p':
635638
# is this an anonymous block with a note definition?
@@ -643,14 +646,13 @@ def fBlock(self, tag, atts, ext, cite, content):
643646
(?P<content>.*)$ # content""".format(
644647
space=regex_snippets['space'], cls=cls_re_s),
645648
flags=re.X | re.U)
646-
notedef = notedef_re.sub(self.fParseNoteDefs, output['content'])
649+
notedef = notedef_re.sub(self.fParseNoteDefs, content)
647650

648651
# It will be empty if the regex matched and ate it.
649652
if '' == notedef:
650-
output['content'] = notedef
651-
return (output['outer_tag'], output['outer_atts'],
652-
output['inner_tag'], output['inner_atts'],
653-
output['content'], output['eat'])
653+
content = notedef
654+
return (outer_tag, outer_atts, inner_tag, inner_atts, content,
655+
eat)
654656

655657
fns = re.search(r'fn(?P<fnid>{0}+)'.format(regex_snippets['digit']),
656658
tag, flags=re.U)
@@ -683,7 +685,7 @@ def fBlock(self, tag, atts, ext, cite, content):
683685
'#fnrev{0}'.format(fnid)})
684686
sup = generate_tag('sup', fnrev, supp_id)
685687

686-
output['content'] = '{0} {1}'.format(sup, output['content'])
688+
content = '{0} {1}'.format(sup, content)
687689

688690
if tag == 'bq':
689691
if cite:
@@ -694,35 +696,39 @@ def fBlock(self, tag, atts, ext, cite, content):
694696
cite = ''
695697
cite_att = OrderedDict()
696698
cite_att.update(attributes)
697-
output.update({'outer_tag': 'blockquote', 'outer_atts': cite_att,
698-
'inner_tag': 'p', 'inner_atts': attributes, 'eat': False})
699+
outer_tag = 'blockquote'
700+
outer_atts = cite_att
701+
inner_tag = 'p'
702+
inner_atts = attributes
703+
eat = False
699704

700705
elif tag == 'bc' or tag == 'pre':
701706
i_tag = ''
702707
if tag == 'bc':
703708
i_tag = 'code'
704-
content = self.shelve(encode_html('{0}\n'.format( output[
705-
'content'].rstrip("\n"))))
706-
output = {'outer_tag': 'pre', 'outer_atts': attributes,
707-
'inner_tag': i_tag, 'inner_atts': attributes, 'content':
708-
content, 'eat': False}
709+
content = self.shelve(encode_html('{0}\n'.format(
710+
content.rstrip("\n"))))
711+
outer_tag = 'pre'
712+
outer_atts = attributes
713+
inner_tag = i_tag
714+
inner_atts = attributes
715+
eat = False
709716

710717
elif tag == 'notextile':
711-
output['content'] = self.shelve(output['content'])
718+
content = self.shelve(content)
712719

713720
elif tag == '###':
714-
output['eat'] = True
721+
eat = True
715722

716723
else:
717-
output['outer_tag'] = tag
718-
output['outer_atts'] = attributes
724+
outer_tag = tag
725+
outer_atts = attributes
719726

720-
if not output['eat']:
721-
output['content'] = self.graf(output['content'])
727+
if not eat:
728+
content = self.graf(content)
722729
else:
723-
output['content'] = ''
724-
return (output['outer_tag'], output['outer_atts'], output['inner_tag'],
725-
output['inner_atts'], output['content'], output['eat'])
730+
content = ''
731+
return (outer_tag, outer_atts, inner_tag, inner_atts, content, eat)
726732

727733
def footnoteRef(self, text):
728734
# somehow php-textile gets away with not capturing the space.

0 commit comments

Comments
 (0)