aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorArtem Yunusov <nedrlab@gmail.com>2008-08-21 23:56:34 +0500
committerArtem Yunusov <nedrlab@gmail.com>2008-08-21 23:56:34 +0500
commit15fe229e19f218eb99dfb09cc745705a9c2d1e97 (patch)
tree827a01fa82a097774088a4196342bf5bd4ecd72d
parentb4362b3bf562bfb1b79bff9aee07feba32983e58 (diff)
parentc846dbced12091cfa1b783f268db96d8c87be030 (diff)
downloadmarkdown-15fe229e19f218eb99dfb09cc745705a9c2d1e97.tar.gz
markdown-15fe229e19f218eb99dfb09cc745705a9c2d1e97.tar.bz2
markdown-15fe229e19f218eb99dfb09cc745705a9c2d1e97.zip
Merge git@gitorious.org:python-markdown/mainline
Conflicts: markdown.py
-rw-r--r--MANIFEST3
-rw-r--r--docs/AUTHORS1
-rw-r--r--docs/CHANGE_LOG6
-rw-r--r--docs/LICENSE30
-rwxr-xr-xmarkdown.py26
-rw-r--r--tests/misc/autolinks_with_asterisks.html3
-rw-r--r--tests/misc/autolinks_with_asterisks.txt2
-rw-r--r--tests/misc/autolinks_with_asterisks_russian.html3
-rw-r--r--tests/misc/autolinks_with_asterisks_russian.txt3
9 files changed, 65 insertions, 12 deletions
diff --git a/MANIFEST b/MANIFEST
index 4e7e3df..028b0e7 100644
--- a/MANIFEST
+++ b/MANIFEST
@@ -1,5 +1,5 @@
markdown.py
-markdown_extnesions/__init__.py
+markdown_extensions/__init__.py
markdown_extensions/codehilite.py
markdown_extensions/fenced_code.py
markdown_extensions/footnotes.py
@@ -16,5 +16,6 @@ docs/README.html
docs/CHANGE_LOG
docs/INSTALL
docs/AUTHORS
+docs/LICENSE
docs/writing_extensions.txt
diff --git a/docs/AUTHORS b/docs/AUTHORS
index b4cd939..00abb15 100644
--- a/docs/AUTHORS
+++ b/docs/AUTHORS
@@ -32,5 +32,6 @@ Tiago Cogumbreiro
G. Clark Haynes
Daniel Krech
Steward Midwinter
+Neale Pickett
Malcolm Tredinnick
and many others to helped by reporting bugs
diff --git a/docs/CHANGE_LOG b/docs/CHANGE_LOG
index 200d5b7..d040789 100644
--- a/docs/CHANGE_LOG
+++ b/docs/CHANGE_LOG
@@ -1,7 +1,11 @@
PYTHON MARKDOWN CHANGELOG
=========================
-August 2008: Updated included extensions to ElementTree. Added a
+August 18 2008: Reorganized directory structure. Added a 'docs' dir
+and moved all extensions into a 'markdown-extensions' package.
+Added additional documentation and a few bug fixes. (v2.0-beta)
+
+August 4 2008: Updated included extensions to ElementTree. Added a
seperate commanline script. (v2.0-alpha)
July 2008: Switched from home-grown NanoDOM to ElementTree and
diff --git a/docs/LICENSE b/docs/LICENSE
new file mode 100644
index 0000000..4cd8b14
--- /dev/null
+++ b/docs/LICENSE
@@ -0,0 +1,30 @@
+Copyright 2007, 2008 The Python Markdown Project (v. 1.7 and later)
+Copyright 2004, 2005, 2006 Yuri Takhteyev (v. 0.2-1.6b)
+Copyright 2004 Manfred Stienstra (the original version)
+
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+* Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+* Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+* Neither the name of the <organization> nor the
+ names of its contributors may be used to endorse or promote products
+ derived from this software without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE PYTHON MARKDOWN PROJECT ''AS IS'' AND ANY
+EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+DISCLAIMED. IN NO EVENT SHALL ANY CONTRIBUTORS TO THE PYTHON MARKDOWN PROJECT
+BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+POSSIBILITY OF SUCH DAMAGE.
+
diff --git a/markdown.py b/markdown.py
index 628d7d7..dec3e86 100755
--- a/markdown.py
+++ b/markdown.py
@@ -215,6 +215,11 @@ def handleAttributes(text, parent):
return RE.regExp['attr'].sub(attributeCallback, text)
+class AtomicString(unicode):
+ "A string which should not be further processed."
+ pass
+
+
"""
======================================================================
========================== PRE-PROCESSORS ============================
@@ -671,7 +676,7 @@ class LinkPattern (Pattern):
if href:
if href[0] == "<":
href = href[1:-1]
- el.set("href", self.sanatize_url(href.strip()))
+ el.set("href", self.sanitize_url(href.strip()))
else:
el.set("href", "")
@@ -680,7 +685,7 @@ class LinkPattern (Pattern):
el.set("title", title)
return el
- def sanatize_url(self, url):
+ def sanitize_url(self, url):
"""
Sanitize a url against xss attacks in "safe_mode".
@@ -722,7 +727,7 @@ class ImagePattern(LinkPattern):
src = src_parts[0]
if src[0] == "<" and src[-1] == ">":
src = src[1:-1]
- el.set('src', self.sanatize_url(src))
+ el.set('src', self.sanitize_url(src))
else:
el.set('src', "")
if len(src_parts) > 1:
@@ -757,7 +762,7 @@ class ReferencePattern(LinkPattern):
def makeTag(self, href, title, text):
el = etree.Element('a')
- el.set('href', self.sanatize_url(href))
+ el.set('href', self.sanitize_url(href))
if title:
el.set('title', title)
@@ -769,7 +774,7 @@ class ImageReferencePattern (ReferencePattern):
""" Match to a stored reference and return img element. """
def makeTag(self, href, title, text):
el = etree.Element("img")
- el.set("src", self.sanatize_url(href))
+ el.set("src", self.sanitize_url(href))
if title:
el.set("title", title)
el.set("alt", text)
@@ -781,7 +786,7 @@ class AutolinkPattern (Pattern):
def handleMatch(self, m):
el = etree.Element("a")
el.set('href', m.group(2))
- el.text = m.group(2)
+ el.text = AtomicString(m.group(2))
return el
class AutomailPattern (Pattern):
@@ -794,9 +799,9 @@ class AutomailPattern (Pattern):
email = m.group(2)
if email.startswith("mailto:"):
email = email[len("mailto:"):]
- el.text = ""
- for letter in email:
- el.text += codepoint2name(ord(letter))
+
+ letters = [codepoint2name(ord(letter)) for letter in email]
+ el.text = AtomicString(''.join(letters))
mailto = "mailto:" + email
mailto = "".join([AMP_SUBSTITUTE + '#%d;' %
@@ -1678,9 +1683,10 @@ class Markdown:
Returns: String with placeholders.
"""
+
if isinstance(data, AtomicString):
return data
-
+
startIndex = 0
while patternIndex < len(self.inlinePatterns):
diff --git a/tests/misc/autolinks_with_asterisks.html b/tests/misc/autolinks_with_asterisks.html
new file mode 100644
index 0000000..a7f2609
--- /dev/null
+++ b/tests/misc/autolinks_with_asterisks.html
@@ -0,0 +1,3 @@
+<p>
+ <a href="http://some.site/weird*url*thing">http://some.site/weird*url*thing</a>
+</p> \ No newline at end of file
diff --git a/tests/misc/autolinks_with_asterisks.txt b/tests/misc/autolinks_with_asterisks.txt
new file mode 100644
index 0000000..24de5d9
--- /dev/null
+++ b/tests/misc/autolinks_with_asterisks.txt
@@ -0,0 +1,2 @@
+<http://some.site/weird*url*thing>
+
diff --git a/tests/misc/autolinks_with_asterisks_russian.html b/tests/misc/autolinks_with_asterisks_russian.html
new file mode 100644
index 0000000..05c44c5
--- /dev/null
+++ b/tests/misc/autolinks_with_asterisks_russian.html
@@ -0,0 +1,3 @@
+<p>
+ <a href="http://some.site/нечто*очень*странное">http://some.site/нечто*очень*странное</a>
+</p> \ No newline at end of file
diff --git a/tests/misc/autolinks_with_asterisks_russian.txt b/tests/misc/autolinks_with_asterisks_russian.txt
new file mode 100644
index 0000000..74465f1
--- /dev/null
+++ b/tests/misc/autolinks_with_asterisks_russian.txt
@@ -0,0 +1,3 @@
+<http://some.site/нечто*очень*странное>
+
+