Sha256: 2b78c6734f12633138a3668da3434c32ac3c3cc7110afdf7b7f0f855646231d1
Contents?: true
Size: 1.06 KB
Versions: 3
Compression:
Stored size: 1.06 KB
Contents
# frozen_string_literal: true require 'reverse_markdown' module Html2rss module AttributePostProcessors ## # 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' class HtmlToMarkdown < Base def self.validate_args!(value, context) assert_type value, String, :value, context: end ## # @return [String] formatted in Markdown def get sanitized_value = SanitizeHtml.new(value, context).get ReverseMarkdown.convert(sanitized_value) end end end end
Version data entries
3 entries across 3 versions & 1 rubygems