Module: Coradoc::Parser::Asciidoc::Content
- Includes:
- Base
- Included in:
- Section
- Defined in:
- lib/coradoc/parser/asciidoc/content.rb
Instance Method Summary
collapse
Methods included from Base
#attribute_name, #attribute_value, #digits, #email, #empty_line, #endline, #keyword, #line_ending, #newline, #space, #space?, #special_character, #text, #words
Instance Method Details
#asciidoc_char ⇒ Object
99
100
101
|
# File 'lib/coradoc/parser/asciidoc/content.rb', line 99
def asciidoc_char
match("^[*_:=-]")
end
|
#asciidoc_char_with_id ⇒ Object
103
104
105
|
# File 'lib/coradoc/parser/asciidoc/content.rb', line 103
def asciidoc_char_with_id
asciidoc_char | str("[#") | str("[[")
end
|
#block_title ⇒ Object
89
90
91
|
# File 'lib/coradoc/parser/asciidoc/content.rb', line 89
def block_title
str(".") >> text.as(:title) >> line_ending
end
|
#cell_content ⇒ Object
76
77
78
|
# File 'lib/coradoc/parser/asciidoc/content.rb', line 76
def cell_content
str("|").absent? >> literal_space? >> words.as(:text)
end
|
#contents ⇒ Object
21
22
23
24
25
26
27
28
29
30
|
# File 'lib/coradoc/parser/asciidoc/content.rb', line 21
def contents
(
example_block.as(:example) |
list.as(:list) |
table.as(:table) |
highlight.as(:highlight) |
glossaries.as(:glossaries) |
paragraph.as(:paragraph) | empty_line
).repeat(1)
end
|
#definition_list ⇒ Object
125
126
127
|
# File 'lib/coradoc/parser/asciidoc/content.rb', line 125
def definition_list
dlist_item.repeat(1)
end
|
#dlist_item ⇒ Object
137
138
139
|
# File 'lib/coradoc/parser/asciidoc/content.rb', line 137
def dlist_item
str("term") >> space >> digits >> str("::") >> space >> text_line
end
|
#empty_cell_content ⇒ Object
72
73
74
|
# File 'lib/coradoc/parser/asciidoc/content.rb', line 72
def empty_cell_content
str("|").absent? >> literal_space.as(:text)
end
|
#example_block ⇒ Object
32
33
34
35
36
37
38
39
|
# File 'lib/coradoc/parser/asciidoc/content.rb', line 32
def example_block
str("[example]") >> newline >>
str("=").repeat(4).capture(:delimiter) >> newline >>
dynamic do |source, context|
(str(context.captures[:delimiter]).absent? >> text.as(:text) >> endline).repeat(1) >>
str(context.captures[:delimiter]) >> endline
end
end
|
#glossaries ⇒ Object
11
12
13
|
# File 'lib/coradoc/parser/asciidoc/content.rb', line 11
def glossaries
glossary.repeat(1)
end
|
#glossary ⇒ Object
112
113
114
115
|
# File 'lib/coradoc/parser/asciidoc/content.rb', line 112
def glossary
keyword.as(:key) >> str("::") >> space? >>
text.as(:value) >> line_ending.as(:break)
end
|
#highlight ⇒ Object
41
42
43
44
|
# File 'lib/coradoc/parser/asciidoc/content.rb', line 41
def highlight
text_id >> newline >>
underline >> highlight_text >> newline
end
|
#highlight_text ⇒ Object
50
51
52
|
# File 'lib/coradoc/parser/asciidoc/content.rb', line 50
def highlight_text
str("#") >> words.as(:text) >> str("#")
end
|
#list ⇒ Object
16
17
18
19
|
# File 'lib/coradoc/parser/asciidoc/content.rb', line 16
def list
unnumbered_list.as(:unnumbered) |
definition_list.as(:definition) | numbered_list.as(:numbered)
end
|
#literal_space ⇒ Object
80
81
82
|
# File 'lib/coradoc/parser/asciidoc/content.rb', line 80
def literal_space
(match[' '] | match[' \t']).repeat(1)
end
|
#literal_space? ⇒ Boolean
85
86
87
|
# File 'lib/coradoc/parser/asciidoc/content.rb', line 85
def literal_space?
literal_space.maybe
end
|
#nlist_item ⇒ Object
129
130
131
|
# File 'lib/coradoc/parser/asciidoc/content.rb', line 129
def nlist_item
match("\.") >> space >> text_line
end
|
#numbered_list ⇒ Object
117
118
119
|
# File 'lib/coradoc/parser/asciidoc/content.rb', line 117
def numbered_list
nlist_item.repeat(1)
end
|
#paragraph ⇒ Object
7
8
9
|
# File 'lib/coradoc/parser/asciidoc/content.rb', line 7
def paragraph
text_line.repeat(1)
end
|
#table ⇒ Object
55
56
57
58
59
60
|
# File 'lib/coradoc/parser/asciidoc/content.rb', line 55
def table
block_title >>
str("|===") >> line_ending >>
table_row.repeat(1).as(:rows) >>
str("|===") >> line_ending
end
|
#table_row ⇒ Object
62
63
64
65
|
# File 'lib/coradoc/parser/asciidoc/content.rb', line 62
def table_row
(literal_space? >> str("|") >> (cell_content | empty_cell_content)).
repeat(1).as(:cols) >> line_ending
end
|
#text_id ⇒ Object
107
108
109
110
|
# File 'lib/coradoc/parser/asciidoc/content.rb', line 107
def text_id
str("[[") >> keyword.as(:id) >> str("]]") |
str("[#") >> keyword.as(:id) >> str("]")
end
|
#text_line ⇒ Object
94
95
96
97
|
# File 'lib/coradoc/parser/asciidoc/content.rb', line 94
def text_line
(asciidoc_char_with_id.absent? | text_id) >> literal_space? >>
text.as(:text) >> line_ending.as(:break)
end
|
#ulist_item ⇒ Object
133
134
135
|
# File 'lib/coradoc/parser/asciidoc/content.rb', line 133
def ulist_item
match("\\*") >> space >> text_line
end
|
#underline ⇒ Object
46
47
48
|
# File 'lib/coradoc/parser/asciidoc/content.rb', line 46
def underline
str("[underline]") | str("[.underline]")
end
|
#unnumbered_list ⇒ Object
121
122
123
|
# File 'lib/coradoc/parser/asciidoc/content.rb', line 121
def unnumbered_list
(ulist_item >> newline.maybe).repeat(1)
end
|
#word ⇒ Object
68
69
70
|
# File 'lib/coradoc/parser/asciidoc/content.rb', line 68
def word
(match("[a-zA-Z0-9_-]") | str(".") | str("*") | match("@")).repeat(1)
end
|