Merge branch 'dev_aliyun' of https://bdgit.educoder.net/Hjqreturn/educoder into dev_aliyun

dev_forum
daiao 5 years ago
commit eedaff8a9a

@ -39,6 +39,8 @@ gem 'pdfkit'
gem 'wkhtmltopdf-binary'
#gem 'iconv'
# markdown 转html
gem 'redcarpet', '~> 3.4'
gem 'rqrcode', '~> 0.10.1'
gem 'rqrcode_png'

@ -193,6 +193,7 @@ GEM
rb-inotify (0.9.10)
ffi (>= 0.5.0, < 2)
rchardet (1.8.0)
redcarpet (3.4.0)
redis (4.1.0)
redis-actionpack (5.0.2)
actionpack (>= 4.0, < 6)
@ -328,6 +329,7 @@ DEPENDENCIES
rails (~> 5.2.0)
rails-i18n (~> 5.1)
rchardet (~> 1.8)
redcarpet (~> 3.4)
redis-rails
roo-xls
rqrcode (~> 0.10.1)

@ -334,6 +334,22 @@ module ApplicationHelper
raw arr.join('')
end
def to_markdown(text)
return nil if text.blank?
options = {
:autolink => true,
:no_intra_emphasis => true,
:fenced_code_blocks => true,
:lax_html_blocks => true,
:strikethrough => true,
:superscript => true,
:tables => true
}
markdown = Redcarpet::Markdown.new(Redcarpet::Render::HTML,options)
markdown.render(text).html_safe
end
end

@ -68,15 +68,17 @@
<span class="text-gray mlr5">(<%= q&.question_score %>分)</span>
</div>
<div class="pbt5">
<% q_title = q.question_title&.html_safe %>
<% q_markdown = to_markdown(q.question_title) %>
<% q_title = q_markdown&.include?("src=\"") ? q_markdown&.gsub("src=\"","src=\"#{@request_url}")&.html_safe : q_markdown %>
<% if q.question_type == 5 %>
<% q_name = q.shixun_name&.html_safe %>
<span class="ques-title"><%= q_name&.include?("src=\"") ? q_name&.gsub("src=\"","src=\"#{@request_url}") : q_name %></span>
<% q_markdown_name = to_markdown(q.shixun_name) %>
<% q_name = q_markdown_name&.include?("src=\"") ? q_markdown_name&.gsub("src=\"","src=\"#{@request_url}")&.html_safe : q_markdown_name %>
<span class="ques-title" id="ques_marked_<%= index %>"><%= q_name %></span>
<div class="mt8 text-gray">
<span><%= q_title&.include?("src=\"") ? q_title&.gsub("src=\"","src=\"#{@request_url}") : q_title %></span>
<span id="ques_title_<%= index %>"><%= q_title %></span>
</div>
<% else %>
<span class="ques-title"><%= q_title&.include?("src=\"") ? q_title&.gsub("src=\"","src=\"#{@request_url}") : q_title %></span>
<span class="ques-title" id="ques_title_<%= index %>"><%= q_title %></span>
<% end %>
</div>
<div class="pbt5">
@ -134,4 +136,5 @@
</div>
</div>
</body>
</html>
Loading…
Cancel
Save