erbook 9.2.0 → 9.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/doc/api/classes/ERBook/Document.html +19 -210
- data/doc/api/classes/ERBook/Document/Node.html +42 -42
- data/doc/api/classes/ERBook/Template.html +5 -5
- data/doc/api/classes/ERBook/Template/Sandbox.html +5 -5
- data/doc/api/classes/RDoc/AnyMethod.html +20 -20
- data/doc/api/classes/RDoc/TopLevel.html +30 -30
- data/doc/api/classes/String.html +5 -5
- data/doc/api/created.rid +1 -1
- data/doc/api/files/lib/erbook/document_rb.html +3 -1
- data/doc/api/files/lib/erbook/to_xhtml_rb.html +1 -1
- data/doc/api/files/lib/erbook_rb.html +1 -3
- data/doc/api/panel/search_index.js +1 -1
- data/doc/history.erb +23 -0
- data/doc/index.html +450 -381
- data/fmt/xhtml.yaml +11 -5
- data/fmt/xhtml/icons/index.yaml +4 -0
- data/fmt/xhtml/icons/w3.org/README +2 -0
- data/fmt/xhtml/icons/w3.org/valid-xhtml10.png +0 -0
- data/fmt/xhtml/icons/w3.org/vcss.gif +0 -0
- data/lib/erbook.rb +2 -2
- data/lib/erbook/document.rb +216 -197
- metadata +8 -5
@@ -49,7 +49,7 @@
|
|
49
49
|
<dd>
|
50
50
|
<ul>
|
51
51
|
|
52
|
-
<li><a href="#
|
52
|
+
<li><a href="#M000051">new</a></li>
|
53
53
|
|
54
54
|
</ul>
|
55
55
|
</dd>
|
@@ -58,7 +58,7 @@
|
|
58
58
|
<dd>
|
59
59
|
<ul>
|
60
60
|
|
61
|
-
<li><a href="#
|
61
|
+
<li><a href="#M000052">to_s</a></li>
|
62
62
|
|
63
63
|
</ul>
|
64
64
|
</dd>
|
@@ -132,9 +132,9 @@ All nodes in the document arranged by node type.
|
|
132
132
|
<div class="sectiontitle">Class Public methods</div>
|
133
133
|
|
134
134
|
<div class="method">
|
135
|
-
<div class="title" id="
|
135
|
+
<div class="title" id="M000051">
|
136
136
|
|
137
|
-
<a name="
|
137
|
+
<a name="M000051"></a><b>new</b>(format_name, input_text, input_file, options = {})
|
138
138
|
|
139
139
|
</div>
|
140
140
|
|
@@ -166,212 +166,21 @@ specification file.
|
|
166
166
|
|
167
167
|
<div class="sourcecode">
|
168
168
|
<p class="source-link">
|
169
|
-
Source: <a href="javascript:toggleSource('
|
169
|
+
Source: <a href="javascript:toggleSource('M000051_source')" id="l_M000051_source">show</a>
|
170
170
|
|
171
|
-
| <a href="http://github.com/sunaku/erbook/blob/
|
171
|
+
| <a href="http://github.com/sunaku/erbook/blob/8c15499d81a4c71c3a15850bff81dc6e5d0236c5/lib/erbook/document.rb#L42" target="_blank" class="github_url">on GitHub</a>
|
172
172
|
|
173
173
|
</p>
|
174
|
-
<div id="
|
174
|
+
<div id="M000051_source" class="dyn-source">
|
175
175
|
<pre><span class="ruby-comment cmt"># File lib/erbook/document.rb, line 42</span>
|
176
176
|
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">initialize</span> <span class="ruby-identifier">format_name</span>, <span class="ruby-identifier">input_text</span>, <span class="ruby-identifier">input_file</span>, <span class="ruby-identifier">options</span> = {}
|
177
|
-
<span class="ruby-
|
178
|
-
<span class="ruby-ivar">@format_file</span> = <span class="ruby-identifier">format_name</span>.<span class="ruby-identifier">to_s</span>
|
177
|
+
<span class="ruby-identifier">load_format</span> <span class="ruby-identifier">format_name</span>
|
179
178
|
|
180
|
-
|
181
|
-
|
179
|
+
<span class="ruby-ivar">@input_text</span> = <span class="ruby-identifier">input_text</span>
|
180
|
+
<span class="ruby-ivar">@input_file</span> = <span class="ruby-identifier">input_file</span>
|
181
|
+
<span class="ruby-ivar">@options</span> = <span class="ruby-identifier">options</span>
|
182
182
|
|
183
|
-
|
184
|
-
<span class="ruby-ivar">@format</span> = <span class="ruby-constant">YAML</span>.<span class="ruby-identifier">load_file</span>(<span class="ruby-ivar">@format_file</span>)
|
185
|
-
<span class="ruby-ivar">@format</span>[<span class="ruby-identifier">:file</span>] = <span class="ruby-constant">File</span>.<span class="ruby-identifier">expand_path</span>(<span class="ruby-ivar">@format_file</span>)
|
186
|
-
<span class="ruby-ivar">@format</span>[<span class="ruby-identifier">:name</span>] = <span class="ruby-constant">File</span>.<span class="ruby-identifier">basename</span>(<span class="ruby-ivar">@format_file</span>).<span class="ruby-identifier">sub</span>(<span class="ruby-regexp re">/\..*?$/</span>, <span class="ruby-value str">''</span>)
|
187
|
-
|
188
|
-
<span class="ruby-keyword kw">if</span> <span class="ruby-ivar">@format</span>.<span class="ruby-identifier">key?</span> <span class="ruby-value str">'code'</span>
|
189
|
-
<span class="ruby-identifier">eval</span> <span class="ruby-ivar">@format</span>[<span class="ruby-value str">'code'</span>].<span class="ruby-identifier">to_s</span>, <span class="ruby-constant">TOPLEVEL_BINDING</span>, <span class="ruby-node">"#{@format_file}:code"</span>
|
190
|
-
<span class="ruby-keyword kw">end</span>
|
191
|
-
|
192
|
-
<span class="ruby-keyword kw">rescue</span> <span class="ruby-constant">Exception</span>
|
193
|
-
<span class="ruby-identifier">error</span> <span class="ruby-node">"Could not load format specification file #{@format_file.inspect}"</span>
|
194
|
-
<span class="ruby-keyword kw">end</span>
|
195
|
-
|
196
|
-
<span class="ruby-ivar">@node_defs</span> = <span class="ruby-ivar">@format</span>[<span class="ruby-value str">'nodes'</span>]
|
197
|
-
|
198
|
-
<span class="ruby-comment cmt"># process input document</span>
|
199
|
-
<span class="ruby-keyword kw">begin</span>
|
200
|
-
<span class="ruby-comment cmt"># create sandbox for input evaluation</span>
|
201
|
-
<span class="ruby-identifier">template</span> = <span class="ruby-constant">Template</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">input_file</span>, <span class="ruby-identifier">input_text</span>, <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:unindent</span>])
|
202
|
-
<span class="ruby-identifier">sandbox</span> = <span class="ruby-identifier">template</span>.<span class="ruby-identifier">sandbox</span>
|
203
|
-
|
204
|
-
<span class="ruby-ivar">@template_vars</span> = {
|
205
|
-
<span class="ruby-identifier">:@format</span> =<span class="ruby-operator">></span> <span class="ruby-ivar">@format</span>,
|
206
|
-
<span class="ruby-identifier">:@roots</span> =<span class="ruby-operator">></span> <span class="ruby-ivar">@roots</span> = [], <span class="ruby-comment cmt"># root nodes of all trees</span>
|
207
|
-
<span class="ruby-identifier">:@nodes</span> =<span class="ruby-operator">></span> <span class="ruby-ivar">@nodes</span> = [], <span class="ruby-comment cmt"># all nodes in the forest</span>
|
208
|
-
<span class="ruby-identifier">:@nodes_by_type</span> =<span class="ruby-operator">></span> <span class="ruby-ivar">@nodes_by_type</span> = <span class="ruby-constant">Hash</span>.<span class="ruby-identifier">new</span> {<span class="ruby-operator">|</span><span class="ruby-identifier">h</span>,<span class="ruby-identifier">k</span><span class="ruby-operator">|</span> <span class="ruby-identifier">h</span>[<span class="ruby-identifier">k</span>] = [] },
|
209
|
-
<span class="ruby-identifier">:@stack</span> =<span class="ruby-operator">></span> [], <span class="ruby-comment cmt"># stack for all nodes</span>
|
210
|
-
}.<span class="ruby-identifier">each_pair</span> {<span class="ruby-operator">|</span><span class="ruby-identifier">k</span>,<span class="ruby-identifier">v</span><span class="ruby-operator">|</span> <span class="ruby-identifier">sandbox</span>.<span class="ruby-identifier">instance_variable_set</span>(<span class="ruby-identifier">k</span>, <span class="ruby-identifier">v</span>) }
|
211
|
-
|
212
|
-
<span class="ruby-comment cmt">#:stopdoc:</span>
|
213
|
-
|
214
|
-
<span class="ruby-comment cmt">##</span>
|
215
|
-
<span class="ruby-comment cmt"># Handles the method call from a node</span>
|
216
|
-
<span class="ruby-comment cmt"># placeholder in the input document.</span>
|
217
|
-
<span class="ruby-comment cmt">#</span>
|
218
|
-
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">sandbox</span>.<span class="ruby-identifier">__node_handler__</span> <span class="ruby-identifier">node_type</span>, <span class="ruby-operator">*</span><span class="ruby-identifier">node_args</span>, <span class="ruby-operator">&</span><span class="ruby-identifier">node_content</span>
|
219
|
-
<span class="ruby-identifier">node</span> = <span class="ruby-constant">Node</span>.<span class="ruby-identifier">new</span>(
|
220
|
-
<span class="ruby-identifier">:type</span> =<span class="ruby-operator">></span> <span class="ruby-identifier">node_type</span>,
|
221
|
-
<span class="ruby-identifier">:definition</span> =<span class="ruby-operator">></span> <span class="ruby-ivar">@format</span>[<span class="ruby-value str">'nodes'</span>][<span class="ruby-identifier">node_type</span>],
|
222
|
-
<span class="ruby-identifier">:arguments</span> =<span class="ruby-operator">></span> <span class="ruby-identifier">node_args</span>,
|
223
|
-
<span class="ruby-identifier">:backtrace</span> =<span class="ruby-operator">></span> <span class="ruby-identifier">caller</span>,
|
224
|
-
<span class="ruby-identifier">:parent</span> =<span class="ruby-operator">></span> <span class="ruby-ivar">@stack</span>.<span class="ruby-identifier">last</span>,
|
225
|
-
<span class="ruby-identifier">:children</span> =<span class="ruby-operator">></span> []
|
226
|
-
)
|
227
|
-
|
228
|
-
<span class="ruby-constant">Array</span>(<span class="ruby-identifier">node</span>.<span class="ruby-identifier">definition</span>[<span class="ruby-value str">'params'</span>]).<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">param</span><span class="ruby-operator">|</span>
|
229
|
-
<span class="ruby-keyword kw">break</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">node_args</span>.<span class="ruby-identifier">empty?</span>
|
230
|
-
<span class="ruby-identifier">node</span>.<span class="ruby-identifier">__send__</span> <span class="ruby-node">"#{param}="</span>, <span class="ruby-identifier">node_args</span>.<span class="ruby-identifier">shift</span>
|
231
|
-
<span class="ruby-keyword kw">end</span>
|
232
|
-
|
233
|
-
<span class="ruby-ivar">@nodes</span> <span class="ruby-operator"><<</span> <span class="ruby-identifier">node</span>
|
234
|
-
<span class="ruby-ivar">@nodes_by_type</span>[<span class="ruby-identifier">node</span>.<span class="ruby-identifier">type</span>] <span class="ruby-operator"><<</span> <span class="ruby-identifier">node</span>
|
235
|
-
|
236
|
-
<span class="ruby-comment cmt"># calculate ordinal number for this node</span>
|
237
|
-
<span class="ruby-keyword kw">if</span> <span class="ruby-identifier">node</span>.<span class="ruby-identifier">ordinal_number?</span>
|
238
|
-
<span class="ruby-ivar">@count_by_type</span> <span class="ruby-operator">||=</span> <span class="ruby-constant">Hash</span>.<span class="ruby-identifier">new</span> {<span class="ruby-operator">|</span><span class="ruby-identifier">h</span>,<span class="ruby-identifier">k</span><span class="ruby-operator">|</span> <span class="ruby-identifier">h</span>[<span class="ruby-identifier">k</span>] = <span class="ruby-value">0</span> }
|
239
|
-
<span class="ruby-identifier">node</span>.<span class="ruby-identifier">ordinal_number</span> = (<span class="ruby-ivar">@count_by_type</span>[<span class="ruby-identifier">node</span>.<span class="ruby-identifier">type</span>] <span class="ruby-operator">+=</span> <span class="ruby-value">1</span>)
|
240
|
-
<span class="ruby-keyword kw">end</span>
|
241
|
-
|
242
|
-
<span class="ruby-comment cmt"># assign node family</span>
|
243
|
-
<span class="ruby-keyword kw">if</span> <span class="ruby-identifier">parent</span> = <span class="ruby-identifier">node</span>.<span class="ruby-identifier">parent</span>
|
244
|
-
<span class="ruby-identifier">parent</span>.<span class="ruby-identifier">children</span> <span class="ruby-operator"><<</span> <span class="ruby-identifier">node</span>
|
245
|
-
<span class="ruby-identifier">node</span>.<span class="ruby-identifier">parent</span> = <span class="ruby-identifier">parent</span>
|
246
|
-
<span class="ruby-identifier">node</span>.<span class="ruby-identifier">depth</span> = <span class="ruby-identifier">parent</span>.<span class="ruby-identifier">depth</span>
|
247
|
-
<span class="ruby-identifier">node</span>.<span class="ruby-identifier">depth</span> <span class="ruby-operator">+=</span> <span class="ruby-value">1</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">node</span>.<span class="ruby-identifier">anchor?</span>
|
248
|
-
|
249
|
-
<span class="ruby-comment cmt"># calculate section number for this node</span>
|
250
|
-
<span class="ruby-keyword kw">if</span> <span class="ruby-identifier">node</span>.<span class="ruby-identifier">section_number?</span>
|
251
|
-
<span class="ruby-identifier">ancestor</span> = <span class="ruby-ivar">@stack</span>.<span class="ruby-identifier">reverse</span>.<span class="ruby-identifier">find</span> {<span class="ruby-operator">|</span><span class="ruby-identifier">n</span><span class="ruby-operator">|</span> <span class="ruby-identifier">n</span>.<span class="ruby-identifier">section_number</span> }
|
252
|
-
<span class="ruby-identifier">branches</span> = <span class="ruby-identifier">parent</span>.<span class="ruby-identifier">children</span>.<span class="ruby-identifier">select</span> {<span class="ruby-operator">|</span><span class="ruby-identifier">n</span><span class="ruby-operator">|</span> <span class="ruby-identifier">n</span>.<span class="ruby-identifier">section_number</span> }
|
253
|
-
|
254
|
-
<span class="ruby-identifier">node</span>.<span class="ruby-identifier">section_number</span> = [
|
255
|
-
<span class="ruby-identifier">ancestor</span>.<span class="ruby-identifier">section_number</span>,
|
256
|
-
<span class="ruby-identifier">branches</span>.<span class="ruby-identifier">length</span> <span class="ruby-operator">+</span> <span class="ruby-value">1</span>
|
257
|
-
].<span class="ruby-identifier">join</span>(<span class="ruby-value str">'.'</span>)
|
258
|
-
<span class="ruby-keyword kw">end</span>
|
259
|
-
<span class="ruby-keyword kw">else</span>
|
260
|
-
<span class="ruby-ivar">@roots</span> <span class="ruby-operator"><<</span> <span class="ruby-identifier">node</span>
|
261
|
-
<span class="ruby-identifier">node</span>.<span class="ruby-identifier">parent</span> = <span class="ruby-keyword kw">nil</span>
|
262
|
-
<span class="ruby-identifier">node</span>.<span class="ruby-identifier">depth</span> = <span class="ruby-value">0</span>
|
263
|
-
|
264
|
-
<span class="ruby-comment cmt"># calculate section number for this node</span>
|
265
|
-
<span class="ruby-keyword kw">if</span> <span class="ruby-identifier">node</span>.<span class="ruby-identifier">section_number?</span>
|
266
|
-
<span class="ruby-identifier">branches</span> = <span class="ruby-ivar">@roots</span>.<span class="ruby-identifier">select</span> {<span class="ruby-operator">|</span><span class="ruby-identifier">n</span><span class="ruby-operator">|</span> <span class="ruby-identifier">n</span>.<span class="ruby-identifier">section_number</span> }
|
267
|
-
<span class="ruby-identifier">node</span>.<span class="ruby-identifier">section_number</span> = (<span class="ruby-identifier">branches</span>.<span class="ruby-identifier">length</span> <span class="ruby-operator">+</span> <span class="ruby-value">1</span>).<span class="ruby-identifier">to_s</span>
|
268
|
-
<span class="ruby-keyword kw">end</span>
|
269
|
-
<span class="ruby-keyword kw">end</span>
|
270
|
-
|
271
|
-
<span class="ruby-comment cmt"># assign node content</span>
|
272
|
-
<span class="ruby-keyword kw">if</span> <span class="ruby-identifier">block_given?</span>
|
273
|
-
<span class="ruby-ivar">@stack</span>.<span class="ruby-identifier">push</span> <span class="ruby-identifier">node</span>
|
274
|
-
<span class="ruby-identifier">node</span>.<span class="ruby-identifier">content</span> = <span class="ruby-identifier">__block_content__</span>(<span class="ruby-identifier">node</span>, <span class="ruby-operator">&</span><span class="ruby-identifier">node_content</span>)
|
275
|
-
<span class="ruby-ivar">@stack</span>.<span class="ruby-identifier">pop</span>
|
276
|
-
<span class="ruby-keyword kw">end</span>
|
277
|
-
|
278
|
-
<span class="ruby-ivar">@buffer</span> <span class="ruby-operator"><<</span> <span class="ruby-identifier">node</span>
|
279
|
-
|
280
|
-
<span class="ruby-keyword kw">nil</span>
|
281
|
-
<span class="ruby-keyword kw">end</span>
|
282
|
-
|
283
|
-
<span class="ruby-comment cmt">#:startdoc:</span>
|
284
|
-
|
285
|
-
<span class="ruby-ivar">@node_defs</span>.<span class="ruby-identifier">each_key</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">type</span><span class="ruby-operator">|</span>
|
286
|
-
<span class="ruby-comment cmt"># XXX: using a string because define_method()</span>
|
287
|
-
<span class="ruby-comment cmt"># does not accept a block until Ruby 1.9</span>
|
288
|
-
<span class="ruby-identifier">file</span>, <span class="ruby-identifier">line</span> = <span class="ruby-keyword kw">__FILE__</span>, <span class="ruby-keyword kw">__LINE__</span>; <span class="ruby-identifier">eval</span> <span class="ruby-node">%{
|
289
|
-
def sandbox.#{type} *node_args, &node_content
|
290
|
-
__node_handler__ #{type.inspect}, *node_args, &node_content
|
291
|
-
end
|
292
|
-
}</span>, <span class="ruby-identifier">binding</span>, <span class="ruby-identifier">file</span>, <span class="ruby-identifier">line</span>
|
293
|
-
<span class="ruby-keyword kw">end</span>
|
294
|
-
|
295
|
-
<span class="ruby-comment cmt"># evaluate the input & build the document tree</span>
|
296
|
-
<span class="ruby-identifier">template</span>.<span class="ruby-identifier">render</span>
|
297
|
-
<span class="ruby-ivar">@processed_document</span> = <span class="ruby-identifier">template</span>.<span class="ruby-identifier">buffer</span>
|
298
|
-
|
299
|
-
<span class="ruby-comment cmt"># chain block-level nodes together for local navigation</span>
|
300
|
-
<span class="ruby-identifier">block_nodes</span> = <span class="ruby-ivar">@nodes</span>.<span class="ruby-identifier">select</span> {<span class="ruby-operator">|</span><span class="ruby-identifier">n</span><span class="ruby-operator">|</span> <span class="ruby-identifier">n</span>.<span class="ruby-identifier">chain?</span> }
|
301
|
-
|
302
|
-
<span class="ruby-identifier">require</span> <span class="ruby-value str">'enumerator'</span>
|
303
|
-
<span class="ruby-identifier">block_nodes</span>.<span class="ruby-identifier">each_cons</span>(<span class="ruby-value">2</span>) <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">a</span>, <span class="ruby-identifier">b</span><span class="ruby-operator">|</span>
|
304
|
-
<span class="ruby-identifier">a</span>.<span class="ruby-identifier">next_node</span> = <span class="ruby-identifier">b</span>
|
305
|
-
<span class="ruby-identifier">b</span>.<span class="ruby-identifier">prev_node</span> = <span class="ruby-identifier">a</span>
|
306
|
-
<span class="ruby-keyword kw">end</span>
|
307
|
-
|
308
|
-
<span class="ruby-comment cmt"># calculate output for all nodes</span>
|
309
|
-
<span class="ruby-identifier">actual_output_by_node</span> = {}
|
310
|
-
|
311
|
-
<span class="ruby-identifier">visitor</span> = <span class="ruby-identifier">lambda</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">n</span><span class="ruby-operator">|</span>
|
312
|
-
<span class="ruby-comment cmt">#</span>
|
313
|
-
<span class="ruby-comment cmt"># allow child nodes to calculate their actual</span>
|
314
|
-
<span class="ruby-comment cmt"># output and to set their identifier as Node#output</span>
|
315
|
-
<span class="ruby-comment cmt">#</span>
|
316
|
-
<span class="ruby-comment cmt"># we do this nodes first because this node's</span>
|
317
|
-
<span class="ruby-comment cmt"># content contains the child nodes' output</span>
|
318
|
-
<span class="ruby-comment cmt">#</span>
|
319
|
-
<span class="ruby-identifier">n</span>.<span class="ruby-identifier">children</span>.<span class="ruby-identifier">each</span> {<span class="ruby-operator">|</span><span class="ruby-identifier">c</span><span class="ruby-operator">|</span> <span class="ruby-identifier">visitor</span>.<span class="ruby-identifier">call</span> <span class="ruby-identifier">c</span> }
|
320
|
-
|
321
|
-
<span class="ruby-comment cmt"># calculate the output for this node</span>
|
322
|
-
<span class="ruby-identifier">actual_output</span> = <span class="ruby-constant">Template</span>.<span class="ruby-identifier">new</span>(
|
323
|
-
<span class="ruby-node">"#{@format_file}:nodes:#{n.type}:output"</span>,
|
324
|
-
<span class="ruby-identifier">n</span>.<span class="ruby-identifier">definition</span>[<span class="ruby-value str">'output'</span>].<span class="ruby-identifier">to_s</span>.<span class="ruby-identifier">chomp</span>
|
325
|
-
).<span class="ruby-identifier">render_with</span>(<span class="ruby-ivar">@template_vars</span>.<span class="ruby-identifier">merge</span>(<span class="ruby-identifier">:@node</span> =<span class="ruby-operator">></span> <span class="ruby-identifier">n</span>))
|
326
|
-
|
327
|
-
<span class="ruby-comment cmt"># reveal child nodes' actual output in this node's actual output</span>
|
328
|
-
<span class="ruby-identifier">n</span>.<span class="ruby-identifier">children</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">c</span><span class="ruby-operator">|</span>
|
329
|
-
<span class="ruby-keyword kw">if</span> <span class="ruby-identifier">c</span>.<span class="ruby-identifier">silent?</span>
|
330
|
-
<span class="ruby-comment cmt"># this child's output is not meant to be revealed at this time</span>
|
331
|
-
<span class="ruby-keyword kw">next</span>
|
332
|
-
|
333
|
-
<span class="ruby-keyword kw">elsif</span> <span class="ruby-identifier">c</span>.<span class="ruby-identifier">inline?</span>
|
334
|
-
<span class="ruby-identifier">actual_output</span>[<span class="ruby-identifier">c</span>.<span class="ruby-identifier">output</span>] = <span class="ruby-identifier">actual_output_by_node</span>[<span class="ruby-identifier">c</span>]
|
335
|
-
|
336
|
-
<span class="ruby-keyword kw">else</span>
|
337
|
-
<span class="ruby-comment cmt"># remove <p> around block-level child (added by Markdown)</span>
|
338
|
-
<span class="ruby-identifier">actual_output</span>.<span class="ruby-identifier">sub!</span> <span class="ruby-node">%r{(<p>\s*)?#{
|
339
|
-
Regexp.quote c.output
|
340
|
-
}(\s*</p>)?}</span> <span class="ruby-keyword kw">do</span>
|
341
|
-
<span class="ruby-identifier">actual_output_by_node</span>[<span class="ruby-identifier">c</span>] <span class="ruby-operator">+</span>
|
342
|
-
<span class="ruby-keyword kw">if</span> <span class="ruby-identifier">$1</span> <span class="ruby-keyword kw">and</span> <span class="ruby-identifier">$2</span>
|
343
|
-
<span class="ruby-value str">''</span>
|
344
|
-
<span class="ruby-keyword kw">else</span>
|
345
|
-
[<span class="ruby-identifier">$1</span>, <span class="ruby-identifier">$2</span>].<span class="ruby-identifier">join</span>
|
346
|
-
<span class="ruby-keyword kw">end</span>
|
347
|
-
<span class="ruby-keyword kw">end</span>
|
348
|
-
<span class="ruby-keyword kw">end</span>
|
349
|
-
<span class="ruby-keyword kw">end</span>
|
350
|
-
|
351
|
-
<span class="ruby-identifier">actual_output_by_node</span>[<span class="ruby-identifier">n</span>] = <span class="ruby-identifier">actual_output</span>
|
352
|
-
|
353
|
-
<span class="ruby-comment cmt">#</span>
|
354
|
-
<span class="ruby-comment cmt"># allow the parent node to calculate its actual</span>
|
355
|
-
<span class="ruby-comment cmt"># output without interference from the output of</span>
|
356
|
-
<span class="ruby-comment cmt"># this node (Node#to_s is aliased to Node#output)</span>
|
357
|
-
<span class="ruby-comment cmt">#</span>
|
358
|
-
<span class="ruby-comment cmt"># this assumes that having this node's string</span>
|
359
|
-
<span class="ruby-comment cmt"># representation be a consecutive sequence of digits</span>
|
360
|
-
<span class="ruby-comment cmt"># will not interfere with the text-to-whatever</span>
|
361
|
-
<span class="ruby-comment cmt"># transformation defined by the format specification</span>
|
362
|
-
<span class="ruby-comment cmt">#</span>
|
363
|
-
<span class="ruby-identifier">n</span>.<span class="ruby-identifier">output</span> = <span class="ruby-constant">Digest</span><span class="ruby-operator">::</span><span class="ruby-constant">SHA1</span>.<span class="ruby-identifier">digest</span>(<span class="ruby-identifier">n</span>.<span class="ruby-identifier">object_id</span>.<span class="ruby-identifier">to_s</span>).<span class="ruby-identifier">unpack</span>(<span class="ruby-value str">'I*'</span>).<span class="ruby-identifier">join</span>
|
364
|
-
<span class="ruby-keyword kw">end</span>
|
365
|
-
|
366
|
-
<span class="ruby-ivar">@roots</span>.<span class="ruby-identifier">each</span> {<span class="ruby-operator">|</span><span class="ruby-identifier">n</span><span class="ruby-operator">|</span> <span class="ruby-identifier">visitor</span>.<span class="ruby-identifier">call</span> <span class="ruby-identifier">n</span> }
|
367
|
-
|
368
|
-
<span class="ruby-comment cmt"># replace the temporary identifier with each node's actual output</span>
|
369
|
-
<span class="ruby-ivar">@nodes</span>.<span class="ruby-identifier">each</span> {<span class="ruby-operator">|</span><span class="ruby-identifier">n</span><span class="ruby-operator">|</span> <span class="ruby-identifier">n</span>.<span class="ruby-identifier">output</span> = <span class="ruby-identifier">actual_output_by_node</span>[<span class="ruby-identifier">n</span>] }
|
370
|
-
|
371
|
-
<span class="ruby-keyword kw">rescue</span> <span class="ruby-constant">Exception</span>
|
372
|
-
<span class="ruby-identifier">puts</span> <span class="ruby-identifier">input_text</span> <span class="ruby-comment cmt"># so the user can debug line numbers in stack trace</span>
|
373
|
-
<span class="ruby-identifier">error</span> <span class="ruby-node">"Could not process input document #{input_file.inspect}"</span>
|
374
|
-
<span class="ruby-keyword kw">end</span>
|
183
|
+
<span class="ruby-identifier">process_input_document</span>
|
375
184
|
<span class="ruby-keyword kw">end</span></pre>
|
376
185
|
</div>
|
377
186
|
</div>
|
@@ -381,9 +190,9 @@ specification file.
|
|
381
190
|
<div class="sectiontitle">Instance Public methods</div>
|
382
191
|
|
383
192
|
<div class="method">
|
384
|
-
<div class="title" id="
|
193
|
+
<div class="title" id="M000052">
|
385
194
|
|
386
|
-
<a name="
|
195
|
+
<a name="M000052"></a><b>to_s</b>()
|
387
196
|
|
388
197
|
</div>
|
389
198
|
|
@@ -399,16 +208,16 @@ Returns the output of this document.
|
|
399
208
|
|
400
209
|
<div class="sourcecode">
|
401
210
|
<p class="source-link">
|
402
|
-
Source: <a href="javascript:toggleSource('
|
211
|
+
Source: <a href="javascript:toggleSource('M000052_source')" id="l_M000052_source">show</a>
|
403
212
|
|
404
|
-
| <a href="http://github.com/sunaku/erbook/blob/
|
213
|
+
| <a href="http://github.com/sunaku/erbook/blob/8c15499d81a4c71c3a15850bff81dc6e5d0236c5/lib/erbook/document.rb#L55" target="_blank" class="github_url">on GitHub</a>
|
405
214
|
|
406
215
|
</p>
|
407
|
-
<div id="
|
408
|
-
<pre><span class="ruby-comment cmt"># File lib/erbook/document.rb, line
|
216
|
+
<div id="M000052_source" class="dyn-source">
|
217
|
+
<pre><span class="ruby-comment cmt"># File lib/erbook/document.rb, line 55</span>
|
409
218
|
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">to_s</span>
|
410
219
|
<span class="ruby-constant">Template</span>.<span class="ruby-identifier">new</span>(<span class="ruby-node">"#{@format_file}:output"</span>, <span class="ruby-ivar">@format</span>[<span class="ruby-value str">'output'</span>].<span class="ruby-identifier">to_s</span>).
|
411
|
-
<span class="ruby-identifier">render_with</span>(<span class="ruby-ivar">@template_vars</span>.<span class="ruby-identifier">merge</span>(<span class="ruby-identifier">:@content</span> =<span class="ruby-operator">></span> <span class="ruby-ivar">@
|
220
|
+
<span class="ruby-identifier">render_with</span>(<span class="ruby-ivar">@template_vars</span>.<span class="ruby-identifier">merge</span>(<span class="ruby-identifier">:@content</span> =<span class="ruby-operator">></span> <span class="ruby-ivar">@evaluated_document</span>.<span class="ruby-identifier">join</span>))
|
412
221
|
<span class="ruby-keyword kw">end</span></pre>
|
413
222
|
</div>
|
414
223
|
</div>
|
@@ -49,7 +49,7 @@
|
|
49
49
|
<dd>
|
50
50
|
<ul>
|
51
51
|
|
52
|
-
<li><a href="#
|
52
|
+
<li><a href="#M000056">chain?</a></li>
|
53
53
|
|
54
54
|
</ul>
|
55
55
|
</dd>
|
@@ -58,7 +58,7 @@
|
|
58
58
|
<dd>
|
59
59
|
<ul>
|
60
60
|
|
61
|
-
<li><a href="#
|
61
|
+
<li><a href="#M000057">inline?</a></li>
|
62
62
|
|
63
63
|
</ul>
|
64
64
|
</dd>
|
@@ -67,7 +67,7 @@
|
|
67
67
|
<dd>
|
68
68
|
<ul>
|
69
69
|
|
70
|
-
<li><a href="#
|
70
|
+
<li><a href="#M000055">ordinal_number?</a></li>
|
71
71
|
|
72
72
|
</ul>
|
73
73
|
</dd>
|
@@ -76,9 +76,9 @@
|
|
76
76
|
<dd>
|
77
77
|
<ul>
|
78
78
|
|
79
|
-
<li><a href="#
|
79
|
+
<li><a href="#M000054">section_number?</a>,</li>
|
80
80
|
|
81
|
-
<li><a href="#
|
81
|
+
<li><a href="#M000058">silent?</a></li>
|
82
82
|
|
83
83
|
</ul>
|
84
84
|
</dd>
|
@@ -87,7 +87,7 @@
|
|
87
87
|
<dd>
|
88
88
|
<ul>
|
89
89
|
|
90
|
-
<li><a href="#
|
90
|
+
<li><a href="#M000053">to_s</a></li>
|
91
91
|
|
92
92
|
</ul>
|
93
93
|
</dd>
|
@@ -109,9 +109,9 @@
|
|
109
109
|
<div class="sectiontitle">Instance Public methods</div>
|
110
110
|
|
111
111
|
<div class="method">
|
112
|
-
<div class="title" id="
|
112
|
+
<div class="title" id="M000056">
|
113
113
|
|
114
|
-
<a name="
|
114
|
+
<a name="M000056"></a><b>chain?</b>()
|
115
115
|
|
116
116
|
</div>
|
117
117
|
|
@@ -127,13 +127,13 @@ Include this node in the previous/next navigation chain?
|
|
127
127
|
|
128
128
|
<div class="sourcecode">
|
129
129
|
<p class="source-link">
|
130
|
-
Source: <a href="javascript:toggleSource('
|
130
|
+
Source: <a href="javascript:toggleSource('M000056_source')" id="l_M000056_source">show</a>
|
131
131
|
|
132
|
-
| <a href="http://github.com/sunaku/erbook/blob/
|
132
|
+
| <a href="http://github.com/sunaku/erbook/blob/8c15499d81a4c71c3a15850bff81dc6e5d0236c5/lib/erbook/document.rb#L88" target="_blank" class="github_url">on GitHub</a>
|
133
133
|
|
134
134
|
</p>
|
135
|
-
<div id="
|
136
|
-
<pre><span class="ruby-comment cmt"># File lib/erbook/document.rb, line
|
135
|
+
<div id="M000056_source" class="dyn-source">
|
136
|
+
<pre><span class="ruby-comment cmt"># File lib/erbook/document.rb, line 88</span>
|
137
137
|
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">chain?</span>
|
138
138
|
<span class="ruby-identifier">definition</span>[<span class="ruby-value str">'chain'</span>]
|
139
139
|
<span class="ruby-keyword kw">end</span></pre>
|
@@ -143,9 +143,9 @@ Include this node in the previous/next navigation chain?
|
|
143
143
|
</div>
|
144
144
|
|
145
145
|
<div class="method">
|
146
|
-
<div class="title" id="
|
146
|
+
<div class="title" id="M000057">
|
147
147
|
|
148
|
-
<a name="
|
148
|
+
<a name="M000057"></a><b>inline?</b>()
|
149
149
|
|
150
150
|
</div>
|
151
151
|
|
@@ -154,13 +154,13 @@ Include this node in the previous/next navigation chain?
|
|
154
154
|
|
155
155
|
<div class="sourcecode">
|
156
156
|
<p class="source-link">
|
157
|
-
Source: <a href="javascript:toggleSource('
|
157
|
+
Source: <a href="javascript:toggleSource('M000057_source')" id="l_M000057_source">show</a>
|
158
158
|
|
159
|
-
| <a href="http://github.com/sunaku/erbook/blob/
|
159
|
+
| <a href="http://github.com/sunaku/erbook/blob/8c15499d81a4c71c3a15850bff81dc6e5d0236c5/lib/erbook/document.rb#L92" target="_blank" class="github_url">on GitHub</a>
|
160
160
|
|
161
161
|
</p>
|
162
|
-
<div id="
|
163
|
-
<pre><span class="ruby-comment cmt"># File lib/erbook/document.rb, line
|
162
|
+
<div id="M000057_source" class="dyn-source">
|
163
|
+
<pre><span class="ruby-comment cmt"># File lib/erbook/document.rb, line 92</span>
|
164
164
|
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">inline?</span>
|
165
165
|
<span class="ruby-identifier">definition</span>[<span class="ruby-value str">'inline'</span>]
|
166
166
|
<span class="ruby-keyword kw">end</span></pre>
|
@@ -170,9 +170,9 @@ Include this node in the previous/next navigation chain?
|
|
170
170
|
</div>
|
171
171
|
|
172
172
|
<div class="method">
|
173
|
-
<div class="title" id="
|
173
|
+
<div class="title" id="M000055">
|
174
174
|
|
175
|
-
<a name="
|
175
|
+
<a name="M000055"></a><b>ordinal_number?</b>()
|
176
176
|
|
177
177
|
</div>
|
178
178
|
|
@@ -181,13 +181,13 @@ Include this node in the previous/next navigation chain?
|
|
181
181
|
|
182
182
|
<div class="sourcecode">
|
183
183
|
<p class="source-link">
|
184
|
-
Source: <a href="javascript:toggleSource('
|
184
|
+
Source: <a href="javascript:toggleSource('M000055_source')" id="l_M000055_source">show</a>
|
185
185
|
|
186
|
-
| <a href="http://github.com/sunaku/erbook/blob/
|
186
|
+
| <a href="http://github.com/sunaku/erbook/blob/8c15499d81a4c71c3a15850bff81dc6e5d0236c5/lib/erbook/document.rb#L81" target="_blank" class="github_url">on GitHub</a>
|
187
187
|
|
188
188
|
</p>
|
189
|
-
<div id="
|
190
|
-
<pre><span class="ruby-comment cmt"># File lib/erbook/document.rb, line
|
189
|
+
<div id="M000055_source" class="dyn-source">
|
190
|
+
<pre><span class="ruby-comment cmt"># File lib/erbook/document.rb, line 81</span>
|
191
191
|
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">ordinal_number?</span>
|
192
192
|
<span class="ruby-constant">Array</span>(<span class="ruby-identifier">definition</span>[<span class="ruby-value str">'number'</span>]).<span class="ruby-identifier">include?</span> <span class="ruby-value str">'ordinal'</span>
|
193
193
|
<span class="ruby-keyword kw">end</span></pre>
|
@@ -197,9 +197,9 @@ Include this node in the previous/next navigation chain?
|
|
197
197
|
</div>
|
198
198
|
|
199
199
|
<div class="method">
|
200
|
-
<div class="title" id="
|
200
|
+
<div class="title" id="M000054">
|
201
201
|
|
202
|
-
<a name="
|
202
|
+
<a name="M000054"></a><b>section_number?</b>()
|
203
203
|
|
204
204
|
</div>
|
205
205
|
|
@@ -208,13 +208,13 @@ Include this node in the previous/next navigation chain?
|
|
208
208
|
|
209
209
|
<div class="sourcecode">
|
210
210
|
<p class="source-link">
|
211
|
-
Source: <a href="javascript:toggleSource('
|
211
|
+
Source: <a href="javascript:toggleSource('M000054_source')" id="l_M000054_source">show</a>
|
212
212
|
|
213
|
-
| <a href="http://github.com/sunaku/erbook/blob/
|
213
|
+
| <a href="http://github.com/sunaku/erbook/blob/8c15499d81a4c71c3a15850bff81dc6e5d0236c5/lib/erbook/document.rb#L77" target="_blank" class="github_url">on GitHub</a>
|
214
214
|
|
215
215
|
</p>
|
216
|
-
<div id="
|
217
|
-
<pre><span class="ruby-comment cmt"># File lib/erbook/document.rb, line
|
216
|
+
<div id="M000054_source" class="dyn-source">
|
217
|
+
<pre><span class="ruby-comment cmt"># File lib/erbook/document.rb, line 77</span>
|
218
218
|
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">section_number?</span>
|
219
219
|
<span class="ruby-constant">Array</span>(<span class="ruby-identifier">definition</span>[<span class="ruby-value str">'number'</span>]).<span class="ruby-identifier">include?</span> <span class="ruby-value str">'section'</span>
|
220
220
|
<span class="ruby-keyword kw">end</span></pre>
|
@@ -224,9 +224,9 @@ Include this node in the previous/next navigation chain?
|
|
224
224
|
</div>
|
225
225
|
|
226
226
|
<div class="method">
|
227
|
-
<div class="title" id="
|
227
|
+
<div class="title" id="M000058">
|
228
228
|
|
229
|
-
<a name="
|
229
|
+
<a name="M000058"></a><b>silent?</b>()
|
230
230
|
|
231
231
|
</div>
|
232
232
|
|
@@ -235,13 +235,13 @@ Include this node in the previous/next navigation chain?
|
|
235
235
|
|
236
236
|
<div class="sourcecode">
|
237
237
|
<p class="source-link">
|
238
|
-
Source: <a href="javascript:toggleSource('
|
238
|
+
Source: <a href="javascript:toggleSource('M000058_source')" id="l_M000058_source">show</a>
|
239
239
|
|
240
|
-
| <a href="http://github.com/sunaku/erbook/blob/
|
240
|
+
| <a href="http://github.com/sunaku/erbook/blob/8c15499d81a4c71c3a15850bff81dc6e5d0236c5/lib/erbook/document.rb#L96" target="_blank" class="github_url">on GitHub</a>
|
241
241
|
|
242
242
|
</p>
|
243
|
-
<div id="
|
244
|
-
<pre><span class="ruby-comment cmt"># File lib/erbook/document.rb, line
|
243
|
+
<div id="M000058_source" class="dyn-source">
|
244
|
+
<pre><span class="ruby-comment cmt"># File lib/erbook/document.rb, line 96</span>
|
245
245
|
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">silent?</span>
|
246
246
|
<span class="ruby-identifier">definition</span>[<span class="ruby-value str">'silent'</span>]
|
247
247
|
<span class="ruby-keyword kw">end</span></pre>
|
@@ -251,9 +251,9 @@ Include this node in the previous/next navigation chain?
|
|
251
251
|
</div>
|
252
252
|
|
253
253
|
<div class="method">
|
254
|
-
<div class="title" id="
|
254
|
+
<div class="title" id="M000053">
|
255
255
|
|
256
|
-
<a name="
|
256
|
+
<a name="M000053"></a><b>to_s</b>()
|
257
257
|
|
258
258
|
</div>
|
259
259
|
|
@@ -269,13 +269,13 @@ Returns the output of this node.
|
|
269
269
|
|
270
270
|
<div class="sourcecode">
|
271
271
|
<p class="source-link">
|
272
|
-
Source: <a href="javascript:toggleSource('
|
272
|
+
Source: <a href="javascript:toggleSource('M000053_source')" id="l_M000053_source">show</a>
|
273
273
|
|
274
|
-
| <a href="http://github.com/sunaku/erbook/blob/
|
274
|
+
| <a href="http://github.com/sunaku/erbook/blob/8c15499d81a4c71c3a15850bff81dc6e5d0236c5/lib/erbook/document.rb#L69" target="_blank" class="github_url">on GitHub</a>
|
275
275
|
|
276
276
|
</p>
|
277
|
-
<div id="
|
278
|
-
<pre><span class="ruby-comment cmt"># File lib/erbook/document.rb, line
|
277
|
+
<div id="M000053_source" class="dyn-source">
|
278
|
+
<pre><span class="ruby-comment cmt"># File lib/erbook/document.rb, line 69</span>
|
279
279
|
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">to_s</span>
|
280
280
|
<span class="ruby-keyword kw">if</span> <span class="ruby-identifier">silent?</span>
|
281
281
|
<span class="ruby-value str">''</span>
|