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, #date, #digit, #digits, #email, #empty_line, #endline, #keyword, #line_ending, #newline, #rich_text, #rich_texts, #space, #space?, #special_character, #text, #word, #words
Instance Method Details
#asciidoc_char ⇒ Object
119
120
121
|
# File 'lib/coradoc/parser/asciidoc/content.rb', line 119
def asciidoc_char
match("^[*_:=-]")
end
|
#asciidoc_char_with_id ⇒ Object
123
124
125
|
# File 'lib/coradoc/parser/asciidoc/content.rb', line 123
def asciidoc_char_with_id
asciidoc_char | str("[#") | str("[[")
end
|
#block ⇒ Object
33
34
35
|
# File 'lib/coradoc/parser/asciidoc/content.rb', line 33
def block
| example_block | source_block | quote_block
end
|
#block_style(delimiter = "*", repeater = 4) ⇒ Object
53
54
55
56
57
58
59
60
|
# File 'lib/coradoc/parser/asciidoc/content.rb', line 53
def block_style(delimiter="*", repeater = 4)
block_title.maybe >>
newline.maybe >>
block_type.maybe >>
str(delimiter).repeat(repeater).as(:delimiter) >> newline >>
text_line.repeat(1).as(:lines) >>
str(delimiter).repeat(repeater) >> newline
end
|
#block_title ⇒ Object
109
110
111
|
# File 'lib/coradoc/parser/asciidoc/content.rb', line 109
def block_title
str(".") >> text.as(:title) >> line_ending
end
|
#block_type ⇒ Object
62
63
64
|
# File 'lib/coradoc/parser/asciidoc/content.rb', line 62
def block_type
str("[") >> keyword.as(:type) >> str("]") >> newline
end
|
#cell_content ⇒ Object
96
97
98
|
# File 'lib/coradoc/parser/asciidoc/content.rb', line 96
def cell_content
str("|").absent? >> literal_space? >> rich_texts.as(:text)
end
|
#contents ⇒ Object
22
23
24
25
26
27
28
29
30
31
|
# File 'lib/coradoc/parser/asciidoc/content.rb', line 22
def contents
(
block.as(:block) |
list.as(:list) |
table.as(:table) |
highlight.as(:highlight) |
glossaries.as(:glossaries) |
paragraph.as(:paragraph) | empty_line
).repeat(1)
end
|
#definition_list ⇒ Object
151
152
153
|
# File 'lib/coradoc/parser/asciidoc/content.rb', line 151
def definition_list
dlist_item.repeat(1)
end
|
#dlist_item ⇒ Object
163
164
165
|
# File 'lib/coradoc/parser/asciidoc/content.rb', line 163
def dlist_item
str("term") >> space >> digits >> str("::") >> space >> text_line
end
|
#empty_cell_content ⇒ Object
92
93
94
|
# File 'lib/coradoc/parser/asciidoc/content.rb', line 92
def empty_cell_content
str("|").absent? >> literal_space.as(:text)
end
|
#example_block ⇒ Object
49
50
51
|
# File 'lib/coradoc/parser/asciidoc/content.rb', line 49
def example_block
block_style("=")
end
|
#glossaries ⇒ Object
12
13
14
|
# File 'lib/coradoc/parser/asciidoc/content.rb', line 12
def glossaries
glossary.repeat(1)
end
|
#glossary ⇒ Object
138
139
140
141
|
# File 'lib/coradoc/parser/asciidoc/content.rb', line 138
def glossary
keyword.as(:key) >> str("::") >> space? >>
text.as(:value) >> line_ending.as(:break)
end
|
#highlight ⇒ Object
66
67
68
69
|
# File 'lib/coradoc/parser/asciidoc/content.rb', line 66
def highlight
text_id >> newline >>
underline >> highlight_text >> newline
end
|
#highlight_text ⇒ Object
75
76
77
|
# File 'lib/coradoc/parser/asciidoc/content.rb', line 75
def highlight_text
str("#") >> words.as(:text) >> str("#")
end
|
#list ⇒ Object
17
18
19
20
|
# File 'lib/coradoc/parser/asciidoc/content.rb', line 17
def list
unordered_list.as(:unordered) |
definition_list.as(:definition) | ordered_list.as(:ordered)
end
|
#literal_space ⇒ Object
100
101
102
|
# File 'lib/coradoc/parser/asciidoc/content.rb', line 100
def literal_space
(match[' '] | match[' \t']).repeat(1)
end
|
#literal_space? ⇒ Boolean
105
106
107
|
# File 'lib/coradoc/parser/asciidoc/content.rb', line 105
def literal_space?
literal_space.maybe
end
|
#olist_item ⇒ Object
155
156
157
|
# File 'lib/coradoc/parser/asciidoc/content.rb', line 155
def olist_item
match("\.") >> space >> text_line
end
|
#ordered_list ⇒ Object
143
144
145
|
# File 'lib/coradoc/parser/asciidoc/content.rb', line 143
def ordered_list
olist_item.repeat(1)
end
|
#paragraph ⇒ Object
7
8
9
10
|
# File 'lib/coradoc/parser/asciidoc/content.rb', line 7
def paragraph
paragraph_meta.as(:meta).maybe >>
text_line.repeat(1).as(:lines)
end
|
132
133
134
135
136
|
# File 'lib/coradoc/parser/asciidoc/content.rb', line 132
def paragraph_meta
str("[") >>
keyword.as(:key) >> str("=") >>
word.as(:value) >> str("]") >> newline
end
|
#quote_block ⇒ Object
41
42
43
|
# File 'lib/coradoc/parser/asciidoc/content.rb', line 41
def quote_block
block_style("_")
end
|
45
46
47
|
# File 'lib/coradoc/parser/asciidoc/content.rb', line 45
def
block_style("*")
end
|
#source_block ⇒ Object
37
38
39
|
# File 'lib/coradoc/parser/asciidoc/content.rb', line 37
def source_block
block_style("-", 2)
end
|
#table ⇒ Object
80
81
82
83
84
85
|
# File 'lib/coradoc/parser/asciidoc/content.rb', line 80
def table
block_title >>
str("|===") >> line_ending >>
table_row.repeat(1).as(:rows) >>
str("|===") >> line_ending
end
|
#table_row ⇒ Object
87
88
89
90
|
# File 'lib/coradoc/parser/asciidoc/content.rb', line 87
def table_row
(literal_space? >> str("|") >> (cell_content | empty_cell_content)).
repeat(1).as(:cols) >> line_ending
end
|
#text_id ⇒ Object
127
128
129
130
|
# File 'lib/coradoc/parser/asciidoc/content.rb', line 127
def text_id
str("[[") >> keyword.as(:id) >> str("]]") |
str("[#") >> keyword.as(:id) >> str("]")
end
|
#text_line ⇒ Object
114
115
116
117
|
# File 'lib/coradoc/parser/asciidoc/content.rb', line 114
def text_line
(asciidoc_char_with_id.absent? | text_id) >> literal_space? >>
text.as(:text) >> line_ending.as(:break)
end
|
#ulist_item ⇒ Object
159
160
161
|
# File 'lib/coradoc/parser/asciidoc/content.rb', line 159
def ulist_item
match("\\*") >> space >> text_line
end
|
#underline ⇒ Object
71
72
73
|
# File 'lib/coradoc/parser/asciidoc/content.rb', line 71
def underline
str("[underline]") | str("[.underline]")
end
|
#unordered_list ⇒ Object
147
148
149
|
# File 'lib/coradoc/parser/asciidoc/content.rb', line 147
def unordered_list
(ulist_item >> newline.maybe).repeat(1)
end
|