dev_forum
SylorHuang 6 years ago
parent 6110df20bd
commit b320715e6e

@ -335,8 +335,7 @@ module ApplicationHelper
end end
def to_markdown(text) def to_markdown(text)
Rails.logger.info("#########################text______________tedxt_________________###{text}") request_url = request.base_url
Rails.logger.info("#########################text______________request_base_url________________###{request.base_url}")
return nil if text.blank? return nil if text.blank?
options = { options = {
@ -350,9 +349,9 @@ module ApplicationHelper
} }
markdown = Redcarpet::Markdown.new(Redcarpet::Render::HTML,options) markdown = Redcarpet::Markdown.new(Redcarpet::Render::HTML,options)
m_t = markdown.render(text) m_t = markdown.render(text)
q_title = m_t &.include?("src=\"") ? m_t&.gsub("src=\"","src=\"#{@request_url}")&.html_safe : m_t ss = m_t&.include?("src=\"") ? m_t&.gsub("src=\"","src=\"#{request_url}")&.html_safe : m_t
Rails.logger.info("#########################text______________markdown.render(text)________________###{q_title }") Rails.logger.info("############_____________ss________________##################{ss}")
q_title ss
end end
end end

@ -69,16 +69,14 @@
</div> </div>
<div class="pbt5"> <div class="pbt5">
<% q_markdown = to_markdown(q.question_title) %> <% 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_markdown_name = to_markdown(q.shixun_name) %> <% 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" ><%= q_markdown_name %></span>
<span class="ques-title" id="ques_marked_<%= index %>"><%= q_name %></span>
<div class="mt8 text-gray"> <div class="mt8 text-gray">
<span id="ques_title_<%= index %>"><%= q_markdown %></span> <span><%= q_markdown %></span>
</div> </div>
<% else %> <% else %>
<span class="ques-title" id="ques_title_<%= index %>"><%= q_markdown %></span> <span class="ques-title"><%= q_markdown %></span>
<% end %> <% end %>
</div> </div>
<div class="pbt5"> <div class="pbt5">
@ -86,14 +84,14 @@
<% q.exercise_choices.each_with_index do |s,index| %> <% q.exercise_choices.each_with_index do |s,index| %>
<p class="pbt5"> <p class="pbt5">
<span class="choose-radio"></span> <span class="choose-radio"></span>
<span class="mr15"><%= convert_to_char((index+1).to_s)%></span><%= s.choice_text%> <span class="mr15"><%= convert_to_char((index+1).to_s)%></span><%= to_markdown(s.choice_text) %>
</p> </p>
<% end %> <% end %>
<% elsif q.question_type == 1 %> <% elsif q.question_type == 1 %>
<% q.exercise_choices.each_with_index do |s,index| %> <% q.exercise_choices.each_with_index do |s,index| %>
<p class="pbt5"> <p class="pbt5">
<span class="choose-checkbox"></span> <span class="choose-checkbox"></span>
<span class="mr20"><%= convert_to_char((index+1).to_s)%></span><%= s.choice_text%> <span class="mr20"><%= convert_to_char((index+1).to_s)%></span><%= to_markdown(s.choice_text) %>
</p> </p>
<% end %> <% end %>
<% elsif q.question_type == 2 %> <% elsif q.question_type == 2 %>
@ -101,7 +99,7 @@
<% q.exercise_choices.each_with_index do |s,index| %> <% q.exercise_choices.each_with_index do |s,index| %>
<span class="mr15"> <span class="mr15">
<span class="choose-radio"></span> <span class="choose-radio"></span>
<span class="mlr5"><%= s.choice_text %></span> <span class="mlr5"><%= to_markdown(s.choice_text) %></span>
</span> </span>
<% end %> <% end %>
</p> </p>

Loading…
Cancel
Save