Sha256: df9f069aa2cf18f19d49950624c121335bd6fc9d045b2deb6f572dde1fcd3509

Contents?: true

Size: 1010 Bytes

Versions: 3

Compression:

Stored size: 1010 Bytes

Contents

require 'kramdown'

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
      def initialize(value, env)
        @value = value
        @env = env
      end

      ##
      # @return [String] formatted in Markdown
      def get
        SanitizeHtml.new(Kramdown::Document.new(@value).to_html, @env).get
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
html2rss-0.9.0 lib/html2rss/attribute_post_processors/markdown_to_html.rb
html2rss-0.8.2 lib/html2rss/attribute_post_processors/markdown_to_html.rb
html2rss-0.8.1 lib/html2rss/attribute_post_processors/markdown_to_html.rb