allura-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From brond...@apache.org
Subject [40/50] [abbrv] git commit: [#5634] ticket:333 Use h.really_unicode and add comments
Date Thu, 16 May 2013 22:30:31 GMT
[#5634] ticket:333 Use h.really_unicode and add comments


Project: http://git-wip-us.apache.org/repos/asf/incubator-allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-allura/commit/fcd3b587
Tree: http://git-wip-us.apache.org/repos/asf/incubator-allura/tree/fcd3b587
Diff: http://git-wip-us.apache.org/repos/asf/incubator-allura/diff/fcd3b587

Branch: refs/heads/db/6208
Commit: fcd3b5876e810c4d269daf0844d848b420b04237
Parents: 9224324
Author: Igor Bondarenko <jetmind2@gmail.com>
Authored: Wed May 8 14:10:17 2013 +0000
Committer: Dave Brondsema <dbrondsema@slashdotmedia.com>
Committed: Wed May 15 15:44:04 2013 +0000

----------------------------------------------------------------------
 Allura/allura/lib/markdown_extensions.py |   10 +++++++++-
 1 files changed, 9 insertions(+), 1 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/fcd3b587/Allura/allura/lib/markdown_extensions.py
----------------------------------------------------------------------
diff --git a/Allura/allura/lib/markdown_extensions.py b/Allura/allura/lib/markdown_extensions.py
index 62b7fe9..a1158e5 100644
--- a/Allura/allura/lib/markdown_extensions.py
+++ b/Allura/allura/lib/markdown_extensions.py
@@ -252,7 +252,15 @@ class RelativeLinkRewriter(markdown.postprocessors.Postprocessor):
             rewrite(link, 'href')
         for link in soup.findAll('img'):
             rewrite(link, 'src')
-        return unicode(str(soup), "utf-8" )
+        # BeautifulSoup always stores data in unicode,
+        # but when doing unicode(soup) it does some strange things
+        # like nesting html comments, e.g. returns <!--<!-- comment -->-->
+        # instead of <!-- comment -->.
+        # Converting soup object to string representation first,
+        # and then back to unicode avoids that.
+        # str() called on BeautifulSoup document always returns string
+        # encoded in utf-8, so this should always work.
+        return h.really_unicode(str(soup))
 
     def _rewrite(self, tag, attr):
         val = tag.get(attr)


Mime
View raw message