aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorArtem Yunusov <nedrlab@gmail.com>2008-08-23 00:48:08 +0500
committerArtem Yunusov <nedrlab@gmail.com>2008-08-23 00:48:08 +0500
commit96576db3bf5f1b035dd312ba567facabd015b142 (patch)
tree79bbbb0ec1fdefe36778080a10416366491ac792
parentafd55854e33d60d6177982bfa9b33d7cafafdd57 (diff)
downloadmarkdown-96576db3bf5f1b035dd312ba567facabd015b142.tar.gz
markdown-96576db3bf5f1b035dd312ba567facabd015b142.tar.bz2
markdown-96576db3bf5f1b035dd312ba567facabd015b142.zip
Added check for AtomicStrinc instead of ['code', 'pre'] check, deleted some commented code lines.
-rwxr-xr-xmarkdown.py26
1 files changed, 7 insertions, 19 deletions
diff --git a/markdown.py b/markdown.py
index a835627..5012ffa 100755
--- a/markdown.py
+++ b/markdown.py
@@ -636,7 +636,7 @@ class BacktickPattern (Pattern):
def handleMatch(self, m):
el = etree.Element(self.tag)
- el.text = m.group(3).strip()
+ el.text = AtomicString(m.group(3).strip())
return el
@@ -1439,8 +1439,6 @@ class Markdown:
level = len(m.group(1))
h = etree.SubElement(parentElem, "h%d" % level)
h.text = m.group(2).strip()
- #inline = etree.SubElement(h, "inline")
- #inline.text = m.group(2).strip()
else:
message(CRITICAL, "We've got a problem header!")
@@ -1464,16 +1462,11 @@ class Markdown:
for line in paragraph:
# it's hr
if RE.regExp["isline3"].match(line):
- #inline = etree.SubElement(el, "inline")
- #inline.text = "\n".join(dump)
el.text = "\n".join(dump)
- #etree.SubElement(el, "hr")
self._processHR(el)
dump = []
# it's header
elif line.startswith("#"):
- #inline = etree.SubElement(el, "inline")
- #inline.text = "\n".join(dump)
el.text = "\n".join(dump)
self._processHeader(parentElem, [line])
dump = []
@@ -1481,8 +1474,6 @@ class Markdown:
dump.append(line)
if dump:
text = "\n".join(dump)
- #inline = etree.SubElement(el, "inline")
- #inline.text = text
el.text = text
def _processUList(self, parentElem, lines, inList):
@@ -1667,7 +1658,7 @@ class Markdown:
code = etree.SubElement(pre, "code")
text = "\n".join(detabbed).rstrip()+"\n"
- code.text = text
+ code.text = AtomicString(text)
self._processSection(parentElem, theRest, inList)
def _handleInline(self, data, patternIndex=0):
@@ -1726,8 +1717,8 @@ class Markdown:
if node is None:
return data, True, len(leftData) + match.span(len(match.groups()))[0]
- if not isstr(node):
- if not node.tag in ["code", "pre"]:
+ if not isstr(node):
+ if not isinstance(node.text, AtomicString):
# We need to process current node too
for child in [node] + node.getchildren():
if not isstr(node):
@@ -1875,11 +1866,9 @@ class Markdown:
currElement = stack.pop()
insertQueue = []
for child in currElement.getchildren():
-
- #if child.tag == "inline":
- if not isinstance(child.text, AtomicString) and child.text \
- and not child.tag in ["code", "pre"]:
-
+
+ if not isinstance(child.text, AtomicString) and child.text:
+
text = child.text
child.text = None
lst = self._processPlaceholders(self._handleInline(
@@ -1895,7 +1884,6 @@ class Markdown:
for element, lst in insertQueue:
- #currElement.remove(element)
if element.text:
element.text = handleAttributes(element.text,
element)