aboutsummaryrefslogtreecommitdiff
path: root/js/markdown
diff options
context:
space:
mode:
authorJohn MacFarlane <jgm@berkeley.edu>2014-09-04 09:28:59 -0700
committerJohn MacFarlane <jgm@berkeley.edu>2014-09-04 09:28:59 -0700
commit2c2424f346c459e1afe093896fcb18390abb3fa6 (patch)
treed8a138991fcfcc2aecef7cc3bb2585f65d8a8f6b /js/markdown
parent023b8aadc69f1d84f5b6b275c9f60dd84ce00e27 (diff)
parent109beaca36bf2ab5af6ab8eab47075d803eb4430 (diff)
Merge pull request #32 from emwap/patch-1
Fix typo
Diffstat (limited to 'js/markdown')
0 files changed, 0 insertions, 0 deletions
s="hl opt">= False
  • self.output = ""
  • self.last_tag = ""
  • def handle_data(self, data):
  • after_tag = self.last == "endtag" or self.last == "starttag"
  • after_block_tag = after_tag and self.is_block_tag(self.last_tag)
  • if after_tag and self.last_tag == "br":
  • data = data.lstrip('\n')
  • if not self.in_pre:
  • data = whitespace_re.sub(' ', data)
  • if after_block_tag and not self.in_pre:
  • if self.last == "starttag":
  • data = data.lstrip()
  • elif self.last == "endtag":
  • data = data.strip()
  • self.output += data
  • self.last = "data"
  • def handle_endtag(self, tag):
  • if tag == "pre":
  • self.in_pre = False
  • elif self.is_block_tag(tag):
  • self.output = self.output.rstrip()
  • self.output += "</" + tag + ">"
  • self.last_tag = tag
  • self.last = "endtag"
  • def handle_starttag(self, tag, attrs):
  • if tag == "pre":
  • self.in_pre = True
  • if self.is_block_tag(tag):
  • self.output = self.output.rstrip()
  • self.output += "<" + tag
  • # For now we don't strip out 'extra' attributes, because of
  • # raw HTML test cases.
  • # attrs = filter(lambda attr: attr[0] in significant_attrs, attrs)
  • if attrs:
  • attrs.sort()
  • for (k,v) in attrs:
  • self.output += " " + k
  • if v in ['href','src']:
  • self.output += ("=" + '"' +
  • urllib.quote(urllib.unquote(v), safe='/') + '"')
  • elif v != None:
  • self.output += ("=" + '"' + cgi.escape(v,quote=True) + '"')
  • self.output += ">"
  • self.last_tag = tag
  • self.last = "starttag"
  • def handle_startendtag(self, tag, attrs):
  • """Ignore closing tag for self-closing """
  • self.handle_starttag(tag, attrs)
  • self.last_tag = tag
  • self.last = "endtag"
  • def handle_comment(self, data):
  • self.output += '<!--' + data + '-->'
  • self.last = "comment"
  • def handle_decl(self, data):
  • self.output += '<!' + data + '>'
  • self.last = "decl"
  • def unknown_decl(self, data):
  • self.output += '<!' + data + '>'
  • self.last = "decl"
  • def handle_pi(self,data):
  • self.output += '<?' + data + '>'
  • self.last = "pi"
  • def handle_entityref(self, name):
  • try:
  • c = chr(name2codepoint[name])
  • except KeyError:
  • c = None
  • self.output_char(c, '&' + name + ';')
  • self.last = "ref"
  • def handle_charref(self, name):
  • try:
  • if name.startswith("x"):
  • c = chr(int(name[1:], 16))
  • else:
  • c = chr(int(name))
  • except ValueError:
  • c = None
  • self.output_char(c, '&' + name + ';')
  • self.last = "ref"
  • # Helpers.
  • def output_char(self, c, fallback):
  • if c == '<':
  • self.output += "&lt;"
  • elif c == '>':
  • self.output += "&gt;"
  • elif c == '&':
  • self.output += "&amp;"
  • elif c == '"':