Skip to content

Commit

Permalink
Folding long lines where possible to improve readability.
Browse files Browse the repository at this point in the history
  • Loading branch information
kurtraschke committed Jul 13, 2010
1 parent a8afa3e commit 66342dd
Showing 1 changed file with 19 additions and 9 deletions.
28 changes: 19 additions & 9 deletions textile/functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -366,7 +366,8 @@ def fList(self, match):
except IndexError:
nextline = ''

m = re.search(r"^([#*]+)(%s%s) (.*)$" % (self.align_re, self.c), line, re.S)
m = re.search(r"^([#*]+)(%s%s) (.*)$" % (self.align_re,
self.c), line, re.S)
if m:
tl, atts, content = m.groups()
nl = ''
Expand All @@ -376,7 +377,8 @@ def fList(self, match):
if tl not in lists:
lists.append(tl)
atts = self.pba(atts)
line = "\t<%sl%s>\n\t\t<li>%s" % (self.listType(tl), atts, self.graf(content))
line = "\t<%sl%s>\n\t\t<li>%s" % (self.listType(tl),
atts, self.graf(content))
else:
line = "\t\t<li>" + self.graf(content)

Expand All @@ -399,7 +401,8 @@ def listType(self, list_string):
return 'u'

def doPBr(self, in_):
return re.compile(r'<(p)([^>]*?)>(.*)(</\1>)', re.S).sub(self.doBr, in_)
return re.compile(r'<(p)([^>]*?)>(.*)(</\1>)', re.S).sub(self.doBr,
in_)

def doBr(self, match):
if self.html_type == 'html':
Expand Down Expand Up @@ -431,7 +434,9 @@ def block(self, text, head_offset=0):

anon = False
for line in text:
pattern = r'^(%s)(%s%s)\.(\.?)(?::(\S+))? (.*)$' % (tre, self.align_re, self.c)
pattern = r'^(%s)(%s%s)\.(\.?)(?::(\S+))? (.*)$' % (tre,
self.align_re,
self.c)
match = re.search(pattern, line, re.S)
if match:
if ext:
Expand Down Expand Up @@ -533,15 +538,17 @@ def fBlock(self, tag, atts, ext, cite, content):
o2 = "<code%s>" % atts
c2 = "</code>"
c1 = "</pre>"
content = self.shelve(self.encode_html(content.rstrip("\n") + "\n"))
content = self.shelve(self.encode_html(content.rstrip("\n") +
"\n"))

elif tag == 'notextile':
content = self.shelve(content)
o1 = o2 = ''
c1 = c2 = ''

elif tag == 'pre':
content = self.shelve(self.encode_html(content.rstrip("\n") + "\n"))
content = self.shelve(self.encode_html(content.rstrip("\n") +
"\n"))
o1 = "<pre%s>" % atts
o2 = c2 = ''
c1 = '</pre>'
Expand All @@ -559,7 +566,8 @@ def footnoteRef(self, text):
>>> t.footnoteRef('foo[1] ') # doctest: +ELLIPSIS
'foo<sup class="footnote"><a href="#fn...">1</a></sup> '
"""
return re.compile(r'\b\[([0-9]+)\](\s)?', re.U).sub(self.footnoteID, text)
return re.compile(r'\b\[([0-9]+)\](\s)?', re.U).sub(self.footnoteID,
text)

def footnoteID(self, match):
footnoteNum, text = match.groups()
Expand Down Expand Up @@ -831,7 +839,8 @@ def fLink(self, match):
text = self.glyphs(text)

url = self.relURL(url)
out = '<a href="%s"%s%s>%s</a>' % (self.encode_html(url), atts, self.rel, text)
out = '<a href="%s"%s%s>%s</a>' % (self.encode_html(url),
atts, self.rel, text)
out = self.shelve(out)
return ''.join([pre, out, post])

Expand All @@ -841,7 +850,8 @@ def span(self, text):
>>> t.span(r"hello %(bob)span *strong* and **bold**% goodbye")
'hello <span class="bob">span <strong>strong</strong> and <b>bold</b></span> goodbye'
"""
qtags = (r'\*\*', r'\*', r'\?\?', r'\-', r'__', r'_', r'%', r'\+', r'~', r'\^')
qtags = (r'\*\*', r'\*', r'\?\?', r'\-', r'__',
r'_', r'%', r'\+', r'~', r'\^')
pnct = ".,\"'?!;:"

for qtag in qtags:
Expand Down

0 comments on commit 66342dd

Please sign in to comment.