search highlighting
This commit is contained in:
@@ -105,7 +105,6 @@ $ ->
|
||||
replaceMath: (text) ->
|
||||
text = text.replace /@@(\d+)@@/g, ($0, $1) => @math[$1]
|
||||
@math = null
|
||||
console.log text
|
||||
text
|
||||
|
||||
@replaceMathWrapper: (_this) ->
|
||||
@@ -163,7 +162,6 @@ $ ->
|
||||
$('#file-upload').unbind('change').change(startUploadHandler)
|
||||
|
||||
imageUploadHandler = (elem, input) ->
|
||||
console.log "here"
|
||||
ajaxFileUpload(imageUploadUrl, input, imageUploadHandler)
|
||||
|
||||
editor = new Markdown.Editor(
|
||||
|
||||
@@ -278,15 +278,36 @@ initializeFollowThread = (thread) ->
|
||||
handleEditComment(this)
|
||||
|
||||
initializeContent: (content) ->
|
||||
|
||||
unescapeHighlightTag = (text) ->
|
||||
text.replace(/\<\;highlight\>\;/g, "<span class='search-highlight'>")
|
||||
.replace(/\<\;\/highlight\>\;/g, "</span>")
|
||||
|
||||
stripLatexHighlight = (text) ->
|
||||
text
|
||||
|
||||
markdownWithHighlight = (text) ->
|
||||
converter = Markdown.getMathCompatibleConverter()
|
||||
unescapeHighlightTag stripLatexHighlight converter.makeHtml text
|
||||
|
||||
$content = $(content)
|
||||
initializeVote $content
|
||||
if $content.hasClass("thread")
|
||||
initializeFollowThread $content
|
||||
$local = Discussion.generateLocal($content.children(".discussion-content"))
|
||||
|
||||
$contentTitle = $local(".thread-title")
|
||||
|
||||
if $contentTitle.length
|
||||
$contentTitle.html unescapeHighlightTag stripLatexHighlight $contentTitle.html()
|
||||
|
||||
$contentBody = $local(".content-body")
|
||||
raw_text = $contentBody.html()
|
||||
converter = Markdown.getMathCompatibleConverter()
|
||||
$contentBody.html(converter.makeHtml(raw_text))
|
||||
|
||||
console.log "raw html:"
|
||||
console.log $contentBody.html()
|
||||
|
||||
$contentBody.html markdownWithHighlight $contentBody.html()
|
||||
|
||||
MathJax.Hub.Queue ["Typeset", MathJax.Hub, $contentBody.attr("id")]
|
||||
id = $content.attr("_id")
|
||||
if not Discussion.getContentInfo id, 'editable'
|
||||
|
||||
@@ -42,7 +42,11 @@
|
||||
<div class="discussion-right-wrapper clearfix">
|
||||
${render_title(content, type, **kwargs)}
|
||||
<div class="discussion-content-view">
|
||||
<div class="content-body ${type}-body" id="content-body-${content['id']}">${content['body'] | h}</div>
|
||||
% if content.get('highlighted_body', None):
|
||||
<div class="content-body ${type}-body" id="content-body-${content['id']}">${content['highlighted_body'] | h}</div>
|
||||
% else:
|
||||
<div class="content-body ${type}-body" id="content-body-${content['id']}">${content['body'] | h}</div>
|
||||
% endif
|
||||
<div class="content-raw-body ${type}-raw-body" style="display: none">${content['body'] | h}</div>
|
||||
${render_tags(content, type, **kwargs)}
|
||||
${render_bottom_bar(content, type, **kwargs)}
|
||||
@@ -54,7 +58,11 @@
|
||||
|
||||
<%def name="render_title(content, type, **kwargs)">
|
||||
% if type == "thread":
|
||||
<a class="thread-title" name="${content['id']}" href="javascript:void(0)">${content['title'] | h}</a>
|
||||
% if content.get('highlighted_title', None):
|
||||
<a class="thread-title" name="${content['id']}" href="javascript:void(0)">${content['highlighted_title'] | h}</a>
|
||||
% else:
|
||||
<a class="thread-title" name="${content['id']}" href="javascript:void(0)">${content['title'] | h}</a>
|
||||
% endif
|
||||
% endif
|
||||
</%def>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user