Add question markup renderer

This commit is contained in:
Andreas Nedbal 2021-12-30 17:59:44 +01:00 committed by Andreas Nedbal
parent 09172a56ef
commit 67ee589b5b
4 changed files with 13 additions and 3 deletions

View File

@ -0,0 +1,10 @@
require 'uri'
class QuestionMarkdown < Redcarpet::Render::Base
include Rails.application.routes.url_helpers
include SharedMarkers
def paragraph(text)
"<p>#{text}</p>"
end
end

View File

@ -29,4 +29,4 @@
%a{ href: show_user_question_path(a.question.user.screen_name, a.question.id) } %a{ href: show_user_question_path(a.question.user.screen_name, a.question.id) }
= pluralize(a.question.answer_count, t('views.general.answer')) = pluralize(a.question.answer_count, t('views.general.answer'))
.answerbox__question-text .answerbox__question-text
= a.question.content = question_markdown a.question.content

View File

@ -11,7 +11,7 @@
· ·
%a{ href: show_user_question_path(i.question.user.screen_name, i.question.id) } %a{ href: show_user_question_path(i.question.user.screen_name, i.question.id) }
= pluralize(i.question.answer_count, t('views.inbox.entry.response')) = pluralize(i.question.answer_count, t('views.inbox.entry.response'))
%p.answerbox__question-text= i.question.content %p.answerbox__question-text= question_markdown i.question.content
- if i.question.user_id != current_user.id || current_user.has_role?(:administrator) - if i.question.user_id != current_user.id || current_user.has_role?(:administrator)
.pull-right .pull-right
.btn-group .btn-group

View File

@ -30,4 +30,4 @@
= user_screen_name question.user, anonymous: question.author_is_anonymous, url: false = user_screen_name question.user, anonymous: question.author_is_anonymous, url: false
- else - else
= raw t('views.answerbox.asked', user: user_screen_name(question.user, anonymous: question.author_is_anonymous), time: time_tooltip(question)) = raw t('views.answerbox.asked', user: user_screen_name(question.user, anonymous: question.author_is_anonymous), time: time_tooltip(question))
%p.answerbox__question-text= question.content %p.answerbox__question-text= question_markdown question.content