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

dev_forum
daiao 6 years ago
commit eedaff8a9a

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

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

@ -334,6 +334,22 @@ module ApplicationHelper
raw arr.join('') raw arr.join('')
end 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 end

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