Module: Coradoc::Parser::Asciidoc::Block

Included in:
Base, Base
Defined in:
lib/coradoc/parser/asciidoc/block.rb

Instance Method Summary collapse

Instance Method Details

#blockObject



6
7
8
9
10
11
12
# File 'lib/coradoc/parser/asciidoc/block.rb', line 6

def block
  sidebar_block |
  example_block |
  source_block |
  quote_block |
  pass_block
end

#block_content(n_deep = 2) ⇒ Object



30
31
32
33
34
35
36
37
# File 'lib/coradoc/parser/asciidoc/block.rb', line 30

def block_content(n_deep = 2)
  c = block_image |
    list |
    text_line |
    empty_line.as(:line_break)
  c = c | block_content(n_deep - 1) if (n_deep > 0)
  c.repeat(1)
end

#block_idObject



58
59
60
61
# File 'lib/coradoc/parser/asciidoc/block.rb', line 58

def block_id
  (match('^\[') >> str("[") >> str('[').absent? >> keyword.as(:id) >> str("]]") |
    str("[#") >> keyword.as(:id) >> str("]")) >> newline
end

#block_style(delimiter = "*", repeater = 4, type = nil) ⇒ Object



63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
# File 'lib/coradoc/parser/asciidoc/block.rb', line 63

def block_style(delimiter = "*", repeater = 4, type = nil)
  block_id.maybe >>
  block_title.maybe >>
    newline.maybe >>
    (attribute_list >> newline ).maybe >>
    block_id.maybe >>
    (attribute_list >> newline ).maybe >>
    str(delimiter).repeat(repeater).as(:delimiter) >> newline >>
    if type == :pass
      (text_line | empty_line.as(:line_break)).repeat(1).as(:lines)
    else
      block_content.as(:lines)
    end >>
    str(delimiter).repeat(repeater) >> newline
end

#block_titleObject



47
48
49
# File 'lib/coradoc/parser/asciidoc/block.rb', line 47

def block_title
  match('^\\.') >> space.absent? >> text.as(:title) >> newline
end

#block_type(type) ⇒ Object



51
52
53
54
55
56
# File 'lib/coradoc/parser/asciidoc/block.rb', line 51

def block_type(type)
  (match('^\[') >> str("[").absent? >>
    str(type).as(:type) >>
    str("]")) | 
  (match('^\[') >> keyword.as(:type) >> str("]")) >> newline
end

#example_blockObject



43
44
45
# File 'lib/coradoc/parser/asciidoc/block.rb', line 43

def example_block
  block_style("=")
end

#pass_blockObject



18
19
20
# File 'lib/coradoc/parser/asciidoc/block.rb', line 18

def pass_block
  block_style("+", 4, :pass)
end

#quote_blockObject



26
27
28
# File 'lib/coradoc/parser/asciidoc/block.rb', line 26

def quote_block
  block_style("_")
end


39
40
41
# File 'lib/coradoc/parser/asciidoc/block.rb', line 39

def sidebar_block
  block_style("*")
end

#source_blockObject



14
15
16
# File 'lib/coradoc/parser/asciidoc/block.rb', line 14

def source_block
  block_style("-", 2)
end