instance method
to_markdown
Ruby on Rails edge
Since edgeSignature
to_markdown(attachment_links: false)
Returns a Markdown version of the markup contained by the body attribute.
message = Message.create!(content: "<h1>Funny times!</h1>")
message.content.to_markdown # => "# Funny times!"
message = Message.create!(content: "<p>Hello <strong>world</strong></p>")
message.content.to_markdown # => "Hello **world**"
When +attachment_links+ is true, ActiveStorage blob attachments generate Markdown links with URLs. This requires a rendering context (e.g., controller or mailer action) and will raise if URL generation fails.
NOTE: that the returned string is not HTML safe and should not be rendered in browsers without additional sanitization.
Parameters
-
attachment_linkskey = false
Source
# File actiontext/app/models/action_text/rich_text.rb, line 93
def to_markdown(attachment_links: false)
body&.to_markdown(attachment_links: attachment_links).to_s
end
Defined in actiontext/app/models/action_text/rich_text.rb line 93
· View on GitHub
· Improve this page
· Find usages on GitHub
Defined in ActionText::RichText