allura-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From brond...@apache.org
Subject [3/7] git commit: [#2835] ticket:290 Convert markdown to plain text before indexation
Date Tue, 26 Mar 2013 21:13:50 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/ec1db8d5
Tree: http://git-wip-us.apache.org/repos/asf/incubator-allura/tree/ec1db8d5
Diff: http://git-wip-us.apache.org/repos/asf/incubator-allura/diff/ec1db8d5

Branch: refs/heads/db/42cc_2835_content_preview
Commit: ec1db8d56ccde9917b159ef91921f8e1f974808b
Parents: ecc187a
Author: Igor Bondarenko <jetmind2@gmail.com>
Authored: Wed Mar 13 13:22:40 2013 +0000
Committer: Dave Brondsema <dbrondsema@geek.net>
Committed: Tue Mar 26 21:10:36 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/ec1db8d5/Allura/allura/lib/search.py
----------------------------------------------------------------------
diff --git a/Allura/allura/lib/search.py b/Allura/allura/lib/search.py
index a428c53..43a4c85 100644
--- a/Allura/allura/lib/search.py
+++ b/Allura/allura/lib/search.py
@@ -3,6 +3,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
 
@@ -17,6 +18,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