Colorize also the code in single backticks

This commit is contained in:
Sijawusz Pur Rahnama 2022-11-28 11:49:26 +01:00
parent 2113e8c055
commit 4dd62a3ed1

View file

@ -69,15 +69,18 @@ module Ameba::Formatter
output_paragraph rule.description output_paragraph rule.description
end end
rule_doc = colorize_code_blocks(rule.class.parsed_doc) rule_doc = colorize_code_fences(rule.class.parsed_doc)
return unless rule_doc return unless rule_doc
output_title "Detailed description" output_title "Detailed description"
output_paragraph rule_doc output_paragraph rule_doc
end end
private def colorize_code_blocks(string) private def colorize_code_fences(string)
string.try &.gsub(/```(.+?)```/m, &.colorize(:dark_gray)) return unless string
string
.gsub(/```(.+?)```/m, &.colorize(:dark_gray))
.gsub(/`(?!`)(.+?)`/, &.colorize(:dark_gray))
end end
private def output_title(title) private def output_title(title)