Sha256: a981a932390181538cdab8b7d1a9eb3817a7d5d6a96e2ee74e4cd8f605d444cc

Contents?: true

Size: 1.02 KB

Versions: 1

Compression:

Stored size: 1.02 KB

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

1 entries across 1 versions & 1 rubygems

Version Path
html2rss-0.8.0 lib/html2rss/attribute_post_processors/markdown_to_html.rb