Sha256: dfa3c011b2e5097a788ab46e2eefaa8122c31badb6815617accd89e230463143
Contents?: true
Size: 1.3 KB
Versions: 2
Compression:
Stored size: 1.3 KB
Contents
# frozen_string_literal: true require 'kramdown' require_relative 'sanitize_html' module Html2rss module AttributePostProcessors ## # 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> class MarkdownToHtml ## # @param value [String] Markdown content to convert to HTML # @param env [Item::Context] Context object providing additional environment details def initialize(value, env) @value = value @env = env end ## # Converts Markdown to sanitized HTML. # # @return [String] Sanitized HTML content def get html_content = Kramdown::Document.new(@value).to_html SanitizeHtml.new(html_content, @env).get end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
html2rss-0.11.0 | lib/html2rss/attribute_post_processors/markdown_to_html.rb |
html2rss-0.10.0 | lib/html2rss/attribute_post_processors/markdown_to_html.rb |