[feedparser commit] r291 - trunk/feedparser

1 view
Skip to first unread message

codesite...@google.com

unread,
Sep 29, 2008, 4:38:43 PM9/29/08
to feedparse...@googlegroups.com
Author: sa3ruby
Date: Mon Sep 29 13:38:19 2008
New Revision: 291

Modified:
trunk/feedparser/feedparser.py

Log:
Handle Jacques distler's nested svg/mathml


Modified: trunk/feedparser/feedparser.py
==============================================================================
--- trunk/feedparser/feedparser.py (original)
+++ trunk/feedparser/feedparser.py Mon Sep 29 13:38:19 2008
@@ -523,7 +523,7 @@
attrs.append(('xmlns',namespace))
if tag=='svg' and namespace=='http://www.w3.org/2000/svg':
attrs.append(('xmlns',namespace))
- if tag == 'svg': self.svgOK = 1
+ if tag == 'svg': self.svgOK += 1
return self.handle_data('<%s%s>' % (tag,
self.strattrs(attrs)), escape=0)

# match namespaces
@@ -559,7 +559,7 @@
prefix = self.namespacemap.get(prefix, prefix)
if prefix:
prefix = prefix + '_'
- if suffix == 'svg': self.svgOK = 0
+ if suffix == 'svg' and self.svgOK: self.svgOK -= 1

# call special handler (if defined) or default handler
methodname = '_end_' + prefix + suffix
@@ -2404,9 +2404,9 @@

# not otherwise acceptable, perhaps it is MathML or SVG?
if tag=='math' and
('xmlns','http://www.w3.org/1998/Math/MathML') in attrs:
- self.mathmlOK = 1
+ self.mathmlOK += 1
if tag=='svg' and ('xmlns','http://www.w3.org/2000/svg') in
attrs:
- self.svgOK = 1
+ self.svgOK += 1

# chose acceptable attributes based on tag class, else bail
if self.mathmlOK and tag in self.mathml_elements:
@@ -2451,10 +2451,10 @@
if tag in self.unacceptable_elements_with_end_tag:
self.unacceptablestack -= 1
if self.mathmlOK and tag in self.mathml_elements:
- if tag == 'math': self.mathmlOK = 0
+ if tag == 'math' and self.mathmlOK: self.mathmlOK -= 1
elif self.svgOK and tag in self.svg_elements:
tag = self.svg_elem_map.get(tag,tag)
- if tag == 'svg': self.svgOK = 0
+ if tag == 'svg' and self.svgOK: self.svgOK -= 1
else:
return
_BaseHTMLProcessor.unknown_endtag(self, tag)

Reply all
Reply to author
Forward
0 new messages