From 3a78823a59e9d0c89d541b2bd259ecfc55aef2cd Mon Sep 17 00:00:00 2001 From: Yuri Takhteyev Date: Wed, 6 Aug 2008 17:23:06 -0700 Subject: Adding LICENSE.txt --- LICENSE.txt | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 LICENSE.txt diff --git a/LICENSE.txt b/LICENSE.txt new file mode 100644 index 0000000..4cd8b14 --- /dev/null +++ b/LICENSE.txt @@ -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 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. + -- cgit v1.2.3 From 17292efebc8c64fe646935fc420cd703003c007f Mon Sep 17 00:00:00 2001 From: Neale Pickett Date: Wed, 20 Aug 2008 21:09:48 -0600 Subject: Pattern.compiled_re > I suppose one thing to do would be to somehow "annotate" nodes to > specify that they should not have their children processed. Artem, > what would you suggest? Then, nodes created with [...]() would > get their children processed, but those created with autolinks (<...>) > will be marked as done. Okay, I promise to get on the mail list, but this was such an obvious and elegant solution that I couldn't wait for the subscription to finish. Any objections to me starting a branch and pushing this to your gitorious project? ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ --- markdown.py | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/markdown.py b/markdown.py index 40cfc61..a38c6ba 100755 --- a/markdown.py +++ b/markdown.py @@ -210,6 +210,11 @@ def handleAttributes(text, parent): return RE.regExp['attr'].sub(attributeCallback, text) +class AtomicString(str): + "A string which should not be further processed." + pass + + """ ====================================================================== ========================== PRE-PROCESSORS ============================ @@ -776,7 +781,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): @@ -789,9 +794,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;' % @@ -1661,6 +1666,10 @@ class Markdown: Returns: String with placeholders. """ + + if isinstance(data, AtomicString): + return data + startIndex = 0 while patternIndex < len(self.inlinePatterns): -- cgit v1.2.3 From 8ba141154f663f2e46e6124396eca6d0443fdb37 Mon Sep 17 00:00:00 2001 From: Yuri Takhteyev Date: Wed, 20 Aug 2008 22:57:46 -0700 Subject: Changing string to unicode in Neale's fix. Adding test cases. --- markdown.py | 2 +- tests/misc/autolinks_with_asterisks.html | 3 +++ tests/misc/autolinks_with_asterisks.txt | 2 ++ 3 files changed, 6 insertions(+), 1 deletion(-) create mode 100644 tests/misc/autolinks_with_asterisks.html create mode 100644 tests/misc/autolinks_with_asterisks.txt diff --git a/markdown.py b/markdown.py index a38c6ba..69616be 100755 --- a/markdown.py +++ b/markdown.py @@ -210,7 +210,7 @@ def handleAttributes(text, parent): return RE.regExp['attr'].sub(attributeCallback, text) -class AtomicString(str): +class AtomicString(unicode): "A string which should not be further processed." pass 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 @@ +

+ http://some.site/weird*url*thing +

\ 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 @@ + + -- cgit v1.2.3 From e71751f0eb7382dc876f2536d2ad5bfbe372e2f0 Mon Sep 17 00:00:00 2001 From: Yuri Takhteyev Date: Wed, 20 Aug 2008 23:02:30 -0700 Subject: Adding unicode tests for Neale's fix. (Those only pass after changing str to unicode.) --- tests/misc/autolinks_with_asterisks_russian.html | 3 +++ tests/misc/autolinks_with_asterisks_russian.txt | 3 +++ 2 files changed, 6 insertions(+) create mode 100644 tests/misc/autolinks_with_asterisks_russian.html create mode 100644 tests/misc/autolinks_with_asterisks_russian.txt 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 @@ +

+ http://some.site/нечто*очень*странное +

\ 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 @@ + + + -- cgit v1.2.3 From 4771f035060581fa407cee5d43a5ea9881a48a82 Mon Sep 17 00:00:00 2001 From: Waylan Limberg Date: Thu, 21 Aug 2008 09:01:11 -0400 Subject: Fixed typo in MANIFEST. --- MANIFEST | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MANIFEST b/MANIFEST index 4e7e3df..79acce5 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 -- cgit v1.2.3 From 561a10e7579105e9b28c54f39ad0a4239a32ced4 Mon Sep 17 00:00:00 2001 From: Waylan Limberg Date: Thu, 21 Aug 2008 09:15:27 -0400 Subject: Added LICENSE to MANIFEST and moved into docs. --- LICENSE.txt | 30 ------------------------------ MANIFEST | 1 + docs/LICENSE | 30 ++++++++++++++++++++++++++++++ 3 files changed, 31 insertions(+), 30 deletions(-) delete mode 100644 LICENSE.txt create mode 100644 docs/LICENSE diff --git a/LICENSE.txt b/LICENSE.txt deleted file mode 100644 index 4cd8b14..0000000 --- a/LICENSE.txt +++ /dev/null @@ -1,30 +0,0 @@ -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 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/MANIFEST b/MANIFEST index 79acce5..028b0e7 100644 --- a/MANIFEST +++ b/MANIFEST @@ -16,5 +16,6 @@ docs/README.html docs/CHANGE_LOG docs/INSTALL docs/AUTHORS +docs/LICENSE docs/writing_extensions.txt 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 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. + -- cgit v1.2.3 From 9f87d5cfbbddb87c73169e807824ed1c5cdca71d Mon Sep 17 00:00:00 2001 From: Waylan Limberg Date: Thu, 21 Aug 2008 11:30:06 -0400 Subject: Updated AUTHORS and CHANGE_LOG --- docs/AUTHORS | 1 + docs/CHANGE_LOG | 6 +++++- 2 files changed, 6 insertions(+), 1 deletion(-) 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 -- cgit v1.2.3 From c846dbced12091cfa1b783f268db96d8c87be030 Mon Sep 17 00:00:00 2001 From: Yuri Takhteyev Date: Thu, 21 Aug 2008 10:57:52 -0700 Subject: "sanatize_url" -> "sanitize_url" --- markdown.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/markdown.py b/markdown.py index 69616be..ef875de 100755 --- a/markdown.py +++ b/markdown.py @@ -671,7 +671,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 +680,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 +722,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 +757,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 +769,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) -- cgit v1.2.3