Sha256: 3dadd397c8577c59f110b6061452d02448f1d5311ffb3f09c4b8c357a5e7a1c7

Contents?: true

Size: 1.35 KB

Versions: 34

Compression:

Stored size: 1.35 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, :highlight,

        # 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 we don't return only a specific argument
      def link(link, title, content)
        "#{content} (#{link})"
      end

      def image(link, title, content)
        content &&= content + " "
        "#{content}#{link}"
      end

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

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

      def table(header, body)
        "#{header}#{body}"
      end

      def table_row(content)
        content + "\n"
      end

      def table_cell(content, alignment)
        content + "\t"
      end
    end
  end
end

Version data entries

34 entries across 30 versions & 8 rubygems

Version Path
mumukit-content-type-1.11.1 vendor/bundle/ruby/2.6.0/gems/redcarpet-3.3.4/lib/redcarpet/render_strip.rb
files.com-1.0.55 docs/vendor/bundle/ruby/2.5.0/gems/redcarpet-3.4.0/lib/redcarpet/render_strip.rb
tdiary-5.0.13 vendor/bundle/gems/redcarpet-3.4.0/lib/redcarpet/render_strip.rb
tdiary-5.0.12.1 vendor/bundle/gems/redcarpet-3.4.0/lib/redcarpet/render_strip.rb
tdiary-5.0.11 vendor/bundle/gems/redcarpet-3.4.0/lib/redcarpet/render_strip.rb
tdiary-5.0.9 vendor/bundle/gems/redcarpet-3.4.0/lib/redcarpet/render_strip.rb
tdiary-5.0.8 vendor/bundle/gems/redcarpet-3.4.0/lib/redcarpet/render_strip.rb
tdiary-5.0.8 vendor/bundle/ruby/2.5.0/gems/redcarpet-3.4.0/lib/redcarpet/render_strip.rb
tdiary-5.0.8 vendor/bundle/gems/tdiary-5.0.7/vendor/bundle/gems/redcarpet-3.4.0/lib/redcarpet/render_strip.rb
tdiary-5.0.7 vendor/bundle/gems/redcarpet-3.4.0/lib/redcarpet/render_strip.rb
tdiary-5.0.6 vendor/bundle/gems/redcarpet-3.4.0/lib/redcarpet/render_strip.rb
tdiary-5.0.5 vendor/bundle/gems/redcarpet-3.4.0/lib/redcarpet/render_strip.rb
tdiary-5.0.5 vendor/bundle/gems/tdiary-5.0.4/vendor/bundle/gems/redcarpet-3.4.0/lib/redcarpet/render_strip.rb
etude_for_ruby-0.1.4 vendor/bundle/ruby/2.2.0/gems/redcarpet-3.4.0/lib/redcarpet/render_strip.rb
etude_for_ruby-0.1.4 vendor/bundle/ruby/2.4.0/gems/redcarpet-3.4.0/lib/redcarpet/render_strip.rb
tdiary-5.0.4 vendor/bundle/gems/redcarpet-3.4.0/lib/redcarpet/render_strip.rb
mdg-1.0.1 vendor/bundle/ruby/2.3.0/gems/redcarpet-3.4.0/lib/redcarpet/render_strip.rb
redcarpet-3.4.0 lib/redcarpet/render_strip.rb
tdiary-5.0.2 vendor/bundle/gems/redcarpet-3.3.4/lib/redcarpet/render_strip.rb
tdiary-5.0.1 vendor/bundle/gems/redcarpet-3.3.4/lib/redcarpet/render_strip.rb