incubator-allura-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From john...@apache.org
Subject [19/50] git commit: [#2835] ticket:290 Convert markdown to plain text before indexation
Date Wed, 24 Apr 2013 22:30:44 GMT
[#2835] ticket:290 Convert markdown to plain text before indexation


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

Branch: refs/heads/cj/5655
Commit: 46db582d6a47fb16c9802aa25940ecd029ef6093
Parents: 0a42328
Author: Igor Bondarenko <jetmind2@gmail.com>
Authored: Wed Mar 13 13:22:40 2013 +0000
Committer: Dave Brondsema <dbrondsema@slashdotmedia.com>
Committed: Wed Apr 24 16:34:40 2013 +0000

----------------------------------------------------------------------
 Allura/allura/lib/search.py |    6 ++++++
 1 files changed, 6 insertions(+), 0 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/46db582d/Allura/allura/lib/search.py
----------------------------------------------------------------------
diff --git a/Allura/allura/lib/search.py b/Allura/allura/lib/search.py
index 04b6ec3..d9c300a 100644
--- a/Allura/allura/lib/search.py
+++ b/Allura/allura/lib/search.py
@@ -20,6 +20,7 @@ import socket
 from logging import getLogger
 
 import markdown
+import jinja2
 from pylons import tmpl_context as c, app_globals as g
 from pysolr import SolrError
 
@@ -34,6 +35,11 @@ def solarize(obj):
     # if index() returned doc without text, assume empty text
     if not doc.get('text'):
         doc['text'] = ''
+    # Convert text to plain text (It usually contains markdown markup).
+    # To do so, we convert markdown into html, and then strip all html tags.
+    text = doc['text']
+    text = g.markdown.convert(text)
+    doc['text'] = jinja2.Markup.escape(text).striptags()
     return doc
 
 class SearchError(SolrError):


Mime
View raw message