Hard wrap in question markdown

This commit is contained in:
Karina Kwiatek 2023-02-15 23:52:10 +01:00
parent 062ca6e65a
commit 9988527580
2 changed files with 5 additions and 3 deletions

View File

@ -6,9 +6,7 @@ class QuestionMarkdown < Redcarpet::Render::StripDown
include Rails.application.routes.url_helpers
include SharedMarkers
def paragraph(text)
"<p>#{text}</p>"
end
def paragraph(text) = "<p>#{text.gsub("\n", '<br>')}</p>"
def link(link, _title, _content)
process_link(link)

View File

@ -74,6 +74,10 @@ describe MarkdownHelper, type: :helper do
it "should not process invalid links" do
expect(question_markdown("https://example.com/example.質問")).to eq("<p>https://example.com/example.質問</p>")
end
it "should turn line breaks into <br> tags" do
expect(markdown("Some\ntext")).to eq("<p>Some<br>\ntext</p>")
end
end
describe "#raw_markdown" do