Sha256: 8414d562c320e21c08c9c39be77905911c1033507e9ae52d9763a67a1352f9d3

Contents?: true

Size: 1.02 KB

Versions: 2

Compression:

Stored size: 1.02 KB

Contents

module Redcarpet
  module Render
    # Markdown-stripping renderer. Turns Markdown into plaintext
    # Thanks to @toupeira (Markus Koller)
    class StripDown < Base
      # Methods where the first argument is the text content
      [
        # block-level calls
        :block_code, :block_quote,
        :block_html, :list, :list_item,

        # span-level calls
        :autolink, :codespan, :double_emphasis,
        :emphasis, :underline, :raw_html,
        :triple_emphasis, :strikethrough,
        :superscript,

        # footnotes
        :footnotes, :footnote_def, :footnote_ref,

        # low level rendering
        :entity, :normal_text
      ].each do |method|
        define_method method do |*args|
          args.first
        end
      end

      # Other methods where the text content is in another argument
      def link(link, title, content)
        content
      end

      def paragraph(text)
        text + "\n"
      end

      def header(text, header_level, anchor)
        text + "\n"
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
redcarpet-3.1.1 lib/redcarpet/render_strip.rb
redcarpet-3.1.0 lib/redcarpet/render_strip.rb