Class: Html2rss::AttributePostProcessors::MarkdownToHtml
- Defined in:
- lib/html2rss/attribute_post_processors/markdown_to_html.rb
Overview
Generates HTML from Markdown.
It’s particularly useful in conjunction with the Template post processor to generate a description from other selectors.
YAML usage example:
selectors:
description:
selector: section
post_process:
- name: template
string: |
# %s
Price: %s
methods:
- self
- price
- name: markdown_to_html
Would e.g. return:
<h1>Section</h1>
<p>Price: 12.34</p>
Instance Attribute Summary
Attributes inherited from Base
Class Method Summary collapse
Instance Method Summary collapse
-
#get ⇒ String
Converts Markdown to sanitized HTML.
Methods inherited from Base
assert_type, expect_options, #initialize
Constructor Details
This class inherits a constructor from Html2rss::AttributePostProcessors::Base
Class Method Details
.validate_args!(value, context) ⇒ Object
36 37 38 |
# File 'lib/html2rss/attribute_post_processors/markdown_to_html.rb', line 36 def self.validate_args!(value, context) assert_type value, String, :value, context: end |
Instance Method Details
#get ⇒ String
Converts Markdown to sanitized HTML.
44 45 46 47 |
# File 'lib/html2rss/attribute_post_processors/markdown_to_html.rb', line 44 def get html_content = Kramdown::Document.new(value).to_html SanitizeHtml.new(html_content, context).get end |