instance method node_to_markdown

Ruby on Rails edge

Since edge

Signature

node_to_markdown(node)

Converts a Nokogiri HTML node into a Markdown string.

node = Nokogiri::HTML4.fragment("<p>Hello <strong>world</strong></p>")
MarkdownConversion.node_to_markdown(node) # => "Hello **world**"

NOTE: text inside ‘<action-text-markdown>` elements is emitted without escaping, so this method is not safe for untrusted content. Convert user-supplied markup through ActionText::Content, which strips those elements while canonicalizing.

Parameters

node req
Source
# File actiontext/lib/action_text/markdown_conversion.rb, line 31
    def node_to_markdown(node)
      BottomUpReducer.new(node).reduce do |n, child_values|
        markdown_for_node(n, child_values)
      end.strip
    end

Defined in actiontext/lib/action_text/markdown_conversion.rb line 31 · 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