instance method inline_code

Ruby on Rails edge

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

Signature

inline_code(content)

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.

Parameters

content req
Source
# File actiontext/lib/action_text/markdown_conversion.rb, line 404
      def inline_code(content)
        content = flatten_to_inline(content)
        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 404 · 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