1
0
Fork 0
forked from gitea/nas

Fix status text single-line via markdown

This commit is contained in:
KMY 2023-03-04 15:58:53 +09:00
parent 44ef5a6173
commit 245309d679

View file

@ -46,6 +46,8 @@ class TextFormatter
html = markdownify(html) html = markdownify(html)
# html = simple_format(html, {}, sanitize: false).delete("\n") if multiline? # html = simple_format(html, {}, sanitize: false).delete("\n") if multiline?
html = html.delete("\n")
p html
html.html_safe # rubocop:disable Rails/OutputSafety html.html_safe # rubocop:disable Rails/OutputSafety
end end
@ -162,7 +164,7 @@ class TextFormatter
# not need filter_html because escape is already done # not need filter_html because escape is already done
@htmlobj ||= MyMarkdownHTML.new( @htmlobj ||= MyMarkdownHTML.new(
filter_html: false, filter_html: false,
hard_wrap: false, hard_wrap: true,
no_styles: true no_styles: true
) )
@markdown ||= Redcarpet::Markdown.new(@htmlobj, @markdown ||= Redcarpet::Markdown.new(@htmlobj,
@ -181,16 +183,12 @@ class TextFormatter
nil nil
end end
def linebreak
nil
end
def block_code(code, language) def block_code(code, language)
"<pre>#{code}</pre>" "<pre>#{process_program_code(code)}</pre>"
end end
def codespan(code) def codespan(code)
"<code>#{escape_tags(code)}</code>" "<code>#{process_program_code(code)}</code>"
end end
def header(text, header_level) def header(text, header_level)
@ -199,8 +197,8 @@ class TextFormatter
private private
def escape_tags(code) def process_program_code(code)
code.gsub(/</, '&lt;').gsub(/>/, '&gt;') code.gsub(/\n/, '<br>')
end end
end end
end end