Class: ContentFS::Renderers::Markdown::ContentFSRenderer Private

Inherits:
CommonMarker::HtmlRenderer
  • Object
show all
Defined in:
lib/contentfs/renderers/markdown.rb

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Instance Method Summary collapse

Instance Method Details

#blockquote(node) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/contentfs/renderers/markdown.rb', line 20

def blockquote(node)
  blockquote_type = if (match = node.to_plaintext.strip.match(/\[(.*)\]/))
    match[1]
  end

  blockquote_class = if blockquote_type
    " class=\"#{blockquote_type}\""
  end

  block do
    container("<blockquote#{sourcepos(node)}#{blockquote_class}>\n", "</blockquote>") do
      node.each.with_index do |child, index|
        content = if blockquote_class && index == 0
          child.to_html.gsub("<p>[#{blockquote_type}] ", "<p>")
        else
          child
        end

        out(content)
      end
    end
  end
end