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:
Section
Price: 12.34
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) ⇒ Object
37 38 39 |
# File 'lib/html2rss/selectors/post_processors/markdown_to_html.rb', line 37 def self.validate_args!(value, context) assert_type value, String, :value, context: end |
Instance Method Details
#get ⇒ String
Converts Markdown to sanitized HTML.
45 46 47 48 |
# File 'lib/html2rss/selectors/post_processors/markdown_to_html.rb', line 45 def get html_content = Kramdown::Document.new(value).to_html SanitizeHtml.new(html_content, context).get end |