Class: Rabbit::Parser::RD::Ext::BlockVerbatim
Constant Summary
Constants included
from GetText
GetText::DOMAIN
Instance Method Summary
collapse
-
#default_ext_block_verbatim(label, source, content, visitor) ⇒ Object
-
#ext_block_verb_aafigure(label, source, content, visitor) ⇒ Object
-
#ext_block_verb_block_quote(label, source, content, visitor) ⇒ Object
-
#ext_block_verb_blockdiag(label, source, content, visitor) ⇒ Object
-
#ext_block_verb_charty(label, source, content, visitor) ⇒ Object
-
#ext_block_verb_coderay(label, source, content, visitor) ⇒ Object
-
#ext_block_verb_emacs(label, source, content, visitor) ⇒ Object
-
#ext_block_verb_enscript(label, source, content, visitor) ⇒ Object
-
#ext_block_verb_img(label, source, content, visitor) ⇒ Object
-
#ext_block_verb_LaTeX(label, source, content, visitor) ⇒ Object
-
#ext_block_verb_mermaid(label, source, content, visitor) ⇒ Object
-
#ext_block_verb_mimeTeX(label, source, content, visitor) ⇒ Object
-
#ext_block_verb_pango(label, source, content, visitor) ⇒ Object
-
#ext_block_verb_quote(label, source, content, visitor) ⇒ Object
-
#ext_block_verb_rouge(label, source, content, visitor) ⇒ Object
-
#ext_block_verb_rt(label, source, content, visitor) ⇒ Object
-
#ext_block_verb_video(label, source, content, visitor) ⇒ Object
-
#ext_block_verb_wait(label, source, content, visitor) ⇒ Object
Methods included from GetText
included
Methods included from Ext::Video
#make_video
Methods included from Image
#img, #make_image_from_file
Methods included from Ext::Image
make_image, make_image_from_file
Methods inherited from Base
add_extension, #apply, extensions, #extensions, inherited, method_added
Instance Method Details
#default_ext_block_verbatim(label, source, content, visitor) ⇒ Object
43
44
45
46
47
|
# File 'lib/rabbit/parser/rd/ext/block-verbatim.rb', line 43
def default_ext_block_verbatim(label, source, content, visitor)
content = visitor.apply_to_String(content.rstrip)
text = Text.new(content)
PreformattedBlock.new(PreformattedText.new(text))
end
|
98
99
100
101
102
103
|
# File 'lib/rabbit/parser/rd/ext/block-verbatim.rb', line 98
def ext_block_verb_aafigure(label, source, content, visitor)
return nil unless /\Aaafigure\z/i =~ label
make_image_from_file(source, visitor) do |src_file, prop|
Parser::Ext::AAFigure.make_image(src_file.path, prop, visitor)
end
end
|
#ext_block_verb_block_quote(label, source, content, visitor) ⇒ Object
144
145
146
147
148
149
150
151
152
|
# File 'lib/rabbit/parser/rd/ext/block-verbatim.rb', line 144
def ext_block_verb_block_quote(label, source, content, visitor)
return nil unless /\Ablock[_-]?quote\z/i =~ label
src, prop = parse_source(source)
tree = ::RD::RDTree.new("=begin\n#{src}\n=end\n")
elems = tree.root.children.collect do |child|
child.accept(visitor)
end
BlockQuote.new(elems, prop)
end
|
#ext_block_verb_blockdiag(label, source, content, visitor) ⇒ Object
105
106
107
108
109
110
|
# File 'lib/rabbit/parser/rd/ext/block-verbatim.rb', line 105
def ext_block_verb_blockdiag(label, source, content, visitor)
return nil unless /\Ablockdiag\z/i =~ label
make_image_from_file(source, visitor) do |src_file, prop|
Parser::Ext::BlockDiag.make_image(src_file.path, prop, visitor)
end
end
|
#ext_block_verb_charty(label, source, content, visitor) ⇒ Object
187
188
189
190
191
192
|
# File 'lib/rabbit/parser/rd/ext/block-verbatim.rb', line 187
def ext_block_verb_charty(label, source, content, visitor)
return nil unless /\Acharty\z/i =~ label
make_image_from_file(source, visitor) do |src_file, prop|
Parser::Ext::Charty.make_image(src_file.path, prop, visitor)
end
end
|
#ext_block_verb_coderay(label, source, content, visitor) ⇒ Object
112
113
114
115
116
117
118
119
120
121
|
# File 'lib/rabbit/parser/rd/ext/block-verbatim.rb', line 112
def ext_block_verb_coderay(label, source, content, visitor)
return nil unless /\Acoderay (\w+)\z/i =~ label
lang = $1.downcase
src, prop = parse_source(source)
logger = visitor.logger
result = Parser::Ext::CodeRay.highlight(lang, src, logger)
result || default_ext_block_verbatim(label, src, src, visitor)
end
|
#ext_block_verb_emacs(label, source, content, visitor) ⇒ Object
123
124
125
126
127
128
129
130
131
132
|
# File 'lib/rabbit/parser/rd/ext/block-verbatim.rb', line 123
def ext_block_verb_emacs(label, source, content, visitor)
return nil unless /\Aemacs(?:\s+(.+))?\z/i =~ label
mode_line = $1
src, prop = parse_source(source)
logger = visitor.logger
result = Parser::Ext::Emacs.highlight(src, logger, mode_line)
result || default_ext_block_verbatim(label, src, src, visitor)
end
|
#ext_block_verb_enscript(label, source, content, visitor) ⇒ Object
69
70
71
72
73
74
75
76
77
78
79
80
81
|
# File 'lib/rabbit/parser/rd/ext/block-verbatim.rb', line 69
def ext_block_verb_enscript(label, source, content, visitor)
return nil unless /\Aenscript (\w+)\z/i =~ label
lang = $1.downcase
src, prop = parse_source(source)
logger = visitor.logger
result = nil
if Parser::Ext::Enscript.check_availability(lang, logger)
result = Parser::Ext::Enscript.highlight(lang, src, logger)
end
result || default_ext_block_verbatim(label, src, src, visitor)
end
|
#ext_block_verb_img(label, source, content, visitor) ⇒ Object
54
55
56
57
58
59
|
# File 'lib/rabbit/parser/rd/ext/block-verbatim.rb', line 54
def ext_block_verb_img(label, source, content, visitor)
return nil unless /\A(?:image|img)\z/i =~ label
src, prop = parse_source(source)
return nil if prop["src"].nil?
make_image(visitor, prop["src"], prop, body: visitor.current_body)
end
|
#ext_block_verb_LaTeX(label, source, content, visitor) ⇒ Object
83
84
85
86
87
88
|
# File 'lib/rabbit/parser/rd/ext/block-verbatim.rb', line 83
def ext_block_verb_LaTeX(label, source, content, visitor)
return nil unless /\ALaTeX\z/i =~ label
make_image_from_file(source, visitor) do |src_file, prop|
Parser::Ext::TeX.make_image_by_LaTeX(src_file.path, prop, visitor)
end
end
|
#ext_block_verb_mermaid(label, source, content, visitor) ⇒ Object
194
195
196
197
198
199
200
201
|
# File 'lib/rabbit/parser/rd/ext/block-verbatim.rb', line 194
def ext_block_verb_mermaid(label, source, content, visitor)
return nil unless /\Amermaid\z/i =~ label
make_image_from_file(source,
visitor,
extension: ".mmd") do |src_file, prop|
src_file
end
end
|
#ext_block_verb_mimeTeX(label, source, content, visitor) ⇒ Object
90
91
92
93
94
95
96
|
# File 'lib/rabbit/parser/rd/ext/block-verbatim.rb', line 90
def ext_block_verb_mimeTeX(label, source, content, visitor)
return nil unless /\AmimeTeX\z/i =~ label
make_image_from_file(source, visitor) do |src_file, prop|
Parser::Ext::TeX.make_image_by_mimeTeX(src_file.path, prop,
visitor)
end
end
|
#ext_block_verb_pango(label, source, content, visitor) ⇒ Object
169
170
171
172
173
174
|
# File 'lib/rabbit/parser/rd/ext/block-verbatim.rb', line 169
def ext_block_verb_pango(label, source, content, visitor)
return nil unless /\Apango\z/i =~ label
src, prop = parse_source(source)
text = Text.new(src)
PreformattedBlock.new(PreformattedText.new(text))
end
|
#ext_block_verb_quote(label, source, content, visitor) ⇒ Object
49
50
51
52
|
# File 'lib/rabbit/parser/rd/ext/block-verbatim.rb', line 49
def ext_block_verb_quote(label, source, content, visitor)
return nil unless /\A_\z/i =~ label
default_ext_block_verbatim("", source, source, visitor)
end
|
#ext_block_verb_rouge(label, source, content, visitor) ⇒ Object
176
177
178
179
180
181
182
183
184
185
|
# File 'lib/rabbit/parser/rd/ext/block-verbatim.rb', line 176
def ext_block_verb_rouge(label, source, content, visitor)
return nil unless /\Arouge (\w+)\z/i =~ label
lang = $1.downcase
src, prop = parse_source(source)
logger = visitor.logger
result = Parser::Ext::Rouge.highlight(lang, src, logger)
result || default_ext_block_verbatim(label, src, src, visitor)
end
|
#ext_block_verb_rt(label, source, content, visitor) ⇒ Object
134
135
136
137
138
139
140
141
142
|
# File 'lib/rabbit/parser/rd/ext/block-verbatim.rb', line 134
def ext_block_verb_rt(label, source, content, visitor)
return nil unless /\Art\z/i =~ label
unless defined?(RT2RabbitVisitor)
visitor.logger.warn(_("RTtool isn't available"))
return nil
end
rt_visitor = RT2RabbitVisitor.new(visitor)
rt_visitor.visit(RT::RTParser.parse(content))
end
|
#ext_block_verb_video(label, source, content, visitor) ⇒ Object
61
62
63
64
65
66
67
|
# File 'lib/rabbit/parser/rd/ext/block-verbatim.rb', line 61
def ext_block_verb_video(label, source, content, visitor)
return nil unless /\Avideo\z/i =~ label
src, prop = parse_source(source)
return nil if prop["src"].nil?
make_video(visitor, prop["src"], prop)
end
|
#ext_block_verb_wait(label, source, content, visitor) ⇒ Object
154
155
156
157
158
159
160
161
162
163
164
165
166
167
|
# File 'lib/rabbit/parser/rd/ext/block-verbatim.rb', line 154
def ext_block_verb_wait(label, source, content, visitor)
return nil unless /\Await\z/i =~ label
src, prop = parse_source(source)
tree = ::RD::RDTree.new("=begin\n#{src}\n=end\n")
wait_block = WaitBlock.new
visitor.register_pause(wait_block)
tree.root.children.each do |child|
wait_block << child.accept(visitor)
end
wait_block
end
|