doc/api/classes/ERBook/Document.html in erbook-8.0.0 vs doc/api/classes/ERBook/Document.html in erbook-9.0.0

- old
+ new

@@ -47,20 +47,20 @@ <dt>N</dt> <dd> <ul> - <li><a href="#M000052">new</a></li> + <li><a href="#M000046">new</a></li> </ul> </dd> <dt>T</dt> <dd> <ul> - <li><a href="#M000064">to_s</a></li> + <li><a href="#M000054">to_s</a></li> </ul> </dd> </dl> @@ -130,13 +130,13 @@ <div class="sectiontitle">Class Public methods</div> <div class="method"> - <div class="title" id="M000052"> + <div class="title" id="M000046"> - <a name="M000052"></a><b>new</b>(format_name, input_text, input_file, options = {}) + <a name="M000046"></a><b>new</b>(format_name, input_text, input_file, options = {}) </div> <div class="description"> <h4>Parameters</h4> @@ -164,16 +164,16 @@ <div class="sourcecode"> <p class="source-link"> - Source: <a href="javascript:toggleSource('M000052_source')" id="l_M000052_source">show</a> + Source: <a href="javascript:toggleSource('M000046_source')" id="l_M000046_source">show</a> - | <a href="http://github.com/sunaku/erbook/blob/aeaff38e68b16f53360682a1f9770747dd84ecb6/lib/erbook/document.rb#L42" target="_blank" class="github_url">on GitHub</a> + | <a href="http://github.com/sunaku/erbook/blob/eda493a151e7b55d041d0a094c586e2c22aa63cc/lib/erbook/document.rb#L42" target="_blank" class="github_url">on GitHub</a> </p> - <div id="M000052_source" class="dyn-source"> + <div id="M000046_source" class="dyn-source"> <pre><span class="ruby-comment cmt"># File lib/erbook/document.rb, line 42</span> <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> = {} <span class="ruby-comment cmt"># process format specification</span> <span class="ruby-ivar">@format_file</span> = <span class="ruby-identifier">format_name</span>.<span class="ruby-identifier">to_s</span> @@ -213,11 +213,11 @@ <span class="ruby-comment cmt">##</span> <span class="ruby-comment cmt"># Handles the method call from a node</span> <span class="ruby-comment cmt"># placeholder in the input document.</span> <span class="ruby-comment cmt">#</span> - <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">sandbox</span>.<span class="ruby-identifier">__node_impl__</span> <span class="ruby-identifier">node_type</span>, <span class="ruby-operator">*</span><span class="ruby-identifier">node_args</span>, <span class="ruby-operator">&amp;</span><span class="ruby-identifier">node_content</span> + <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">&amp;</span><span class="ruby-identifier">node_content</span> <span class="ruby-identifier">node</span> = <span class="ruby-constant">Node</span>.<span class="ruby-identifier">new</span>( <span class="ruby-identifier">:type</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">node_type</span>, <span class="ruby-identifier">:definition</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-ivar">@format</span>[<span class="ruby-value str">'nodes'</span>][<span class="ruby-identifier">node_type</span>], <span class="ruby-identifier">:arguments</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">node_args</span>, <span class="ruby-identifier">:backtrace</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">caller</span>, @@ -285,21 +285,21 @@ <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> <span class="ruby-comment cmt"># XXX: using a string because define_method()</span> <span class="ruby-comment cmt"># does not accept a block until Ruby 1.9</span> <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">%{ def sandbox.#{type} *node_args, &amp;node_content - __node_impl__ #{type.inspect}, *node_args, &amp;node_content + __node_handler__ #{type.inspect}, *node_args, &amp;node_content end }</span>, <span class="ruby-identifier">binding</span>, <span class="ruby-identifier">file</span>, <span class="ruby-identifier">line</span> <span class="ruby-keyword kw">end</span> <span class="ruby-comment cmt"># evaluate the input &amp; build the document tree</span> <span class="ruby-identifier">template</span>.<span class="ruby-identifier">render</span> <span class="ruby-ivar">@processed_document</span> = <span class="ruby-identifier">template</span>.<span class="ruby-identifier">buffer</span> <span class="ruby-comment cmt"># chain block-level nodes together for local navigation</span> - <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">anchor?</span> } + <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> } <span class="ruby-identifier">require</span> <span class="ruby-value str">'enumerator'</span> <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> <span class="ruby-identifier">a</span>.<span class="ruby-identifier">next_node</span> = <span class="ruby-identifier">b</span> <span class="ruby-identifier">b</span>.<span class="ruby-identifier">prev_node</span> = <span class="ruby-identifier">a</span> @@ -332,13 +332,20 @@ <span class="ruby-keyword kw">elsif</span> <span class="ruby-identifier">c</span>.<span class="ruby-identifier">inline?</span> <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>] <span class="ruby-keyword kw">else</span> - <span class="ruby-comment cmt"># pull block-level child out of paragraph tag added by Maruku</span> - <span class="ruby-identifier">actual_output</span>.<span class="ruby-identifier">sub!</span> <span class="ruby-node">%r/(&lt;p&gt;\s*)?#{Regexp.quote c.output}/</span> <span class="ruby-keyword kw">do</span> - <span class="ruby-identifier">actual_output_by_node</span>[<span class="ruby-identifier">c</span>] <span class="ruby-operator">+</span> <span class="ruby-identifier">$1</span>.<span class="ruby-identifier">to_s</span> + <span class="ruby-comment cmt"># remove &lt;p&gt; around block-level child (added by Markdown)</span> + <span class="ruby-identifier">actual_output</span>.<span class="ruby-identifier">sub!</span> <span class="ruby-node">%r{(&lt;p&gt;\s*)?#{ + Regexp.quote c.output + }(\s*&lt;/p&gt;)?}</span> <span class="ruby-keyword kw">do</span> + <span class="ruby-identifier">actual_output_by_node</span>[<span class="ruby-identifier">c</span>] <span class="ruby-operator">+</span> + <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> + <span class="ruby-value str">''</span> + <span class="ruby-keyword kw">else</span> + [<span class="ruby-identifier">$1</span>, <span class="ruby-identifier">$2</span>].<span class="ruby-identifier">join</span> + <span class="ruby-keyword kw">end</span> <span class="ruby-keyword kw">end</span> <span class="ruby-keyword kw">end</span> <span class="ruby-keyword kw">end</span> <span class="ruby-identifier">actual_output_by_node</span>[<span class="ruby-identifier">n</span>] = <span class="ruby-identifier">actual_output</span> @@ -372,13 +379,13 @@ </div> <div class="sectiontitle">Instance Public methods</div> <div class="method"> - <div class="title" id="M000064"> + <div class="title" id="M000054"> - <a name="M000064"></a><b>to_s</b>() + <a name="M000054"></a><b>to_s</b>() </div> <div class="description"> <p> @@ -390,16 +397,16 @@ <div class="sourcecode"> <p class="source-link"> - Source: <a href="javascript:toggleSource('M000064_source')" id="l_M000064_source">show</a> + Source: <a href="javascript:toggleSource('M000054_source')" id="l_M000054_source">show</a> - | <a href="http://github.com/sunaku/erbook/blob/aeaff38e68b16f53360682a1f9770747dd84ecb6/lib/erbook/document.rb#L239" target="_blank" class="github_url">on GitHub</a> + | <a href="http://github.com/sunaku/erbook/blob/eda493a151e7b55d041d0a094c586e2c22aa63cc/lib/erbook/document.rb#L246" target="_blank" class="github_url">on GitHub</a> </p> - <div id="M000064_source" class="dyn-source"> - <pre><span class="ruby-comment cmt"># File lib/erbook/document.rb, line 239</span> + <div id="M000054_source" class="dyn-source"> + <pre><span class="ruby-comment cmt"># File lib/erbook/document.rb, line 246</span> <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">to_s</span> <span class="ruby-constant">Template</span>.<span class="ruby-identifier">new</span>(<span class="ruby-node">&quot;#{@format_file}:output&quot;</span>, <span class="ruby-ivar">@format</span>[<span class="ruby-value str">'output'</span>].<span class="ruby-identifier">to_s</span>). <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">&gt;</span> <span class="ruby-ivar">@processed_document</span>.<span class="ruby-identifier">join</span>)) <span class="ruby-keyword kw">end</span></pre> </div> \ No newline at end of file