Module: GitlabKramdown::Parser::FencedBlockquote

Included in:
Kramdown::Parser::GitlabKramdown
Defined in:
lib/gitlab_kramdown/parser/fenced_blockquote.rb

Overview

Multiline Blockquote

This parser implements multiline blockquotes fenced by ‘>>>`

Constant Summary collapse

FENCED_BLOCKQUOTE_START =
/>{3}/x
FENCED_BLOCKQUOTE_MATCH =
%r{
  ^(?<delimiter>>{3})   # line must start with >>>
  \s*                   # any amount of trailling whitespace
  \n                    # followed by a linebreak
  (?<content>[\S\s]+)   # at least one non whitespace chracter
  \n
  \k<delimiter>         # same delimiter used to open the block
  [ \t]*                # any amount of trailling whitespace
  \s
}xm

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(klass) ⇒ Object



24
25
26
27
28
# File 'lib/gitlab_kramdown/parser/fenced_blockquote.rb', line 24

def self.included(klass)
  return if klass.has_parser?(:fenced_blockquote)

  klass.define_parser(:fenced_blockquote, FENCED_BLOCKQUOTE_START)
end

Instance Method Details

#parse_fenced_blockquoteObject



30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/gitlab_kramdown/parser/fenced_blockquote.rb', line 30

def parse_fenced_blockquote
  if @src.check(FENCED_BLOCKQUOTE_MATCH)
    start_line_number = @src.current_line_number
    @src.pos += @src.matched_size

    el = new_block_el(:blockquote, nil, nil, location: start_line_number)

    content = parse_inner_fenced_content(@src[:content])
    el.children = content
    @tree.children << el
    true
  else
    false
  end
end