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) }
= pluralize(a.question.answer_count, t('views.general.answer'))
.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) }
= 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)
.pull-right
.btn-group

View file

@ -30,4 +30,4 @@
= user_screen_name question.user, anonymous: question.author_is_anonymous, url: false
- else
= 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