Module: SimpleCov::Formatter::AIFormatter::MarkdownBuilder::InlineCode
- Extended by:
- T::Sig
- Defined in:
- lib/simplecov-ai/markdown_builder/inline_code.rb
Overview
Renders text as a CommonMark code span. The backtick fence is one longer than the
longest backtick run inside the text, and the content is space-padded when it starts
or ends with a backtick, so a backtick in a snippet, comment, path or method name
(def (cmd)`) can never close the span early and let the remainder render as Markdown.
Constant Summary collapse
- EMPTY_SPAN =
The span standing in for empty text: two bare backticks are not a code span in CommonMark and would render literally, while a span holding one space is.
T.let('` `', String)
Class Method Summary collapse
Class Method Details
.span(text) ⇒ Object
22 23 24 25 26 27 28 |
# File 'lib/simplecov-ai/markdown_builder/inline_code.rb', line 22 def self.span(text) return EMPTY_SPAN if text.empty? fence = '`' * ((text.scan(/`+/).map(&:length).max || 0) + 1) content = text.start_with?('`') || text.end_with?('`') ? " #{text} " : text "#{fence}#{content}#{fence}" end |