Class: Html2rss::AttributePostProcessors::HtmlToMarkdown
- Inherits:
-
Object
- Object
- Html2rss::AttributePostProcessors::HtmlToMarkdown
- Defined in:
- lib/html2rss/attribute_post_processors/html_to_markdown.rb
Overview
Returns HTML code as Markdown formatted String. Before converting to markdown, the HTML is sanitized with SanitizeHtml. Imagine this HTML structure:
<section>
Lorem <b>ipsum</b> dolor...
<iframe src="https://evil.corp/miner"></iframe>
<script>alert();</script>
</section>
YAML usage example:
selectors:
description:
selector: section
extractor: html
post_process:
name: html_to_markdown
Would return:
'Lorem **ipsum** dolor'
Instance Method Summary collapse
-
#get ⇒ String
Formatted in Markdown.
-
#initialize(value, env) ⇒ HtmlToMarkdown
constructor
A new instance of HtmlToMarkdown.
Constructor Details
#initialize(value, env) ⇒ HtmlToMarkdown
Returns a new instance of HtmlToMarkdown
28 29 30 |
# File 'lib/html2rss/attribute_post_processors/html_to_markdown.rb', line 28 def initialize(value, env) @value = SanitizeHtml.new(value, env).get end |
Instance Method Details
#get ⇒ String
Returns formatted in Markdown
34 35 36 |
# File 'lib/html2rss/attribute_post_processors/html_to_markdown.rb', line 34 def get ReverseMarkdown.convert @value end |