Class: Html2rss::Selectors::PostProcessors::MarkdownToHtml
- Defined in:
- lib/html2rss/selectors/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::Selectors::PostProcessors::Base
Class Method Details
.validate_args!(value, context) ⇒ void
This method returns an undefined value.
40 41 42 |
# File 'lib/html2rss/selectors/post_processors/markdown_to_html.rb', line 40 def self.validate_args!(value, context) assert_type value, String, :value, context: end |
Instance Method Details
#get ⇒ String
Converts Markdown to sanitized HTML.
48 49 50 51 |
# File 'lib/html2rss/selectors/post_processors/markdown_to_html.rb', line 48 def get html_content = Kramdown::Document.new(value).to_html SanitizeHtml.new(html_content, context).get end |