instance method inline_code

Ruby on Rails edge

Since edge Private — implementation detail, not part of the public API

Signature

inline_code(content, node)

Two things break a code span’s delimiter. A blank line closes the paragraph before the closing backtick string arrives – Markdown turns the line endings inside a code span into spaces anyway, so collapse them and the span always closes. And a lone backtick followed by whitespace does not open a span in every renderer (kramdown refuses it), so widen the delimiter when the content leads with whitespace.

In a table row, kramdown rebuilds a span that leads with whitespace with a single backtick, so strip the whitespace. GFM ends a table cell at any unescaped pipe, even one inside a code span, so escape pipes there.

Parameters

content req
node req
Source
# File actiontext/lib/action_text/markdown_conversion.rb, line 423
      def inline_code(content, node)
        content = flatten_to_inline(content)
        if node.ancestors.any? { |ancestor| ancestor.name == "tr" }
          content = content.strip.gsub("|", "\\|")
        end
        max_run = content.scan(/`+/).map(&:length).max || 0
        fence = "`" * [content.match?(/\A\s/) ? 2 : 1, max_run + 1].max
        if content.start_with?("`") || content.end_with?("`")
          "#{fence} #{content} #{fence}"
        else
          "#{fence}#{content}#{fence}"
        end
      end

Defined in actiontext/lib/action_text/markdown_conversion.rb line 423 · View on GitHub · Improve this page · Find usages on GitHub

Defined in ActionText::MarkdownConversion

Type at least 2 characters to search.

Use the arrow keys to navigate results, Enter to open one, Escape to close.

Keyboard shortcuts

/
Focus search
⌘K / Ctrl-K
Command palette
?
This help
Esc
Close