1
0
Fork 0
mirror of https://github.com/ganelson/inform.git synced 2024-07-08 18:14:21 +03:00
inform7/docs/indoc/2-rnd.html

1128 lines
143 KiB
HTML

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>2/exm</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta http-equiv="Content-Language" content="en-gb">
<link href="inweb.css" rel="stylesheet" rev="stylesheet" type="text/css">
</head>
<body>
<!--Weave of '2/rnd' generated by 7-->
<ul class="crumbs"><li><a href="../webs.html">&#9733;</a></li><li><a href="index.html">indoc 4</a></li><li><a href="index.html#2">Chapter 2: Processing</a></li><li><b>Renderer</b></li></ul><p class="purpose">The general output apparatus for writing a block of documentation.</p>
<ul class="toc"><li><a href="#SP1">&#167;1. Definitions</a></li><li><a href="#SP7">&#167;7. Block buffer</a></li><li><a href="#SP9">&#167;9. Top-level renderer</a></li><li><a href="#SP11">&#167;11. Rendering text</a></li><li><a href="#SP11_2_1">&#167;11.2.1. Code mode</a></li><li><a href="#SP11_2_4">&#167;11.2.4. Tabular mode</a></li><li><a href="#SP11_2_7">&#167;11.2.7. Regular mode</a></li><li><a href="#SP11_2_2_3">&#167;11.2.2.3. Javascript paste icons</a></li><li><a href="#SP14">&#167;14. Rendering cross-references to other sections</a></li><li><a href="#SP16">&#167;16. Handling the formatted file</a></li></ul><hr class="tocbar">
<p class="inwebparagraph"><a id="SP1"></a><b>&#167;1. Definitions. </b></p>
<p class="inwebparagraph"><a id="SP2"></a><b>&#167;2. </b>The output mechanism produces documentation in chunks called "blocks", and
it has a buffer which stores one block at a time. Each block contains a
list of paragraphs, numbered from 0.
</p>
<pre class="definitions">
<span class="definitionkeyword">define</span> <span class="constant">MAX_PARAGRAPHS_PER_BLOCK</span><span class="plain"> 1000</span>
</pre>
<pre class="display">
<span class="reserved">typedef</span><span class="plain"> </span><span class="reserved">struct</span><span class="plain"> </span><span class="reserved">paragraph</span><span class="plain"> {</span>
<span class="reserved">int</span><span class="plain"> </span><span class="identifier">par_indentation</span><span class="plain">;</span>
<span class="reserved">int</span><span class="plain"> </span><span class="identifier">par_suppression</span><span class="plain">;</span>
<span class="reserved">struct</span><span class="plain"> </span><span class="reserved">text_stream</span><span class="plain"> *</span><span class="identifier">par_texts</span><span class="plain">;</span>
<span class="reserved">struct</span><span class="plain"> </span><span class="reserved">text_stream</span><span class="plain"> *</span><span class="identifier">par_prefix</span><span class="plain">;</span>
<span class="reserved">struct</span><span class="plain"> </span><span class="reserved">text_stream</span><span class="plain"> *</span><span class="identifier">par_styles</span><span class="plain">;</span>
<span class="reserved">int</span><span class="plain"> </span><span class="identifier">par_shortened</span><span class="plain">;</span>
<span class="plain">} </span><span class="reserved">paragraph</span><span class="plain">;</span>
</pre>
<p class="inwebparagraph"></p>
<p class="endnote">The structure paragraph is accessed in 2/rr and here.</p>
<p class="inwebparagraph"><a id="SP3"></a><b>&#167;3. </b></p>
<pre class="display">
<span class="reserved">int</span><span class="plain"> </span><span class="identifier">no_paras_in_block_buffer</span><span class="plain"> = 0;</span>
<span class="reserved">paragraph</span><span class="plain"> </span><span class="identifier">paragraphs</span><span class="plain">[</span><span class="constant">MAX_PARAGRAPHS_PER_BLOCK</span><span class="plain">];</span>
</pre>
<p class="inwebparagraph"></p>
<p class="inwebparagraph"><a id="SP4"></a><b>&#167;4. </b>The blocks are written to a file of "formatted text":
</p>
<pre class="display">
<span class="reserved">filename</span><span class="plain"> *</span><span class="identifier">current_FTD_filename</span><span class="plain"> = </span><span class="identifier">NULL</span><span class="plain">; </span> <span class="comment">with <code class="display"><span class="extract">NULL</span></code> meaning that no file is open</span>
<span class="reserved">text_stream</span><span class="plain"> </span><span class="identifier">current_FTD_stream</span><span class="plain">; </span> <span class="comment">otherwise, this is where the text goes</span>
</pre>
<p class="inwebparagraph"></p>
<p class="inwebparagraph"><a id="SP5"></a><b>&#167;5. </b>It's convenient to record all the formatted text filenames written to, and
those are the keys of the following hash:
</p>
<pre class="display">
<span class="reserved">typedef</span><span class="plain"> </span><span class="reserved">struct</span><span class="plain"> </span><span class="reserved">formatted_file</span><span class="plain"> {</span>
<span class="reserved">struct</span><span class="plain"> </span><span class="reserved">filename</span><span class="plain"> *</span><span class="identifier">name</span><span class="plain">;</span>
<span class="constant">MEMORY_MANAGEMENT</span>
<span class="plain">} </span><span class="reserved">formatted_file</span><span class="plain">;</span>
</pre>
<p class="inwebparagraph"></p>
<p class="endnote">The structure formatted_file is accessed in 2/utsr and here.</p>
<p class="inwebparagraph"><a id="SP6"></a><b>&#167;6. </b>Miscellaneously:
</p>
<pre class="display">
<span class="reserved">int</span><span class="plain"> </span><span class="identifier">Javascript_paste_count</span><span class="plain"> = 0; </span> <span class="comment">used to make unique ID numbers for paste icons</span>
<span class="reserved">int</span><span class="plain"> </span><span class="identifier">index_to_examples</span><span class="plain"> = </span><span class="constant">FALSE</span><span class="plain">; </span> <span class="comment">used to index examples to particular sections</span>
<span class="reserved">int</span><span class="plain"> </span><span class="identifier">unique_code_pos_counter</span><span class="plain"> = 0; </span> <span class="comment">used to uniquely ID code samples</span>
<span class="reserved">example</span><span class="plain"> *</span><span class="identifier">code_example</span><span class="plain"> = </span><span class="identifier">NULL</span><span class="plain">;</span>
</pre>
<p class="inwebparagraph"></p>
<p class="inwebparagraph"><a id="SP7"></a><b>&#167;7. Block buffer. </b>When the scanner starts a new block, it calls this:
</p>
<pre class="display">
<span class="reserved">void</span><span class="plain"> </span><span class="functiontext">Renderer::clear_block_buffer</span><span class="plain">(</span><span class="reserved">void</span><span class="plain">) {</span>
<span class="identifier">no_paras_in_block_buffer</span><span class="plain"> = 0;</span>
<span class="identifier">index_to_examples</span><span class="plain"> = </span><span class="constant">FALSE</span><span class="plain">;</span>
<span class="plain">}</span>
</pre>
<p class="inwebparagraph"></p>
<p class="endnote">The function Renderer::clear_block_buffer is used in 2/rr (<a href="2-rr.html#SP3_2">&#167;3.2</a>).</p>
<p class="inwebparagraph"><a id="SP8"></a><b>&#167;8. </b>It then calls this to add paragraphs to the block:
</p>
<pre class="display">
<span class="reserved">void</span><span class="plain"> </span><span class="functiontext">Renderer::add_para_to_block_buffer</span><span class="plain">(</span><span class="reserved">text_stream</span><span class="plain"> *</span><span class="identifier">text</span><span class="plain">, </span><span class="reserved">int</span><span class="plain"> </span><span class="identifier">indentation</span><span class="plain">, </span><span class="reserved">int</span><span class="plain"> </span><span class="identifier">suppression</span><span class="plain">,</span>
<span class="reserved">text_stream</span><span class="plain"> *</span><span class="identifier">prefix</span><span class="plain">, </span><span class="reserved">text_stream</span><span class="plain"> *</span><span class="identifier">style</span><span class="plain">, </span><span class="reserved">int</span><span class="plain"> </span><span class="identifier">shortened</span><span class="plain">) {</span>
<span class="reserved">if</span><span class="plain"> (</span><span class="identifier">no_paras_in_block_buffer</span><span class="plain"> &gt;= </span><span class="constant">MAX_PARAGRAPHS_PER_BLOCK</span><span class="plain">)</span>
<span class="functiontext">Errors::fatal</span><span class="plain">(</span><span class="string">"too many paragraphs in block"</span><span class="plain">);</span>
<span class="reserved">paragraph</span><span class="plain"> *</span><span class="identifier">P</span><span class="plain"> = &amp;</span><span class="identifier">paragraphs</span><span class="plain">[</span><span class="identifier">no_paras_in_block_buffer</span><span class="plain">++];</span>
<span class="identifier">P</span><span class="plain">-</span><span class="element">&gt;par_indentation</span><span class="plain"> = </span><span class="identifier">indentation</span><span class="plain">;</span>
<span class="identifier">P</span><span class="plain">-</span><span class="element">&gt;par_texts</span><span class="plain"> = </span><span class="functiontext">Str::duplicate</span><span class="plain">(</span><span class="identifier">text</span><span class="plain">);</span>
<span class="identifier">P</span><span class="plain">-</span><span class="element">&gt;par_suppression</span><span class="plain"> = </span><span class="identifier">suppression</span><span class="plain">;</span>
<span class="identifier">P</span><span class="plain">-</span><span class="element">&gt;par_prefix</span><span class="plain"> = </span><span class="functiontext">Str::duplicate</span><span class="plain">(</span><span class="identifier">prefix</span><span class="plain">);</span>
<span class="identifier">P</span><span class="plain">-</span><span class="element">&gt;par_styles</span><span class="plain"> = </span><span class="functiontext">Str::duplicate</span><span class="plain">(</span><span class="identifier">style</span><span class="plain">);</span>
<span class="identifier">P</span><span class="plain">-</span><span class="element">&gt;par_shortened</span><span class="plain"> = </span><span class="identifier">shortened</span><span class="plain">;</span>
<span class="plain">}</span>
</pre>
<p class="inwebparagraph"></p>
<p class="endnote">The function Renderer::add_para_to_block_buffer is used in 2/rr (<a href="2-rr.html#SP4_7">&#167;4.7</a>).</p>
<p class="inwebparagraph"><a id="SP9"></a><b>&#167;9. Top-level renderer. </b>If the block consists of text from a section, then the scanner calls the
following when the buffer is filled. If, on the other hand, the block
comes from an example, it calls <code class="display"><span class="extract">render_text_of_block</span></code> instead, a simpler
routine which doesn't surround the text with navigational gadgets and headings.
</p>
<pre class="display">
<span class="reserved">text_stream</span><span class="plain"> *</span><span class="functiontext">Renderer::render_block</span><span class="plain">(</span><span class="constant">OUTPUT_STREAM</span><span class="plain">, </span><span class="reserved">volume</span><span class="plain"> *</span><span class="identifier">V</span><span class="plain">, </span><span class="reserved">section</span><span class="plain"> *</span><span class="identifier">S</span><span class="plain">) {</span>
<span class="identifier">OUT</span><span class="plain"> = </span><span class="functiontext">Renderer::formatted_file_must_be</span><span class="plain">(</span><span class="identifier">OUT</span><span class="plain">, </span><span class="identifier">V</span><span class="plain">, </span><span class="identifier">S</span><span class="plain">);</span>
<span class="functiontext">Nav::render_navigation_top</span><span class="plain">(</span><span class="identifier">OUT</span><span class="plain">, </span><span class="identifier">V</span><span class="plain">, </span><span class="identifier">S</span><span class="plain">);</span>
<span class="functiontext">Renderer::render_text_of_block</span><span class="plain">(</span><span class="identifier">OUT</span><span class="plain">, </span><span class="identifier">V</span><span class="plain">, </span><span class="identifier">S</span><span class="plain">);</span>
<span class="functiontext">Nav::render_navigation_middle</span><span class="plain">(</span><span class="identifier">OUT</span><span class="plain">, </span><span class="identifier">V</span><span class="plain">, </span><span class="identifier">S</span><span class="plain">);</span>
&lt;<span class="cwebmacro">Render the examples below the text of the block</span> <span class="cwebmacronumber">9.1</span>&gt;<span class="plain">;</span>
<span class="functiontext">Nav::render_navigation_bottom</span><span class="plain">(</span><span class="identifier">OUT</span><span class="plain">, </span><span class="identifier">V</span><span class="plain">, </span><span class="identifier">S</span><span class="plain">);</span>
<span class="reserved">return</span><span class="plain"> </span><span class="identifier">OUT</span><span class="plain">;</span>
<span class="plain">}</span>
</pre>
<p class="inwebparagraph"></p>
<p class="endnote">The function Renderer::render_block is used in 2/rr (<a href="2-rr.html#SP3_3">&#167;3.3</a>).</p>
<p class="inwebparagraph"><a id="SP9_1"></a><b>&#167;9.1. </b><code class="display">
&lt;<span class="cwebmacrodefn">Render the examples below the text of the block</span> <span class="cwebmacronumber">9.1</span>&gt; =
</code></p>
<pre class="displaydefn">
<span class="identifier">TEMPORARY_TEXT</span><span class="plain">(</span><span class="identifier">form_of_title_to_test</span><span class="plain">);</span>
&lt;<span class="cwebmacro">Adapt the block title to the form of the title to test</span> <span class="cwebmacronumber">9.1.1</span>&gt;<span class="plain">;</span>
<span class="reserved">int</span><span class="plain"> </span><span class="identifier">no_examples_rendered_here</span><span class="plain"> = 0;</span>
<span class="reserved">for</span><span class="plain"> (</span><span class="reserved">int</span><span class="plain"> </span><span class="identifier">n</span><span class="plain"> = 0; </span><span class="identifier">n</span><span class="plain"> &lt; </span><span class="identifier">no_examples</span><span class="plain">; </span><span class="identifier">n</span><span class="plain">++) {</span>
<span class="reserved">example</span><span class="plain"> *</span><span class="identifier">E</span><span class="plain"> = </span><span class="identifier">V</span><span class="plain">-</span><span class="element">&gt;examples_sequence</span><span class="plain">[</span><span class="identifier">n</span><span class="plain">];</span>
<span class="reserved">if</span><span class="plain"> (</span><span class="identifier">E</span><span class="plain">-</span><span class="element">&gt;example_displayed_at_section</span><span class="plain">[</span><span class="identifier">V</span><span class="plain">-</span><span class="element">&gt;allocation_id</span><span class="plain">] == </span><span class="identifier">S</span><span class="plain">) {</span>
<span class="identifier">no_examples_rendered_here</span><span class="plain">++;</span>
<span class="reserved">if</span><span class="plain"> (</span><span class="identifier">no_examples_rendered_here</span><span class="plain"> == 1)</span>
<span class="functiontext">Nav::render_navigation_example_top</span><span class="plain">(</span><span class="identifier">OUT</span><span class="plain">, </span><span class="identifier">V</span><span class="plain">, </span><span class="identifier">S</span><span class="plain">);</span>
&lt;<span class="cwebmacro">Render the example here</span> <span class="cwebmacronumber">9.1.2</span>&gt;<span class="plain">;</span>
<span class="reserved">if</span><span class="plain"> (</span><span class="identifier">indoc_settings</span><span class="plain">-</span><span class="element">&gt;examples_mode</span><span class="plain"> == </span><span class="constant">EXMODE_open_internal</span><span class="plain">) </span><span class="functiontext">HTMLUtilities::ruled_line</span><span class="plain">(</span><span class="identifier">OUT</span><span class="plain">);</span>
<span class="plain">}</span>
<span class="plain">}</span>
<span class="reserved">if</span><span class="plain"> (</span><span class="identifier">no_examples_rendered_here</span><span class="plain"> &gt; 0)</span>
<span class="functiontext">Nav::render_navigation_example_bottom</span><span class="plain">(</span><span class="identifier">OUT</span><span class="plain">, </span><span class="identifier">V</span><span class="plain">, </span><span class="identifier">S</span><span class="plain">);</span>
</pre>
<p class="inwebparagraph"></p>
<p class="endnote">This code is used in <a href="#SP9">&#167;9</a>.</p>
<p class="inwebparagraph"><a id="SP9_1_1"></a><b>&#167;9.1.1. </b>Examples need to connect with particular sections of documentation, but
they do so by title, not by block number, to protect them from renumbering
as sections are added or removed. So if the current block is called
</p>
<p class="inwebparagraph"></p>
<pre class="display">
<span class="plain">2.3. Sailing Ships</span>
</pre>
<p class="inwebparagraph">then we need to look for the text <code class="display"><span class="extract">Sailing Ships</span></code> to see if an example
belongs here. (But, owing to a historical accident, in the Recipe Book
section names are capitalised for this purpose.)
</p>
<p class="macrodefinition"><code class="display">
&lt;<span class="cwebmacrodefn">Adapt the block title to the form of the title to test</span> <span class="cwebmacronumber">9.1.1</span>&gt; =
</code></p>
<pre class="displaydefn">
<span class="functiontext">Str::copy</span><span class="plain">(</span><span class="identifier">form_of_title_to_test</span><span class="plain">, </span><span class="identifier">S</span><span class="plain">-</span><span class="element">&gt;unlabelled_title</span><span class="plain">);</span>
<span class="reserved">match_results</span><span class="plain"> </span><span class="identifier">mr</span><span class="plain"> = </span><span class="functiontext">Regexp::create_mr</span><span class="plain">();</span>
<span class="reserved">if</span><span class="plain"> (</span><span class="functiontext">Regexp::match</span><span class="plain">(&amp;</span><span class="identifier">mr</span><span class="plain">, </span><span class="identifier">form_of_title_to_test</span><span class="plain">, </span><span class="identifier">L</span><span class="string">"(%d+.)* *(%c*)"</span><span class="plain">)) {</span>
<span class="functiontext">Str::copy</span><span class="plain">(</span><span class="identifier">form_of_title_to_test</span><span class="plain">, </span><span class="identifier">mr</span><span class="element">.exp</span><span class="plain">[1]); </span><span class="functiontext">Regexp::dispose_of</span><span class="plain">(&amp;</span><span class="identifier">mr</span><span class="plain">);</span>
<span class="plain">}</span>
<span class="reserved">if</span><span class="plain"> (</span><span class="identifier">V</span><span class="plain">-</span><span class="element">&gt;allocation_id</span><span class="plain"> == 1)</span>
<span class="identifier">LOOP_THROUGH_TEXT</span><span class="plain">(</span><span class="identifier">pos</span><span class="plain">, </span><span class="identifier">form_of_title_to_test</span><span class="plain">)</span>
<span class="functiontext">Str::put</span><span class="plain">(</span><span class="identifier">pos</span><span class="plain">, </span><span class="functiontext">Characters::toupper</span><span class="plain">(</span><span class="functiontext">Str::get</span><span class="plain">(</span><span class="identifier">pos</span><span class="plain">)));</span>
</pre>
<p class="inwebparagraph"></p>
<p class="endnote">This code is used in <a href="#SP9_1">&#167;9.1</a>.</p>
<p class="inwebparagraph"><a id="SP9_1_2"></a><b>&#167;9.1.2. </b><code class="display">
&lt;<span class="cwebmacrodefn">Render the example here</span> <span class="cwebmacronumber">9.1.2</span>&gt; =
</code></p>
<pre class="displaydefn">
<span class="identifier">TEMPORARY_TEXT</span><span class="plain">(</span><span class="identifier">index_term</span><span class="plain">);</span>
<span class="identifier">WRITE_TO</span><span class="plain">(</span><span class="identifier">index_term</span><span class="plain">, </span><span class="string">"%S=___=!example"</span><span class="plain">, </span><span class="identifier">E</span><span class="plain">-</span><span class="element">&gt;ex_public_name</span><span class="plain">);</span>
<span class="functiontext">Indexes::mark_index_term</span><span class="plain">(</span><span class="identifier">index_term</span><span class="plain">, </span><span class="identifier">V</span><span class="plain">, </span><span class="identifier">NULL</span><span class="plain">, </span><span class="identifier">NULL</span><span class="plain">, </span><span class="identifier">E</span><span class="plain">, </span><span class="identifier">NULL</span><span class="plain">, </span><span class="identifier">NULL</span><span class="plain">);</span>
<span class="identifier">DISCARD_TEXT</span><span class="plain">(</span><span class="identifier">index_term</span><span class="plain">);</span>
<span class="reserved">if</span><span class="plain"> (</span><span class="identifier">indoc_settings</span><span class="plain">-</span><span class="element">&gt;format</span><span class="plain"> == </span><span class="constant">HTML_FORMAT</span><span class="plain">) {</span>
<span class="identifier">TEMPORARY_TEXT</span><span class="plain">(</span><span class="identifier">comment</span><span class="plain">);</span>
<span class="identifier">WRITE_TO</span><span class="plain">(</span><span class="identifier">comment</span><span class="plain">, </span><span class="string">"START EXAMPLE \</span><span class="plain">"</span><span class="string">%d: %S\</span><span class="plain">"</span><span class="string"> \</span><span class="plain">"</span><span class="string">e%d\</span><span class="plain">"</span><span class="string">"</span><span class="plain">,</span>
<span class="identifier">E</span><span class="plain">-</span><span class="element">&gt;example_position</span><span class="plain">[0], </span><span class="identifier">E</span><span class="plain">-</span><span class="element">&gt;ex_public_name</span><span class="plain">, </span><span class="identifier">E</span><span class="plain">-</span><span class="element">&gt;allocation_id</span><span class="plain">);</span>
<span class="functiontext">HTML::comment</span><span class="plain">(</span><span class="identifier">OUT</span><span class="plain">, </span><span class="identifier">comment</span><span class="plain">);</span>
<span class="identifier">DISCARD_TEXT</span><span class="plain">(</span><span class="identifier">comment</span><span class="plain">);</span>
<span class="plain">}</span>
<span class="functiontext">Examples::render_example_cue</span><span class="plain">(</span><span class="identifier">OUT</span><span class="plain">, </span><span class="identifier">E</span><span class="plain">, </span><span class="identifier">V</span><span class="plain">, 0);</span>
<span class="identifier">code_example</span><span class="plain"> = </span><span class="identifier">E</span><span class="plain">;</span>
<span class="identifier">OUT</span><span class="plain"> = </span><span class="functiontext">Renderer::render_example_body</span><span class="plain">(</span><span class="identifier">OUT</span><span class="plain">, </span><span class="identifier">E</span><span class="plain">, </span><span class="identifier">V</span><span class="plain">, </span><span class="constant">TRUE</span><span class="plain">);</span>
<span class="identifier">code_example</span><span class="plain"> = </span><span class="identifier">NULL</span><span class="plain">;</span>
<span class="reserved">if</span><span class="plain"> (</span><span class="identifier">indoc_settings</span><span class="plain">-</span><span class="element">&gt;format</span><span class="plain"> == </span><span class="constant">HTML_FORMAT</span><span class="plain">) </span><span class="functiontext">HTML::comment</span><span class="plain">(</span><span class="identifier">OUT</span><span class="plain">, </span><span class="identifier">I</span><span class="string">"END EXAMPLE"</span><span class="plain">);</span>
</pre>
<p class="inwebparagraph"></p>
<p class="endnote">This code is used in <a href="#SP9_1">&#167;9.1</a>.</p>
<p class="inwebparagraph"><a id="SP10"></a><b>&#167;10. </b></p>
<pre class="display">
<span class="reserved">text_stream</span><span class="plain"> *</span><span class="functiontext">Renderer::render_example_body</span><span class="plain">(</span><span class="constant">OUTPUT_STREAM</span><span class="plain">, </span><span class="reserved">example</span><span class="plain"> *</span><span class="identifier">E</span><span class="plain">, </span><span class="reserved">volume</span><span class="plain"> *</span><span class="identifier">V</span><span class="plain">, </span><span class="reserved">int</span><span class="plain"> </span><span class="identifier">empty</span><span class="plain">) {</span>
<span class="reserved">int</span><span class="plain"> </span><span class="identifier">hide</span><span class="plain"> = </span><span class="constant">FALSE</span><span class="plain">;</span>
<span class="reserved">if</span><span class="plain"> (</span><span class="identifier">indoc_settings</span><span class="plain">-</span><span class="element">&gt;examples_mode</span><span class="plain"> == </span><span class="constant">EXMODE_openable_internal</span><span class="plain">) </span><span class="identifier">hide</span><span class="plain"> = </span><span class="constant">TRUE</span><span class="plain">;</span>
<span class="reserved">if</span><span class="plain"> (</span><span class="identifier">indoc_settings</span><span class="plain">-</span><span class="element">&gt;format</span><span class="plain"> == </span><span class="constant">HTML_FORMAT</span><span class="plain">) {</span>
<span class="identifier">TEMPORARY_TEXT</span><span class="plain">(</span><span class="identifier">id</span><span class="plain">);</span>
<span class="identifier">WRITE_TO</span><span class="plain">(</span><span class="identifier">id</span><span class="plain">, </span><span class="string">"example%d"</span><span class="plain">, </span><span class="identifier">E</span><span class="plain">-</span><span class="element">&gt;allocation_id</span><span class="plain">);</span>
<span class="functiontext">HTML::begin_div_with_class_and_id_S</span><span class="plain">(</span><span class="identifier">OUT</span><span class="plain">, </span><span class="identifier">I</span><span class="string">"egpanel"</span><span class="plain">, </span><span class="identifier">id</span><span class="plain">, </span><span class="identifier">hide</span><span class="plain">);</span>
<span class="plain">}</span>
<span class="identifier">OUT</span><span class="plain"> = </span><span class="functiontext">Rawtext::process_example_rawtext_file</span><span class="plain">(</span><span class="identifier">OUT</span><span class="plain">, </span><span class="identifier">V</span><span class="plain">, </span><span class="identifier">E</span><span class="plain">);</span>
<span class="reserved">if</span><span class="plain"> (</span><span class="identifier">indoc_settings</span><span class="plain">-</span><span class="element">&gt;format</span><span class="plain"> == </span><span class="constant">HTML_FORMAT</span><span class="plain">) {</span>
<span class="functiontext">HTML::end_div</span><span class="plain">(</span><span class="identifier">OUT</span><span class="plain">);</span>
<span class="reserved">if</span><span class="plain"> (</span><span class="identifier">empty</span><span class="plain">) { </span><span class="identifier">HTML_OPEN</span><span class="plain">(</span><span class="string">"p"</span><span class="plain">); </span><span class="identifier">HTML_CLOSE</span><span class="plain">(</span><span class="string">"p"</span><span class="plain">); }</span>
<span class="plain">}</span>
<span class="reserved">return</span><span class="plain"> </span><span class="identifier">OUT</span><span class="plain">;</span>
<span class="plain">}</span>
</pre>
<p class="inwebparagraph"></p>
<p class="endnote">The function Renderer::render_example_body is used in <a href="#SP9_1_2">&#167;9.1.2</a>.</p>
<p class="inwebparagraph"><a id="SP11"></a><b>&#167;11. Rendering text. </b>The actual contents of the buffer are rendered here, then:
</p>
<pre class="display">
<span class="reserved">text_stream</span><span class="plain"> *</span><span class="functiontext">Renderer::render_text_of_block</span><span class="plain">(</span><span class="constant">OUTPUT_STREAM</span><span class="plain">, </span><span class="reserved">volume</span><span class="plain"> *</span><span class="identifier">V</span><span class="plain">, </span><span class="reserved">section</span><span class="plain"> *</span><span class="identifier">S</span><span class="plain">) {</span>
<span class="reserved">if</span><span class="plain"> (</span><span class="identifier">indoc_settings</span><span class="plain">-</span><span class="element">&gt;format</span><span class="plain"> == </span><span class="constant">PLAIN_FORMAT</span><span class="plain">) </span>&lt;<span class="cwebmacro">Render the block buffer as plain text</span> <span class="cwebmacronumber">11.1</span>&gt;
<span class="reserved">else</span><span class="plain"> </span><span class="reserved">if</span><span class="plain"> (</span><span class="identifier">indoc_settings</span><span class="plain">-</span><span class="element">&gt;format</span><span class="plain"> == </span><span class="constant">HTML_FORMAT</span><span class="plain">) </span>&lt;<span class="cwebmacro">Render the block buffer as HTML</span> <span class="cwebmacronumber">11.2</span>&gt;<span class="plain">;</span>
<span class="reserved">return</span><span class="plain"> </span><span class="identifier">OUT</span><span class="plain">;</span>
<span class="plain">}</span>
</pre>
<p class="inwebparagraph"></p>
<p class="endnote">The function Renderer::render_text_of_block is used in <a href="#SP9">&#167;9</a>, 2/rr (<a href="2-rr.html#SP3_3">&#167;3.3</a>).</p>
<p class="inwebparagraph"><a id="SP11_1"></a><b>&#167;11.1. </b>Plain text is very plain indeed:
</p>
<p class="macrodefinition"><code class="display">
&lt;<span class="cwebmacrodefn">Render the block buffer as plain text</span> <span class="cwebmacronumber">11.1</span>&gt; =
</code></p>
<pre class="displaydefn">
<span class="reserved">for</span><span class="plain"> (</span><span class="reserved">int</span><span class="plain"> </span><span class="identifier">i</span><span class="plain">=0; </span><span class="identifier">i</span><span class="plain">&lt;</span><span class="identifier">no_paras_in_block_buffer</span><span class="plain">; </span><span class="identifier">i</span><span class="plain">++) {</span>
<span class="comment">Indent using tabs</span>
<span class="reserved">int</span><span class="plain"> </span><span class="identifier">ic</span><span class="plain"> = </span><span class="identifier">paragraphs</span><span class="plain">[</span><span class="identifier">i</span><span class="plain">]</span><span class="element">.par_indentation</span><span class="plain">;</span>
<span class="reserved">while</span><span class="plain"> (</span><span class="identifier">ic</span><span class="plain"> &gt; 0) { </span><span class="identifier">ic</span><span class="plain">--; </span><span class="identifier">WRITE</span><span class="plain">(</span><span class="string">"\</span><span class="plain">t</span><span class="string">"</span><span class="plain">); }</span>
<span class="comment">Remove any paste markers entirely</span>
<span class="reserved">text_stream</span><span class="plain"> *</span><span class="identifier">raw</span><span class="plain"> = </span><span class="identifier">paragraphs</span><span class="plain">[</span><span class="identifier">i</span><span class="plain">]</span><span class="element">.par_texts</span><span class="plain">;</span>
<span class="reserved">match_results</span><span class="plain"> </span><span class="identifier">mr</span><span class="plain"> = </span><span class="functiontext">Regexp::create_mr</span><span class="plain">();</span>
<span class="reserved">if</span><span class="plain"> ((</span><span class="identifier">indoc_settings</span><span class="plain">-</span><span class="element">&gt;treat_code_as_verbatim</span><span class="plain"> == </span><span class="constant">FALSE</span><span class="plain">) &amp;&amp;</span>
<span class="plain">(</span><span class="functiontext">Regexp::match</span><span class="plain">(&amp;</span><span class="identifier">mr</span><span class="plain">, </span><span class="identifier">raw</span><span class="plain">, </span><span class="identifier">L</span><span class="string">"{%*+} *(%c*)"</span><span class="plain">)))</span>
<span class="identifier">WRITE</span><span class="plain">(</span><span class="string">"%S\</span><span class="plain">n</span><span class="string">"</span><span class="plain">, </span><span class="identifier">mr</span><span class="element">.exp</span><span class="plain">[0]);</span>
<span class="reserved">else</span>
<span class="identifier">WRITE</span><span class="plain">(</span><span class="string">"%S\</span><span class="plain">n</span><span class="string">"</span><span class="plain">, </span><span class="identifier">raw</span><span class="plain">);</span>
<span class="functiontext">Regexp::dispose_of</span><span class="plain">(&amp;</span><span class="identifier">mr</span><span class="plain">);</span>
<span class="plain">}</span>
</pre>
<p class="inwebparagraph"></p>
<p class="endnote">This code is used in <a href="#SP11">&#167;11</a>.</p>
<p class="inwebparagraph"><a id="SP11_2"></a><b>&#167;11.2. </b>HTML is more work:
</p>
<p class="macrodefinition"><code class="display">
&lt;<span class="cwebmacrodefn">Render the block buffer as HTML</span> <span class="cwebmacronumber">11.2</span>&gt; =
</code></p>
<pre class="displaydefn">
<span class="reserved">int</span><span class="plain"> </span><span class="identifier">code_mode</span><span class="plain"> = </span><span class="constant">FALSE</span><span class="plain">;</span>
<span class="reserved">int</span><span class="plain"> </span><span class="identifier">tabular_mode</span><span class="plain"> = </span><span class="constant">FALSE</span><span class="plain">;</span>
<span class="reserved">int</span><span class="plain"> </span><span class="identifier">last_xref_type</span><span class="plain"> = 0; </span> <span class="comment">0 means "none"; 1 means "to section"; 2 means "to example"</span>
<span class="reserved">for</span><span class="plain"> (</span><span class="reserved">int</span><span class="plain"> </span><span class="identifier">i</span><span class="plain">=0; </span><span class="identifier">i</span><span class="plain">&lt;</span><span class="identifier">no_paras_in_block_buffer</span><span class="plain">; </span><span class="identifier">i</span><span class="plain">++) {</span>
<span class="reserved">paragraph</span><span class="plain"> *</span><span class="identifier">P</span><span class="plain"> = &amp;(</span><span class="identifier">paragraphs</span><span class="plain">[</span><span class="identifier">i</span><span class="plain">]);</span>
<span class="reserved">if</span><span class="plain"> (</span><span class="identifier">P</span><span class="plain">-</span><span class="element">&gt;par_indentation</span><span class="plain"> == 0) {</span>
<span class="reserved">if</span><span class="plain"> (</span><span class="identifier">tabular_mode</span><span class="plain">) </span>&lt;<span class="cwebmacro">Exit tabular mode</span> <span class="cwebmacronumber">11.2.6</span>&gt;<span class="plain">;</span>
<span class="reserved">if</span><span class="plain"> (</span><span class="identifier">code_mode</span><span class="plain">) </span>&lt;<span class="cwebmacro">Exit code mode</span> <span class="cwebmacronumber">11.2.3</span>&gt;<span class="plain">;</span>
&lt;<span class="cwebmacro">Look for cross-references and then render</span> <span class="cwebmacronumber">11.2.7</span>&gt;<span class="plain">;</span>
<span class="plain">} </span><span class="reserved">else</span><span class="plain"> {</span>
<span class="reserved">if</span><span class="plain"> (</span><span class="identifier">tabular_mode</span><span class="plain"> == </span><span class="constant">FALSE</span><span class="plain">) {</span>
<span class="reserved">if</span><span class="plain"> (</span><span class="identifier">code_mode</span><span class="plain"> == </span><span class="constant">FALSE</span><span class="plain">) </span>&lt;<span class="cwebmacro">Enter code mode</span> <span class="cwebmacronumber">11.2.1</span>&gt;
<span class="reserved">else</span><span class="plain"> </span><span class="identifier">HTML_TAG</span><span class="plain">(</span><span class="string">"br"</span><span class="plain">);</span>
<span class="reserved">if</span><span class="plain"> (</span><span class="functiontext">Regexp::match</span><span class="plain">(</span><span class="identifier">NULL</span><span class="plain">, </span><span class="identifier">P</span><span class="plain">-</span><span class="element">&gt;par_texts</span><span class="plain">, </span><span class="identifier">L</span><span class="string">"%c*%C\</span><span class="plain">t</span><span class="string">+%C%c*"</span><span class="plain">))</span>
&lt;<span class="cwebmacro">Enter tabular mode</span> <span class="cwebmacronumber">11.2.4</span>&gt;<span class="plain">;</span>
<span class="plain">}</span>
<span class="reserved">if</span><span class="plain"> (</span><span class="identifier">tabular_mode</span><span class="plain">)</span>
&lt;<span class="cwebmacro">Render the tab-divided line as an HTML table row</span> <span class="cwebmacronumber">11.2.5</span>&gt;
<span class="reserved">else</span>
&lt;<span class="cwebmacro">Render the line in code mode</span> <span class="cwebmacronumber">11.2.2</span>&gt;<span class="plain">;</span>
<span class="plain">}</span>
<span class="plain">}</span>
<span class="reserved">if</span><span class="plain"> (</span><span class="identifier">tabular_mode</span><span class="plain">) </span>&lt;<span class="cwebmacro">Exit tabular mode</span> <span class="cwebmacronumber">11.2.6</span>&gt;<span class="plain">;</span>
<span class="reserved">if</span><span class="plain"> (</span><span class="identifier">code_mode</span><span class="plain">) </span>&lt;<span class="cwebmacro">Exit code mode</span> <span class="cwebmacronumber">11.2.3</span>&gt;<span class="plain">;</span>
</pre>
<p class="inwebparagraph"></p>
<p class="endnote">This code is used in <a href="#SP11">&#167;11</a>.</p>
<p class="inwebparagraph"><a id="SP11_2_1"></a><b>&#167;11.2.1. Code mode. </b>Code mode is when the renderer is working on a displayed quotation of source
code, broken off from the main narrative.
</p>
<p class="macrodefinition"><code class="display">
&lt;<span class="cwebmacrodefn">Enter code mode</span> <span class="cwebmacronumber">11.2.1</span>&gt; =
</code></p>
<pre class="displaydefn">
<span class="identifier">code_mode</span><span class="plain"> = 1;</span>
<span class="identifier">TEMPORARY_TEXT</span><span class="plain">(</span><span class="identifier">id</span><span class="plain">);</span>
<span class="identifier">WRITE_TO</span><span class="plain">(</span><span class="identifier">id</span><span class="plain">, </span><span class="string">"c%d"</span><span class="plain">, ++</span><span class="identifier">unique_code_pos_counter</span><span class="plain">);</span>
<span class="reserved">if</span><span class="plain"> (</span><span class="identifier">code_example</span><span class="plain">) </span><span class="identifier">WRITE_TO</span><span class="plain">(</span><span class="identifier">id</span><span class="plain">, </span><span class="string">"_%d"</span><span class="plain">, </span><span class="identifier">code_example</span><span class="plain">-</span><span class="element">&gt;allocation_id</span><span class="plain">);</span>
<span class="identifier">TEMPORARY_TEXT</span><span class="plain">(</span><span class="identifier">comment</span><span class="plain">);</span>
<span class="identifier">WRITE_TO</span><span class="plain">(</span><span class="identifier">comment</span><span class="plain">, </span><span class="string">"START CODE \</span><span class="plain">"</span><span class="string">%S\</span><span class="plain">"</span><span class="string">"</span><span class="plain">, </span><span class="identifier">id</span><span class="plain">);</span>
<span class="functiontext">HTML::comment</span><span class="plain">(</span><span class="identifier">OUT</span><span class="plain">, </span><span class="identifier">comment</span><span class="plain">);</span>
<span class="identifier">DISCARD_TEXT</span><span class="plain">(</span><span class="identifier">comment</span><span class="plain">);</span>
<span class="identifier">HTML_OPEN_WITH</span><span class="plain">(</span><span class="string">"blockquote"</span><span class="plain">, </span><span class="string">"class=\</span><span class="plain">"</span><span class="string">code\</span><span class="plain">"</span><span class="string">"</span><span class="plain">);</span>
<span class="identifier">HTML_OPEN_WITH</span><span class="plain">(</span><span class="string">"p"</span><span class="plain">, </span><span class="string">"class=\</span><span class="plain">"</span><span class="string">quoted\</span><span class="plain">"</span><span class="string">"</span><span class="plain">);</span>
<span class="functiontext">HTML::anchor</span><span class="plain">(</span><span class="identifier">OUT</span><span class="plain">, </span><span class="identifier">id</span><span class="plain">);</span>
</pre>
<p class="inwebparagraph"></p>
<p class="endnote">This code is used in <a href="#SP11_2">&#167;11.2</a>.</p>
<p class="inwebparagraph"><a id="SP11_2_2"></a><b>&#167;11.2.2. </b>Quoted code is pretty well passed through in raw form, except for Javascript
paste markers, which occupy a lot of code below but don't actually come up
very much.
</p>
<p class="macrodefinition"><code class="display">
&lt;<span class="cwebmacrodefn">Render the line in code mode</span> <span class="cwebmacronumber">11.2.2</span>&gt; =
</code></p>
<pre class="displaydefn">
&lt;<span class="cwebmacro">Render some indentation</span> <span class="cwebmacronumber">11.2.2.1</span>&gt;<span class="plain">;</span>
<span class="identifier">TEMPORARY_TEXT</span><span class="plain">(</span><span class="identifier">raw</span><span class="plain">);</span>
<span class="functiontext">Str::copy</span><span class="plain">(</span><span class="identifier">raw</span><span class="plain">, </span><span class="identifier">P</span><span class="plain">-</span><span class="element">&gt;par_texts</span><span class="plain">);</span>
<span class="reserved">if</span><span class="plain"> (</span><span class="identifier">indoc_settings</span><span class="plain">-</span><span class="element">&gt;treat_code_as_verbatim</span><span class="plain"> == </span><span class="constant">FALSE</span><span class="plain">) {</span>
<span class="functiontext">Regexp::replace</span><span class="plain">(</span><span class="identifier">raw</span><span class="plain">, </span><span class="identifier">L</span><span class="string">"{%*%*}"</span><span class="plain">, </span><span class="identifier">NULL</span><span class="plain">, </span><span class="constant">REP_REPEATING</span><span class="plain">); </span> <span class="comment">Remove any paste-continuation marker</span>
&lt;<span class="cwebmacro">Take note of any named inline example</span> <span class="cwebmacronumber">11.2.2.2</span>&gt;<span class="plain">;</span>
<span class="reserved">match_results</span><span class="plain"> </span><span class="identifier">mr</span><span class="plain"> = </span><span class="functiontext">Regexp::create_mr</span><span class="plain">();</span>
<span class="reserved">if</span><span class="plain"> (</span><span class="functiontext">Regexp::match</span><span class="plain">(&amp;</span><span class="identifier">mr</span><span class="plain">, </span><span class="identifier">raw</span><span class="plain">, </span><span class="identifier">L</span><span class="string">"(%c*?){%*}(%c*)"</span><span class="plain">)) {</span>
&lt;<span class="cwebmacro">Convert this paste marker to a Javascript paste mechanism</span> <span class="cwebmacronumber">11.2.2.3</span>&gt;<span class="plain">;</span>
<span class="functiontext">Regexp::dispose_of</span><span class="plain">(&amp;</span><span class="identifier">mr</span><span class="plain">);</span>
<span class="plain">}</span>
<span class="plain">}</span>
<span class="identifier">WRITE</span><span class="plain">(</span><span class="string">"%S\</span><span class="plain">n</span><span class="string">"</span><span class="plain">, </span><span class="identifier">raw</span><span class="plain">);</span>
</pre>
<p class="inwebparagraph"></p>
<p class="endnote">This code is used in <a href="#SP11_2">&#167;11.2</a>.</p>
<p class="inwebparagraph"><a id="SP11_2_2_1"></a><b>&#167;11.2.2.1. </b>A distinctly olde-worlde way to indent.
</p>
<p class="macrodefinition"><code class="display">
&lt;<span class="cwebmacrodefn">Render some indentation</span> <span class="cwebmacronumber">11.2.2.1</span>&gt; =
</code></p>
<pre class="displaydefn">
<span class="reserved">int</span><span class="plain"> </span><span class="identifier">ic</span><span class="plain"> = </span><span class="identifier">P</span><span class="plain">-</span><span class="element">&gt;par_indentation</span><span class="plain">;</span>
<span class="reserved">while</span><span class="plain"> (</span><span class="identifier">ic</span><span class="plain"> &gt; 1) { </span><span class="identifier">ic</span><span class="plain">--; </span><span class="identifier">WRITE</span><span class="plain">(</span><span class="string">"&amp;#160;&amp;#160;&amp;#160;&amp;#160;"</span><span class="plain">); }</span>
</pre>
<p class="inwebparagraph"></p>
<p class="endnote">This code is used in <a href="#SP11_2_2">&#167;11.2.2</a>.</p>
<p class="inwebparagraph"><a id="SP11_2_2_2"></a><b>&#167;11.2.2.2. </b><code class="display">
&lt;<span class="cwebmacrodefn">Take note of any named inline example</span> <span class="cwebmacronumber">11.2.2.2</span>&gt; =
</code></p>
<pre class="displaydefn">
<span class="reserved">match_results</span><span class="plain"> </span><span class="identifier">mr</span><span class="plain"> = </span><span class="functiontext">Regexp::create_mr</span><span class="plain">();</span>
<span class="reserved">if</span><span class="plain"> ((</span><span class="identifier">index_to_examples</span><span class="plain">) &amp;&amp;</span>
<span class="plain">(</span><span class="functiontext">Regexp::match</span><span class="plain">(&amp;</span><span class="identifier">mr</span><span class="plain">, </span><span class="identifier">raw</span><span class="plain">, </span><span class="identifier">L</span><span class="string">"{%*}&amp;quot;(%c*)&amp;quot;%c*"</span><span class="plain">)) &amp;&amp;</span>
<span class="plain">(</span><span class="functiontext">Str::ne_wide_string</span><span class="plain">(</span><span class="identifier">mr</span><span class="element">.exp</span><span class="plain">[0], </span><span class="identifier">L</span><span class="string">"Midsummer Day"</span><span class="plain">))) {</span>
<span class="functiontext">ExamplesIndex::add_to_alphabetic_examples_index</span><span class="plain">(</span><span class="identifier">mr</span><span class="element">.exp</span><span class="plain">[0], </span><span class="identifier">S</span><span class="plain">, </span><span class="identifier">NULL</span><span class="plain">, </span><span class="constant">TRUE</span><span class="plain">, </span><span class="constant">FALSE</span><span class="plain">);</span>
<span class="functiontext">Regexp::dispose_of</span><span class="plain">(&amp;</span><span class="identifier">mr</span><span class="plain">);</span>
<span class="plain">}</span>
</pre>
<p class="inwebparagraph"></p>
<p class="endnote">This code is used in <a href="#SP11_2_2">&#167;11.2.2</a>.</p>
<p class="inwebparagraph"><a id="SP11_2_3"></a><b>&#167;11.2.3. </b><code class="display">
&lt;<span class="cwebmacrodefn">Exit code mode</span> <span class="cwebmacronumber">11.2.3</span>&gt; =
</code></p>
<pre class="displaydefn">
<span class="identifier">code_mode</span><span class="plain"> = </span><span class="constant">FALSE</span><span class="plain">;</span>
<span class="identifier">HTML_CLOSE</span><span class="plain">(</span><span class="string">"p"</span><span class="plain">);</span>
<span class="identifier">HTML_CLOSE</span><span class="plain">(</span><span class="string">"blockquote"</span><span class="plain">);</span>
<span class="functiontext">HTML::comment</span><span class="plain">(</span><span class="identifier">OUT</span><span class="plain">, </span><span class="identifier">I</span><span class="string">"END CODE"</span><span class="plain">);</span>
</pre>
<p class="inwebparagraph"></p>
<p class="endnote">This code is used in <a href="#SP11_2">&#167;11.2</a> (twice).</p>
<p class="inwebparagraph"><a id="SP11_2_4"></a><b>&#167;11.2.4. Tabular mode. </b>Tabular mode is not an alternative to code mode: it's a deeper mode within
it, and is used for a display of I7 source text (i.e., code) when it needs
to show a Table.
</p>
<p class="macrodefinition"><code class="display">
&lt;<span class="cwebmacrodefn">Enter tabular mode</span> <span class="cwebmacronumber">11.2.4</span>&gt; =
</code></p>
<pre class="displaydefn">
<span class="identifier">tabular_mode</span><span class="plain"> = </span><span class="constant">TRUE</span><span class="plain">;</span>
<span class="identifier">HTML_CLOSE</span><span class="plain">(</span><span class="string">"p"</span><span class="plain">);</span>
<span class="identifier">HTML_CLOSE</span><span class="plain">(</span><span class="string">"blockquote"</span><span class="plain">);</span>
<span class="identifier">HTML_OPEN_WITH</span><span class="plain">(</span><span class="string">"table"</span><span class="plain">, </span><span class="string">"class=\</span><span class="plain">"</span><span class="string">codetable\</span><span class="plain">"</span><span class="string">"</span><span class="plain">);</span>
</pre>
<p class="inwebparagraph"></p>
<p class="endnote">This code is used in <a href="#SP11_2">&#167;11.2</a>.</p>
<p class="inwebparagraph"><a id="SP11_2_5"></a><b>&#167;11.2.5. </b>Within tabular mode, the following renders lines.
</p>
<p class="inwebparagraph">Note that any run of one or more tabs is treated as a single column
division, and that leading or trailing tabs are ignored &mdash; so there is no
way to code for an entirely empty cell. (This is fine for Inform documentation
purposes since the only empty cells are trailing ones in the line anyway;
people use the blank marker <code class="display"><span class="extract">--</span></code> explicitly if they want blanks.)
</p>
<p class="macrodefinition"><code class="display">
&lt;<span class="cwebmacrodefn">Render the tab-divided line as an HTML table row</span> <span class="cwebmacronumber">11.2.5</span>&gt; =
</code></p>
<pre class="displaydefn">
<span class="identifier">HTML_OPEN</span><span class="plain">(</span><span class="string">"tr"</span><span class="plain">);</span>
<span class="identifier">HTML_OPEN_WITH</span><span class="plain">(</span><span class="string">"td"</span><span class="plain">, </span><span class="string">"class=\</span><span class="plain">"</span><span class="string">quotedtablecell\</span><span class="plain">"</span><span class="string">"</span><span class="plain">);</span>
<span class="identifier">HTML_OPEN_WITH</span><span class="plain">(</span><span class="string">"p"</span><span class="plain">, </span><span class="string">"class=\</span><span class="plain">"</span><span class="string">quoted\</span><span class="plain">"</span><span class="string">"</span><span class="plain">);</span>
<span class="identifier">TEMPORARY_TEXT</span><span class="plain">(</span><span class="identifier">row</span><span class="plain">);</span>
<span class="reserved">match_results</span><span class="plain"> </span><span class="identifier">mr</span><span class="plain"> = </span><span class="functiontext">Regexp::create_mr</span><span class="plain">();</span>
<span class="functiontext">Regexp::match</span><span class="plain">(&amp;</span><span class="identifier">mr</span><span class="plain">, </span><span class="identifier">P</span><span class="plain">-</span><span class="element">&gt;par_texts</span><span class="plain">, </span><span class="identifier">L</span><span class="string">" *(%c*?) *"</span><span class="plain">);</span>
<span class="functiontext">Str::copy</span><span class="plain">(</span><span class="identifier">row</span><span class="plain">, </span><span class="identifier">mr</span><span class="element">.exp</span><span class="plain">[0]); </span> <span class="comment">Strip leading and trailing space</span>
<span class="reserved">while</span><span class="plain"> (</span><span class="functiontext">Regexp::match</span><span class="plain">(&amp;</span><span class="identifier">mr</span><span class="plain">, </span><span class="identifier">row</span><span class="plain">, </span><span class="identifier">L</span><span class="string">"(%c*?)\</span><span class="plain">t</span><span class="string">+(%c*)"</span><span class="plain">)) {</span>
<span class="identifier">WRITE</span><span class="plain">(</span><span class="string">"%S"</span><span class="plain">, </span><span class="identifier">mr</span><span class="element">.exp</span><span class="plain">[0]); </span> <span class="comment">Place a cell division at any run of one or more tabs</span>
<span class="identifier">HTML_CLOSE</span><span class="plain">(</span><span class="string">"p"</span><span class="plain">);</span>
<span class="identifier">HTML_CLOSE</span><span class="plain">(</span><span class="string">"td"</span><span class="plain">);</span>
<span class="identifier">HTML_OPEN_WITH</span><span class="plain">(</span><span class="string">"td"</span><span class="plain">, </span><span class="string">"class=\</span><span class="plain">"</span><span class="string">quotedtablecell\</span><span class="plain">"</span><span class="string">"</span><span class="plain">);</span>
<span class="identifier">HTML_OPEN_WITH</span><span class="plain">(</span><span class="string">"p"</span><span class="plain">, </span><span class="string">"class=\</span><span class="plain">"</span><span class="string">quoted\</span><span class="plain">"</span><span class="string">"</span><span class="plain">);</span>
<span class="functiontext">Str::copy</span><span class="plain">(</span><span class="identifier">row</span><span class="plain">, </span><span class="identifier">mr</span><span class="element">.exp</span><span class="plain">[1]);</span>
<span class="plain">}</span>
<span class="identifier">WRITE</span><span class="plain">(</span><span class="string">"%S"</span><span class="plain">, </span><span class="identifier">row</span><span class="plain">);</span>
<span class="identifier">DISCARD_TEXT</span><span class="plain">(</span><span class="identifier">row</span><span class="plain">);</span>
<span class="functiontext">Regexp::dispose_of</span><span class="plain">(&amp;</span><span class="identifier">mr</span><span class="plain">);</span>
<span class="identifier">HTML_CLOSE</span><span class="plain">(</span><span class="string">"p"</span><span class="plain">);</span>
<span class="identifier">HTML_CLOSE</span><span class="plain">(</span><span class="string">"td"</span><span class="plain">);</span>
<span class="identifier">HTML_CLOSE</span><span class="plain">(</span><span class="string">"tr"</span><span class="plain">);</span>
</pre>
<p class="inwebparagraph"></p>
<p class="endnote">This code is used in <a href="#SP11_2">&#167;11.2</a>.</p>
<p class="inwebparagraph"><a id="SP11_2_6"></a><b>&#167;11.2.6. </b><code class="display">
&lt;<span class="cwebmacrodefn">Exit tabular mode</span> <span class="cwebmacronumber">11.2.6</span>&gt; =
</code></p>
<pre class="displaydefn">
<span class="identifier">tabular_mode</span><span class="plain"> = </span><span class="constant">FALSE</span><span class="plain">;</span>
<span class="identifier">HTML_CLOSE</span><span class="plain">(</span><span class="string">"table"</span><span class="plain">);</span>
<span class="identifier">HTML_OPEN</span><span class="plain">(</span><span class="string">"blockquote"</span><span class="plain">);</span>
<span class="identifier">HTML_OPEN</span><span class="plain">(</span><span class="string">"p"</span><span class="plain">);</span>
</pre>
<p class="inwebparagraph"></p>
<p class="endnote">This code is used in <a href="#SP11_2">&#167;11.2</a> (twice).</p>
<p class="inwebparagraph"><a id="SP11_2_7"></a><b>&#167;11.2.7. Regular mode. </b>So this is what happens when we're not in either tabular or code mode.
</p>
<p class="inwebparagraph">The foot of a block of documentation sometimes contains cross-references
to other blocks (resolved by name), and this is where we recognise and
convert those to HTML links.
</p>
<p class="macrodefinition"><code class="display">
&lt;<span class="cwebmacrodefn">Look for cross-references and then render</span> <span class="cwebmacronumber">11.2.7</span>&gt; =
</code></p>
<pre class="displaydefn">
<span class="reserved">match_results</span><span class="plain"> </span><span class="identifier">mr</span><span class="plain"> = </span><span class="functiontext">Regexp::create_mr</span><span class="plain">();</span>
<span class="reserved">if</span><span class="plain"> (</span><span class="functiontext">Regexp::match</span><span class="plain">(&amp;</span><span class="identifier">mr</span><span class="plain">, </span><span class="identifier">P</span><span class="plain">-</span><span class="element">&gt;par_texts</span><span class="plain">, </span><span class="identifier">L</span><span class="string">"%((-*)See {(%c*?)} for (%c*?).%) *"</span><span class="plain">)) {</span>
<span class="reserved">if</span><span class="plain"> (</span><span class="functiontext">Str::len</span><span class="plain">(</span><span class="identifier">mr</span><span class="element">.exp</span><span class="plain">[0]) == 0) {</span>
<span class="functiontext">Renderer::render_cross_reference</span><span class="plain">(</span><span class="identifier">OUT</span><span class="plain">, </span><span class="identifier">mr</span><span class="element">.exp</span><span class="plain">[1], </span><span class="identifier">mr</span><span class="element">.exp</span><span class="plain">[2], </span><span class="identifier">V</span><span class="plain">, 0);</span>
<span class="plain">} </span><span class="reserved">else</span><span class="plain"> {</span>
<span class="reserved">if</span><span class="plain"> (</span><span class="identifier">last_xref_type</span><span class="plain"> == 0) { </span><span class="identifier">HTML_TAG</span><span class="plain">(</span><span class="string">"hr"</span><span class="plain">); }</span>
<span class="functiontext">Renderer::render_cross_reference</span><span class="plain">(</span><span class="identifier">OUT</span><span class="plain">, </span><span class="identifier">mr</span><span class="element">.exp</span><span class="plain">[1], </span><span class="identifier">mr</span><span class="element">.exp</span><span class="plain">[2], </span><span class="identifier">V</span><span class="plain">, 1);</span>
<span class="plain">}</span>
<span class="identifier">last_xref_type</span><span class="plain"> = 1;</span>
<span class="plain">} </span><span class="reserved">else</span><span class="plain"> </span><span class="reserved">if</span><span class="plain"> (</span><span class="functiontext">Regexp::match</span><span class="plain">(&amp;</span><span class="identifier">mr</span><span class="plain">, </span><span class="identifier">P</span><span class="plain">-</span><span class="element">&gt;par_texts</span><span class="plain">, </span><span class="identifier">L</span><span class="string">"%((-*)See (%c*?) for (%c*?).%) *"</span><span class="plain">)) {</span>
<span class="reserved">if</span><span class="plain"> (</span><span class="functiontext">Str::len</span><span class="plain">(</span><span class="identifier">mr</span><span class="element">.exp</span><span class="plain">[0]) == 0) {</span>
<span class="functiontext">Renderer::render_cross_reference</span><span class="plain">(</span><span class="identifier">OUT</span><span class="plain">, </span><span class="identifier">mr</span><span class="element">.exp</span><span class="plain">[1], </span><span class="identifier">mr</span><span class="element">.exp</span><span class="plain">[2], </span><span class="identifier">V</span><span class="plain">, 0);</span>
<span class="plain">} </span><span class="reserved">else</span><span class="plain"> {</span>
<span class="reserved">if</span><span class="plain"> (</span><span class="identifier">last_xref_type</span><span class="plain"> == 0) { </span><span class="identifier">HTML_TAG</span><span class="plain">(</span><span class="string">"hr"</span><span class="plain">); }</span>
<span class="functiontext">Renderer::render_cross_reference</span><span class="plain">(</span><span class="identifier">OUT</span><span class="plain">, </span><span class="identifier">mr</span><span class="element">.exp</span><span class="plain">[1], </span><span class="identifier">mr</span><span class="element">.exp</span><span class="plain">[2], </span><span class="identifier">V</span><span class="plain">, 1);</span>
<span class="plain">}</span>
<span class="identifier">last_xref_type</span><span class="plain"> = 1;</span>
<span class="plain">} </span><span class="reserved">else</span><span class="plain"> </span><span class="reserved">if</span><span class="plain"> (</span><span class="functiontext">Regexp::match</span><span class="plain">(&amp;</span><span class="identifier">mr</span><span class="plain">, </span><span class="identifier">P</span><span class="plain">-</span><span class="element">&gt;par_texts</span><span class="plain">, </span><span class="identifier">L</span><span class="string">"%(See example &amp;quot;(%c*?)&amp;quot;%) *"</span><span class="plain">)) {</span>
<span class="reserved">if</span><span class="plain"> (</span><span class="identifier">last_xref_type</span><span class="plain"> == 1) { </span><span class="identifier">HTML_TAG</span><span class="plain">(</span><span class="string">"hr"</span><span class="plain">); }</span>
<span class="functiontext">Renderer::render_example_cross_reference</span><span class="plain">(</span><span class="identifier">OUT</span><span class="plain">, </span><span class="identifier">mr</span><span class="element">.exp</span><span class="plain">[0], </span><span class="identifier">V</span><span class="plain">);</span>
<span class="identifier">last_xref_type</span><span class="plain"> = 2;</span>
<span class="plain">} </span><span class="reserved">else</span><span class="plain"> </span>&lt;<span class="cwebmacro">Render a non-quotation paragraph to HTML</span> <span class="cwebmacronumber">11.2.7.1</span>&gt;<span class="plain">;</span>
<span class="functiontext">Regexp::dispose_of</span><span class="plain">(&amp;</span><span class="identifier">mr</span><span class="plain">);</span>
</pre>
<p class="inwebparagraph"></p>
<p class="endnote">This code is used in <a href="#SP11_2">&#167;11.2</a>.</p>
<p class="inwebparagraph"><a id="SP11_2_7_1"></a><b>&#167;11.2.7.1. </b>Blank lines are simply ignored.
</p>
<p class="macrodefinition"><code class="display">
&lt;<span class="cwebmacrodefn">Render a non-quotation paragraph to HTML</span> <span class="cwebmacronumber">11.2.7.1</span>&gt; =
</code></p>
<pre class="displaydefn">
<span class="reserved">if</span><span class="plain"> (</span><span class="functiontext">Regexp::match</span><span class="plain">(</span><span class="identifier">NULL</span><span class="plain">, </span><span class="identifier">P</span><span class="plain">-</span><span class="element">&gt;par_texts</span><span class="plain">, </span><span class="identifier">L</span><span class="string">" *"</span><span class="plain">) == </span><span class="constant">FALSE</span><span class="plain">) {</span>
<span class="identifier">WRITE</span><span class="plain">(</span><span class="string">"%S"</span><span class="plain">, </span><span class="identifier">P</span><span class="plain">-</span><span class="element">&gt;par_prefix</span><span class="plain">);</span>
<span class="reserved">if</span><span class="plain"> (</span><span class="identifier">P</span><span class="plain">-</span><span class="element">&gt;par_suppression</span><span class="plain"> == </span><span class="constant">TRUE</span><span class="plain">) {</span>
<span class="identifier">WRITE</span><span class="plain">(</span><span class="string">"%S\</span><span class="plain">n</span><span class="string">"</span><span class="plain">, </span><span class="identifier">P</span><span class="plain">-</span><span class="element">&gt;par_texts</span><span class="plain">);</span>
<span class="plain">} </span><span class="reserved">else</span><span class="plain"> {</span>
<span class="reserved">if</span><span class="plain"> (</span><span class="functiontext">Str::len</span><span class="plain">(</span><span class="identifier">P</span><span class="plain">-</span><span class="element">&gt;par_styles</span><span class="plain">) &gt; 0) {</span>
<span class="identifier">TEMPORARY_TEXT</span><span class="plain">(</span><span class="identifier">details</span><span class="plain">);</span>
<span class="identifier">WRITE_TO</span><span class="plain">(</span><span class="identifier">details</span><span class="plain">, </span><span class="string">"class=\</span><span class="plain">"</span><span class="string">%S\</span><span class="plain">"</span><span class="string">"</span><span class="plain">, </span><span class="identifier">P</span><span class="plain">-</span><span class="element">&gt;par_styles</span><span class="plain">);</span>
<span class="functiontext">HTML::open</span><span class="plain">(</span><span class="identifier">OUT</span><span class="plain">, </span><span class="string">"p"</span><span class="plain">, </span><span class="identifier">details</span><span class="plain">);</span>
<span class="identifier">DISCARD_TEXT</span><span class="plain">(</span><span class="identifier">details</span><span class="plain">);</span>
<span class="identifier">WRITE</span><span class="plain">(</span><span class="string">"%S"</span><span class="plain">, </span><span class="identifier">P</span><span class="plain">-</span><span class="element">&gt;par_texts</span><span class="plain">);</span>
<span class="identifier">HTML_CLOSE</span><span class="plain">(</span><span class="string">"p"</span><span class="plain">);</span>
<span class="plain">} </span><span class="reserved">else</span><span class="plain"> {</span>
<span class="identifier">HTML_OPEN</span><span class="plain">(</span><span class="string">"p"</span><span class="plain">);</span>
<span class="identifier">WRITE</span><span class="plain">(</span><span class="string">"%S"</span><span class="plain">, </span><span class="identifier">P</span><span class="plain">-</span><span class="element">&gt;par_texts</span><span class="plain">);</span>
<span class="identifier">HTML_CLOSE</span><span class="plain">(</span><span class="string">"p"</span><span class="plain">);</span>
<span class="plain">}</span>
<span class="plain">}</span>
<span class="plain">}</span>
</pre>
<p class="inwebparagraph"></p>
<p class="endnote">This code is used in <a href="#SP11_2_7">&#167;11.2.7</a>.</p>
<p class="inwebparagraph"><a id="SP11_2_2_3"></a><b>&#167;11.2.2.3. Javascript paste icons. </b>That's the whole rendering routine, except for the handling of Javascript
paste icons. In rawtext, these look like so:
</p>
<p class="inwebparagraph"></p>
<pre class="display">
<span class="plain"> {*}A useful sentence.</span>
</pre>
<p class="inwebparagraph">The <code class="display"><span class="extract">{*}</span></code> is replaced by a button which, when clicked on, performs a Javascript
function call to paste "A useful sentence" into the Inform application's
source text pane. (Note that the "A useful sentence" text is still also
rendered on screen &mdash; it doesn't vanish into the button.) These pastes
can occur only in code mode, and can extend for multiple lines, as we'll
see below.
</p>
<p class="macrodefinition"><code class="display">
&lt;<span class="cwebmacrodefn">Convert this paste marker to a Javascript paste mechanism</span> <span class="cwebmacronumber">11.2.2.3</span>&gt; =
</code></p>
<pre class="displaydefn">
<span class="functiontext">Str::copy</span><span class="plain">(</span><span class="identifier">raw</span><span class="plain">, </span><span class="identifier">mr</span><span class="element">.exp</span><span class="plain">[0]);</span>
<span class="identifier">TEMPORARY_TEXT</span><span class="plain">(</span><span class="identifier">right</span><span class="plain">);</span>
<span class="functiontext">Str::copy</span><span class="plain">(</span><span class="identifier">right</span><span class="plain">, </span><span class="identifier">mr</span><span class="element">.exp</span><span class="plain">[1]);</span>
<span class="reserved">if</span><span class="plain"> (</span><span class="identifier">indoc_settings</span><span class="plain">-</span><span class="element">&gt;javascript_paste_method</span><span class="plain"> == </span><span class="constant">PASTEMODE_none</span><span class="plain">) {</span>
<span class="identifier">WRITE_TO</span><span class="plain">(</span><span class="identifier">raw</span><span class="plain">, </span><span class="string">"%S"</span><span class="plain">, </span><span class="identifier">right</span><span class="plain">);</span>
<span class="plain">} </span><span class="reserved">else</span><span class="plain"> {</span>
<span class="identifier">WRITE_TO</span><span class="plain">(</span><span class="identifier">raw</span><span class="plain">, </span><span class="string">"&lt;a href=\</span><span class="plain">"</span><span class="string">javascript:pasteCode"</span><span class="plain">);</span>
<span class="reserved">if</span><span class="plain"> (</span><span class="identifier">indoc_settings</span><span class="plain">-</span><span class="element">&gt;javascript_paste_method</span><span class="plain"> == </span><span class="constant">PASTEMODE_David</span><span class="plain">) {</span>
<span class="identifier">Javascript_paste_count</span><span class="plain">++;</span>
<span class="identifier">WRITE_TO</span><span class="plain">(</span><span class="identifier">raw</span><span class="plain">, </span><span class="string">"%d"</span><span class="plain">, </span><span class="identifier">Javascript_paste_count</span><span class="plain">);</span>
<span class="plain">}</span>
<span class="identifier">WRITE_TO</span><span class="plain">(</span><span class="identifier">raw</span><span class="plain">, </span><span class="string">"("</span><span class="plain">);</span>
<span class="identifier">TEMPORARY_TEXT</span><span class="plain">(</span><span class="identifier">J_text</span><span class="plain">);</span>
&lt;<span class="cwebmacro">Determine the quoted J-text</span> <span class="cwebmacronumber">11.2.2.3.1</span>&gt;<span class="plain">;</span>
<span class="identifier">TEMPORARY_TEXT</span><span class="plain">(</span><span class="identifier">titling</span><span class="plain">);</span>
<span class="reserved">if</span><span class="plain"> (</span><span class="identifier">code_example</span><span class="plain">) {</span>
<span class="identifier">WRITE_TO</span><span class="plain">(</span><span class="identifier">titling</span><span class="plain">, </span><span class="string">"Example - "</span><span class="plain">);</span>
<span class="identifier">LOOP_THROUGH_TEXT</span><span class="plain">(</span><span class="identifier">pos</span><span class="plain">, </span><span class="identifier">code_example</span><span class="plain">-</span><span class="element">&gt;ex_public_name</span><span class="plain">) {</span>
<span class="reserved">int</span><span class="plain"> </span><span class="identifier">c</span><span class="plain"> = </span><span class="functiontext">Str::get</span><span class="plain">(</span><span class="identifier">pos</span><span class="plain">);</span>
<span class="reserved">if</span><span class="plain"> (</span><span class="identifier">c</span><span class="plain"> == </span><span class="character">'\</span><span class="plain">'</span><span class="character">'</span><span class="plain">) </span><span class="identifier">WRITE_TO</span><span class="plain">(</span><span class="identifier">titling</span><span class="plain">, </span><span class="string">"\</span><span class="plain">\</span><span class="string">'"</span><span class="plain">);</span>
<span class="reserved">else</span><span class="plain"> </span><span class="identifier">PUT_TO</span><span class="plain">(</span><span class="identifier">titling</span><span class="plain">, </span><span class="identifier">c</span><span class="plain">);</span>
<span class="plain">}</span>
<span class="plain">}</span>
<span class="functiontext">Renderer::apply_Inform_escape_characters</span><span class="plain">(</span><span class="identifier">titling</span><span class="plain">);</span>
<span class="reserved">if</span><span class="plain"> (</span><span class="identifier">indoc_settings</span><span class="plain">-</span><span class="element">&gt;javascript_paste_method</span><span class="plain"> == </span><span class="constant">PASTEMODE_Andrew</span><span class="plain">)</span>
<span class="identifier">WRITE_TO</span><span class="plain">(</span><span class="identifier">raw</span><span class="plain">, </span><span class="string">"'%S\</span><span class="plain">\</span><span class="string">n'"</span><span class="plain">, </span><span class="identifier">J_text</span><span class="plain">);</span>
<span class="identifier">WRITE_TO</span><span class="plain">(</span><span class="identifier">raw</span><span class="plain">, </span><span class="string">")\</span><span class="plain">"</span><span class="string">&gt;"</span><span class="plain">);</span>
<span class="reserved">if</span><span class="plain"> (</span><span class="identifier">indoc_settings</span><span class="plain">-</span><span class="element">&gt;retina_images</span><span class="plain">) </span><span class="functiontext">HTMLUtilities::image_element_scaled</span><span class="plain">(</span><span class="identifier">raw</span><span class="plain">, </span><span class="identifier">I</span><span class="string">"paste@2x.png"</span><span class="plain">, 13, 13);</span>
<span class="reserved">else</span><span class="plain"> </span><span class="functiontext">HTMLUtilities::image_element</span><span class="plain">(</span><span class="identifier">raw</span><span class="plain">, </span><span class="identifier">I</span><span class="string">"paste.png"</span><span class="plain">);</span>
<span class="identifier">WRITE_TO</span><span class="plain">(</span><span class="identifier">raw</span><span class="plain">, </span><span class="string">"&lt;/a&gt; "</span><span class="plain">);</span>
<span class="reserved">if</span><span class="plain"> ((</span><span class="identifier">indoc_settings</span><span class="plain">-</span><span class="element">&gt;support_creation</span><span class="plain">) &amp;&amp; (</span><span class="functiontext">Str::len</span><span class="plain">(</span><span class="identifier">titling</span><span class="plain">) &gt; 0)) {</span>
<span class="identifier">WRITE_TO</span><span class="plain">(</span><span class="identifier">raw</span><span class="plain">, </span><span class="string">"&lt;a href=\</span><span class="plain">"</span><span class="string">javascript:createNewProject"</span><span class="plain">);</span>
<span class="reserved">if</span><span class="plain"> (</span><span class="identifier">indoc_settings</span><span class="plain">-</span><span class="element">&gt;javascript_paste_method</span><span class="plain"> == </span><span class="constant">PASTEMODE_David</span><span class="plain">)</span>
<span class="identifier">WRITE_TO</span><span class="plain">(</span><span class="identifier">raw</span><span class="plain">, </span><span class="string">"%d"</span><span class="plain">, </span><span class="identifier">Javascript_paste_count</span><span class="plain">);</span>
<span class="identifier">WRITE_TO</span><span class="plain">(</span><span class="identifier">raw</span><span class="plain">, </span><span class="string">"("</span><span class="plain">);</span>
<span class="reserved">if</span><span class="plain"> (</span><span class="identifier">indoc_settings</span><span class="plain">-</span><span class="element">&gt;javascript_paste_method</span><span class="plain"> == </span><span class="constant">PASTEMODE_Andrew</span><span class="plain">)</span>
<span class="identifier">WRITE_TO</span><span class="plain">(</span><span class="identifier">raw</span><span class="plain">, </span><span class="string">"'%S\</span><span class="plain">\</span><span class="string">n', '%S'"</span><span class="plain">, </span><span class="identifier">J_text</span><span class="plain">, </span><span class="identifier">titling</span><span class="plain">);</span>
<span class="identifier">WRITE_TO</span><span class="plain">(</span><span class="identifier">raw</span><span class="plain">, </span><span class="string">")\</span><span class="plain">"</span><span class="string">&gt;"</span><span class="plain">);</span>
<span class="reserved">if</span><span class="plain"> (</span><span class="identifier">indoc_settings</span><span class="plain">-</span><span class="element">&gt;retina_images</span><span class="plain">) {</span>
<span class="functiontext">HTMLUtilities::image_element_scaled</span><span class="plain">(</span><span class="identifier">raw</span><span class="plain">, </span><span class="identifier">I</span><span class="string">"create@2x.png"</span><span class="plain">, 26, 13);</span>
<span class="plain">} </span><span class="reserved">else</span><span class="plain"> {</span>
<span class="functiontext">HTMLUtilities::image_element</span><span class="plain">(</span><span class="identifier">raw</span><span class="plain">, </span><span class="identifier">I</span><span class="string">"create.png"</span><span class="plain">);</span>
<span class="plain">}</span>
<span class="identifier">WRITE_TO</span><span class="plain">(</span><span class="identifier">raw</span><span class="plain">, </span><span class="string">"&lt;/a&gt;"</span><span class="plain">);</span>
<span class="identifier">WRITE_TO</span><span class="plain">(</span><span class="identifier">raw</span><span class="plain">, </span><span class="string">"&amp;nbsp;&amp;nbsp; "</span><span class="plain">);</span>
<span class="plain">}</span>
<span class="identifier">WRITE_TO</span><span class="plain">(</span><span class="identifier">raw</span><span class="plain">, </span><span class="string">"%S"</span><span class="plain">, </span><span class="identifier">right</span><span class="plain">);</span>
<span class="reserved">if</span><span class="plain"> ((</span><span class="identifier">indoc_settings</span><span class="plain">-</span><span class="element">&gt;javascript</span><span class="plain">) &amp;&amp;</span>
<span class="plain">(</span><span class="identifier">indoc_settings</span><span class="plain">-</span><span class="element">&gt;javascript_paste_method</span><span class="plain"> == </span><span class="constant">PASTEMODE_David</span><span class="plain">)) {</span>
<span class="functiontext">HTMLUtilities::paste_script</span><span class="plain">(</span><span class="identifier">OUT</span><span class="plain">, </span><span class="identifier">J_text</span><span class="plain">, </span><span class="identifier">Javascript_paste_count</span><span class="plain">);</span>
<span class="functiontext">HTMLUtilities::create_script</span><span class="plain">(</span><span class="identifier">OUT</span><span class="plain">, </span><span class="identifier">J_text</span><span class="plain">, </span><span class="identifier">Javascript_paste_count</span><span class="plain">, </span><span class="identifier">titling</span><span class="plain">);</span>
<span class="plain">}</span>
<span class="plain">}</span>
</pre>
<p class="inwebparagraph"></p>
<p class="endnote">This code is used in <a href="#SP11_2_2">&#167;11.2.2</a>.</p>
<p class="inwebparagraph"><a id="SP11_2_2_3_1"></a><b>&#167;11.2.2.3.1. </b>The rawtext is doing something like this:
</p>
<p class="inwebparagraph"></p>
<pre class="display">
<span class="plain"> {*}A ball is in the bag.</span>
<span class="plain"> The bag is on the kitchen table.</span>
<span class="plain">This single sentence doesn"t make much of a simulation. Let"s add:</span>
<span class="plain"> {**}The stitched seam is part of the ball.</span>
</pre>
<p class="inwebparagraph">The line count <code class="display"><span class="extract">i</span></code> points to the first line of this. The paste consists
of the two lines about the bag and the table, but with the stitched seam
line added in, because of the <code class="display"><span class="extract">{**}</span></code> continuation marker. The "range" is
down to the last line which is included in the paste.
</p>
<p class="macrodefinition"><code class="display">
&lt;<span class="cwebmacrodefn">Determine the quoted J-text</span> <span class="cwebmacronumber">11.2.2.3.1</span>&gt; =
</code></p>
<pre class="displaydefn">
<span class="reserved">int</span><span class="plain"> </span><span class="identifier">up_to</span><span class="plain">; </span> <span class="comment">one line beyond what will be pasted</span>
&lt;<span class="cwebmacro">Find the range of rawtext lines which fall into this paste</span> <span class="cwebmacronumber">11.2.2.3.1.1</span>&gt;<span class="plain">;</span>
&lt;<span class="cwebmacro">Collate the indented lines in that range into the J-text</span> <span class="cwebmacronumber">11.2.2.3.1.2</span>&gt;<span class="plain">;</span>
<span class="functiontext">Renderer::apply_Inform_escape_characters</span><span class="plain">(</span><span class="identifier">J_text</span><span class="plain">);</span>
</pre>
<p class="inwebparagraph"></p>
<p class="endnote">This code is used in <a href="#SP11_2_2_3">&#167;11.2.2.3</a>.</p>
<p class="inwebparagraph"><a id="SP11_2_2_3_1_1"></a><b>&#167;11.2.2.3.1.1. </b><code class="display">
&lt;<span class="cwebmacrodefn">Find the range of rawtext lines which fall into this paste</span> <span class="cwebmacronumber">11.2.2.3.1.1</span>&gt; =
</code></p>
<pre class="displaydefn">
<span class="reserved">for</span><span class="plain"> (</span><span class="identifier">up_to</span><span class="plain"> = </span><span class="identifier">i</span><span class="plain">; ((</span><span class="identifier">up_to</span><span class="plain">&lt;</span><span class="identifier">no_paras_in_block_buffer</span><span class="plain">) &amp;&amp;</span>
<span class="plain">((</span><span class="identifier">paragraphs</span><span class="plain">[</span><span class="identifier">up_to</span><span class="plain">]</span><span class="element">.par_indentation</span><span class="plain"> &gt; 0) ||</span>
<span class="plain">(</span><span class="functiontext">Str::len</span><span class="plain">(</span><span class="identifier">paragraphs</span><span class="plain">[</span><span class="identifier">up_to</span><span class="plain">]</span><span class="element">.par_texts</span><span class="plain">) == 0))); </span><span class="identifier">up_to</span><span class="plain">++) { ; }</span>
<span class="reserved">int</span><span class="plain"> </span><span class="identifier">extended_range</span><span class="plain"> = </span><span class="constant">TRUE</span><span class="plain">;</span>
<span class="reserved">while</span><span class="plain"> (</span><span class="identifier">extended_range</span><span class="plain">) {</span>
<span class="identifier">extended_range</span><span class="plain"> = </span><span class="constant">FALSE</span><span class="plain">;</span>
<span class="reserved">int</span><span class="plain"> </span><span class="identifier">l</span><span class="plain">;</span>
<span class="reserved">for</span><span class="plain"> (</span><span class="identifier">l</span><span class="plain">=</span><span class="identifier">up_to</span><span class="plain">; ((</span><span class="identifier">l</span><span class="plain">&lt;</span><span class="identifier">no_paras_in_block_buffer</span><span class="plain">) &amp;&amp;</span>
<span class="plain">(</span><span class="identifier">paragraphs</span><span class="plain">[</span><span class="identifier">l</span><span class="plain">]</span><span class="element">.par_indentation</span><span class="plain"> == 0)); </span><span class="identifier">l</span><span class="plain">++) { ; }</span>
<span class="reserved">if</span><span class="plain"> ((</span><span class="identifier">l</span><span class="plain">&lt;</span><span class="identifier">no_paras_in_block_buffer</span><span class="plain">) &amp;&amp;</span>
<span class="plain">(</span><span class="functiontext">Regexp::match</span><span class="plain">(</span><span class="identifier">NULL</span><span class="plain">, </span><span class="identifier">paragraphs</span><span class="plain">[</span><span class="identifier">l</span><span class="plain">]</span><span class="element">.par_texts</span><span class="plain">, </span><span class="identifier">L</span><span class="string">"%c*{%*%*}%c*"</span><span class="plain">))) {</span>
<span class="reserved">for</span><span class="plain"> (</span><span class="identifier">l</span><span class="plain">++; ((</span><span class="identifier">l</span><span class="plain">&lt;</span><span class="identifier">no_paras_in_block_buffer</span><span class="plain">) &amp;&amp;</span>
<span class="plain">((</span><span class="identifier">paragraphs</span><span class="plain">[</span><span class="identifier">l</span><span class="plain">]</span><span class="element">.par_indentation</span><span class="plain"> &gt; 0) ||</span>
<span class="plain">(</span><span class="functiontext">Str::len</span><span class="plain">(</span><span class="identifier">paragraphs</span><span class="plain">[</span><span class="identifier">l</span><span class="plain">]</span><span class="element">.par_texts</span><span class="plain">) == 0))); </span><span class="identifier">l</span><span class="plain">++) { ; }</span>
<span class="identifier">up_to</span><span class="plain"> = </span><span class="identifier">l</span><span class="plain">; </span><span class="identifier">extended_range</span><span class="plain"> = </span><span class="constant">TRUE</span><span class="plain">;</span>
<span class="plain">}</span>
<span class="plain">}</span>
</pre>
<p class="inwebparagraph"></p>
<p class="endnote">This code is used in <a href="#SP11_2_2_3_1">&#167;11.2.2.3.1</a>.</p>
<p class="inwebparagraph"><a id="SP11_2_2_3_1_2"></a><b>&#167;11.2.2.3.1.2. </b><code class="display">
&lt;<span class="cwebmacrodefn">Collate the indented lines in that range into the J-text</span> <span class="cwebmacronumber">11.2.2.3.1.2</span>&gt; =
</code></p>
<pre class="displaydefn">
<span class="reserved">for</span><span class="plain"> (</span><span class="reserved">int</span><span class="plain"> </span><span class="identifier">j</span><span class="plain">=</span><span class="identifier">i</span><span class="plain">; </span><span class="identifier">j</span><span class="plain">&lt;</span><span class="identifier">up_to</span><span class="plain">; </span><span class="identifier">j</span><span class="plain">++) {</span>
<span class="reserved">int</span><span class="plain"> </span><span class="identifier">ic</span><span class="plain"> = </span><span class="identifier">paragraphs</span><span class="plain">[</span><span class="identifier">j</span><span class="plain">]</span><span class="element">.par_indentation</span><span class="plain">;</span>
<span class="identifier">TEMPORARY_TEXT</span><span class="plain">(</span><span class="identifier">joinbit</span><span class="plain">);</span>
<span class="reserved">while</span><span class="plain"> (</span><span class="identifier">ic</span><span class="plain"> &gt; 1) { </span><span class="identifier">ic</span><span class="plain">--; </span><span class="identifier">PUT_TO</span><span class="plain">(</span><span class="identifier">J_text</span><span class="plain">, </span><span class="character">'\</span><span class="plain">t</span><span class="character">'</span><span class="plain">); }</span>
<span class="reserved">if</span><span class="plain"> (</span><span class="identifier">j</span><span class="plain"> == </span><span class="identifier">i</span><span class="plain">) </span><span class="functiontext">Str::copy</span><span class="plain">(</span><span class="identifier">joinbit</span><span class="plain">, </span><span class="identifier">right</span><span class="plain">);</span>
<span class="reserved">else</span><span class="plain"> </span><span class="functiontext">Str::copy</span><span class="plain">(</span><span class="identifier">joinbit</span><span class="plain">, </span><span class="identifier">paragraphs</span><span class="plain">[</span><span class="identifier">j</span><span class="plain">]</span><span class="element">.par_texts</span><span class="plain">);</span>
<span class="reserved">if</span><span class="plain"> ((</span><span class="identifier">paragraphs</span><span class="plain">[</span><span class="identifier">j</span><span class="plain">]</span><span class="element">.par_indentation</span><span class="plain"> == 0) &amp;&amp; (</span><span class="functiontext">Str::len</span><span class="plain">(</span><span class="identifier">joinbit</span><span class="plain">) &gt; 0)) {</span>
<span class="identifier">TEMPORARY_TEXT</span><span class="plain">(</span><span class="identifier">br</span><span class="plain">);</span>
<span class="identifier">WRITE_TO</span><span class="plain">(</span><span class="identifier">br</span><span class="plain">, </span><span class="string">"[%S]"</span><span class="plain">, </span><span class="identifier">joinbit</span><span class="plain">);</span>
<span class="functiontext">Str::copy</span><span class="plain">(</span><span class="identifier">joinbit</span><span class="plain">, </span><span class="identifier">br</span><span class="plain">);</span>
<span class="identifier">DISCARD_TEXT</span><span class="plain">(</span><span class="identifier">br</span><span class="plain">);</span>
<span class="plain">}</span>
<span class="reserved">for</span><span class="plain"> (</span><span class="reserved">int</span><span class="plain"> </span><span class="identifier">k</span><span class="plain">=0, </span><span class="identifier">L</span><span class="plain"> = </span><span class="functiontext">Str::len</span><span class="plain">(</span><span class="identifier">joinbit</span><span class="plain">), </span><span class="identifier">prev_c</span><span class="plain"> = -1; </span><span class="identifier">k</span><span class="plain">&lt;</span><span class="identifier">L</span><span class="plain">; </span><span class="identifier">k</span><span class="plain">++) {</span>
<span class="reserved">int</span><span class="plain"> </span><span class="identifier">c</span><span class="plain"> = </span><span class="functiontext">Str::get_at</span><span class="plain">(</span><span class="identifier">joinbit</span><span class="plain">, </span><span class="identifier">k</span><span class="plain">);</span>
<span class="reserved">switch</span><span class="plain"> (</span><span class="identifier">c</span><span class="plain">) {</span>
<span class="reserved">case</span><span class="plain"> </span><span class="character">'\</span><span class="plain">\</span><span class="character">'</span><span class="plain">: </span><span class="identifier">WRITE_TO</span><span class="plain">(</span><span class="identifier">J_text</span><span class="plain">, </span><span class="string">"___backslash___"</span><span class="plain">); </span><span class="reserved">break</span><span class="plain">;</span>
<span class="reserved">case</span><span class="plain"> </span><span class="character">'\</span><span class="plain">'</span><span class="character">'</span><span class="plain">: </span><span class="identifier">WRITE_TO</span><span class="plain">(</span><span class="identifier">J_text</span><span class="plain">, </span><span class="string">"\</span><span class="plain">\</span><span class="string">'"</span><span class="plain">); </span><span class="reserved">break</span><span class="plain">;</span>
<span class="reserved">case</span><span class="plain"> </span><span class="character">'\</span><span class="plain">t</span><span class="character">'</span><span class="plain">: </span><span class="reserved">if</span><span class="plain"> (</span><span class="identifier">prev_c</span><span class="plain"> != </span><span class="character">'\</span><span class="plain">t</span><span class="character">'</span><span class="plain">) </span><span class="identifier">WRITE_TO</span><span class="plain">(</span><span class="identifier">J_text</span><span class="plain">, </span><span class="string">"\</span><span class="plain">\</span><span class="string">t"</span><span class="plain">); </span><span class="reserved">break</span><span class="plain">;</span>
<span class="reserved">case</span><span class="plain"> </span><span class="character">'&amp;'</span><span class="plain">: </span><span class="reserved">if</span><span class="plain"> (</span><span class="functiontext">Str::includes_wide_string_at</span><span class="plain">(</span><span class="identifier">joinbit</span><span class="plain">, </span><span class="identifier">L</span><span class="string">"amp;"</span><span class="plain">, </span><span class="identifier">k</span><span class="plain">+1)) </span><span class="identifier">k</span><span class="plain"> += 4;</span>
<span class="identifier">PUT_TO</span><span class="plain">(</span><span class="identifier">J_text</span><span class="plain">, </span><span class="identifier">c</span><span class="plain">); </span><span class="reserved">break</span><span class="plain">;</span>
<span class="reserved">case</span><span class="plain"> </span><span class="character">'{'</span><span class="plain">: </span><span class="reserved">if</span><span class="plain"> (</span><span class="functiontext">Str::includes_wide_string_at</span><span class="plain">(</span><span class="identifier">joinbit</span><span class="plain">, </span><span class="identifier">L</span><span class="string">"**}"</span><span class="plain">, </span><span class="identifier">k</span><span class="plain">+1)) </span><span class="identifier">k</span><span class="plain"> += 3;</span>
<span class="reserved">else</span><span class="plain"> </span><span class="identifier">PUT_TO</span><span class="plain">(</span><span class="identifier">J_text</span><span class="plain">, </span><span class="identifier">c</span><span class="plain">); </span><span class="reserved">break</span><span class="plain">;</span>
<span class="reserved">default</span><span class="plain">: </span><span class="identifier">PUT_TO</span><span class="plain">(</span><span class="identifier">J_text</span><span class="plain">, </span><span class="identifier">c</span><span class="plain">); </span><span class="reserved">break</span><span class="plain">;</span>
<span class="plain">}</span>
<span class="identifier">prev_c</span><span class="plain"> = </span><span class="identifier">c</span><span class="plain">;</span>
<span class="plain">}</span>
<span class="identifier">PUT_TO</span><span class="plain">(</span><span class="identifier">J_text</span><span class="plain">, </span><span class="character">'\</span><span class="plain">n</span><span class="character">'</span><span class="plain">);</span>
<span class="identifier">DISCARD_TEXT</span><span class="plain">(</span><span class="identifier">joinbit</span><span class="plain">);</span>
<span class="plain">}</span>
</pre>
<p class="inwebparagraph"></p>
<p class="endnote">This code is used in <a href="#SP11_2_2_3_1">&#167;11.2.2.3.1</a>.</p>
<p class="inwebparagraph"><a id="SP12"></a><b>&#167;12. </b></p>
<pre class="display">
<span class="reserved">void</span><span class="plain"> </span><span class="functiontext">Renderer::remove_paste_markers</span><span class="plain">(</span><span class="reserved">text_stream</span><span class="plain"> *</span><span class="identifier">text</span><span class="plain">) {</span>
<span class="reserved">for</span><span class="plain"> (</span><span class="reserved">int</span><span class="plain"> </span><span class="identifier">i</span><span class="plain">=0, </span><span class="identifier">L</span><span class="plain">=</span><span class="functiontext">Str::len</span><span class="plain">(</span><span class="identifier">text</span><span class="plain">); </span><span class="identifier">i</span><span class="plain">&lt;</span><span class="identifier">L</span><span class="plain">; </span><span class="identifier">i</span><span class="plain">++) {</span>
<span class="reserved">if</span><span class="plain"> ((</span><span class="functiontext">Str::get_at</span><span class="plain">(</span><span class="identifier">text</span><span class="plain">, </span><span class="identifier">i</span><span class="plain">) == </span><span class="character">'{'</span><span class="plain">) &amp;&amp;</span>
<span class="plain">(</span><span class="functiontext">Str::get_at</span><span class="plain">(</span><span class="identifier">text</span><span class="plain">, </span><span class="identifier">i</span><span class="plain">+1) == </span><span class="character">'*'</span><span class="plain">) &amp;&amp;</span>
<span class="plain">(</span><span class="functiontext">Str::get_at</span><span class="plain">(</span><span class="identifier">text</span><span class="plain">, </span><span class="identifier">i</span><span class="plain">+2) == </span><span class="character">'*'</span><span class="plain">) &amp;&amp;</span>
<span class="plain">(</span><span class="functiontext">Str::get_at</span><span class="plain">(</span><span class="identifier">text</span><span class="plain">, </span><span class="identifier">i</span><span class="plain">+3) == </span><span class="character">'}'</span><span class="plain">)) {</span>
<span class="functiontext">Renderer::remove_paste_markers_from</span><span class="plain">(</span><span class="identifier">text</span><span class="plain">, </span><span class="identifier">i</span><span class="plain">);</span>
<span class="reserved">return</span><span class="plain">;</span>
<span class="plain">}</span>
<span class="plain">}</span>
<span class="plain">}</span>
<span class="reserved">void</span><span class="plain"> </span><span class="functiontext">Renderer::remove_paste_markers_from</span><span class="plain">(</span><span class="reserved">text_stream</span><span class="plain"> *</span><span class="identifier">text</span><span class="plain">, </span><span class="reserved">int</span><span class="plain"> </span><span class="identifier">i</span><span class="plain">) {</span>
<span class="identifier">TEMPORARY_TEXT</span><span class="plain">(</span><span class="identifier">modified</span><span class="plain">);</span>
<span class="reserved">for</span><span class="plain"> (</span><span class="reserved">int</span><span class="plain"> </span><span class="identifier">j</span><span class="plain">=0; </span><span class="identifier">j</span><span class="plain">&lt;</span><span class="identifier">i</span><span class="plain">; </span><span class="identifier">j</span><span class="plain">++) </span><span class="identifier">PUT_TO</span><span class="plain">(</span><span class="identifier">modified</span><span class="plain">, </span><span class="functiontext">Str::get_at</span><span class="plain">(</span><span class="identifier">text</span><span class="plain">, </span><span class="identifier">j</span><span class="plain">));</span>
<span class="reserved">for</span><span class="plain"> (</span><span class="reserved">int</span><span class="plain"> </span><span class="identifier">L</span><span class="plain">=</span><span class="functiontext">Str::len</span><span class="plain">(</span><span class="identifier">text</span><span class="plain">); </span><span class="identifier">i</span><span class="plain">&lt;</span><span class="identifier">L</span><span class="plain">; </span><span class="identifier">i</span><span class="plain">++) {</span>
<span class="reserved">int</span><span class="plain"> </span><span class="identifier">c</span><span class="plain"> = </span><span class="functiontext">Str::get_at</span><span class="plain">(</span><span class="identifier">text</span><span class="plain">, </span><span class="identifier">i</span><span class="plain">);</span>
<span class="reserved">if</span><span class="plain"> ((</span><span class="identifier">c</span><span class="plain"> == </span><span class="character">'{'</span><span class="plain">) &amp;&amp;</span>
<span class="plain">(</span><span class="functiontext">Str::get_at</span><span class="plain">(</span><span class="identifier">text</span><span class="plain">, </span><span class="identifier">i</span><span class="plain">+1) == </span><span class="character">'*'</span><span class="plain">) &amp;&amp;</span>
<span class="plain">(</span><span class="functiontext">Str::get_at</span><span class="plain">(</span><span class="identifier">text</span><span class="plain">, </span><span class="identifier">i</span><span class="plain">+2) == </span><span class="character">'*'</span><span class="plain">) &amp;&amp;</span>
<span class="plain">(</span><span class="functiontext">Str::get_at</span><span class="plain">(</span><span class="identifier">text</span><span class="plain">, </span><span class="identifier">i</span><span class="plain">+3) == </span><span class="character">'}'</span><span class="plain">)) </span><span class="identifier">i</span><span class="plain">+=3;</span>
<span class="reserved">else</span><span class="plain"> </span><span class="identifier">PUT_TO</span><span class="plain">(</span><span class="identifier">modified</span><span class="plain">, </span><span class="identifier">c</span><span class="plain">);</span>
<span class="plain">}</span>
<span class="functiontext">Str::copy</span><span class="plain">(</span><span class="identifier">text</span><span class="plain">, </span><span class="identifier">modified</span><span class="plain">);</span>
<span class="identifier">DISCARD_TEXT</span><span class="plain">(</span><span class="identifier">modified</span><span class="plain">);</span>
<span class="plain">}</span>
</pre>
<p class="inwebparagraph"></p>
<p class="endnote">The function Renderer::remove_paste_markers appears nowhere else.</p>
<p class="endnote">The function Renderer::remove_paste_markers_from appears nowhere else.</p>
<p class="inwebparagraph"><a id="SP13"></a><b>&#167;13. </b></p>
<pre class="display">
<span class="reserved">void</span><span class="plain"> </span><span class="functiontext">Renderer::apply_Inform_escape_characters</span><span class="plain">(</span><span class="reserved">text_stream</span><span class="plain"> *</span><span class="identifier">text</span><span class="plain">) {</span>
<span class="identifier">TEMPORARY_TEXT</span><span class="plain">(</span><span class="identifier">modified</span><span class="plain">);</span>
<span class="reserved">for</span><span class="plain"> (</span><span class="reserved">int</span><span class="plain"> </span><span class="identifier">i</span><span class="plain">=0, </span><span class="identifier">L</span><span class="plain">=</span><span class="functiontext">Str::len</span><span class="plain">(</span><span class="identifier">text</span><span class="plain">); </span><span class="identifier">i</span><span class="plain">&lt;</span><span class="identifier">L</span><span class="plain">; </span><span class="identifier">i</span><span class="plain">++) {</span>
<span class="reserved">int</span><span class="plain"> </span><span class="identifier">c</span><span class="plain"> = </span><span class="functiontext">Str::get_at</span><span class="plain">(</span><span class="identifier">text</span><span class="plain">, </span><span class="identifier">i</span><span class="plain">);</span>
<span class="reserved">switch</span><span class="plain"> (</span><span class="identifier">c</span><span class="plain">) {</span>
<span class="reserved">case</span><span class="plain"> </span><span class="character">'\</span><span class="plain">\</span><span class="character">'</span><span class="plain">:</span>
<span class="identifier">c</span><span class="plain"> = </span><span class="functiontext">Str::get_at</span><span class="plain">(</span><span class="identifier">text</span><span class="plain">, ++</span><span class="identifier">i</span><span class="plain">);</span>
<span class="reserved">if</span><span class="plain"> (</span><span class="identifier">c</span><span class="plain"> == </span><span class="character">'\</span><span class="plain">'</span><span class="character">'</span><span class="plain">) </span><span class="identifier">WRITE_TO</span><span class="plain">(</span><span class="identifier">modified</span><span class="plain">, </span><span class="string">"[=0x0027=]"</span><span class="plain">);</span>
<span class="reserved">else</span><span class="plain"> </span><span class="reserved">if</span><span class="plain"> (</span><span class="identifier">c</span><span class="plain"> == </span><span class="character">'t'</span><span class="plain">) </span><span class="identifier">WRITE_TO</span><span class="plain">(</span><span class="identifier">modified</span><span class="plain">, </span><span class="string">"[=0x0009=]"</span><span class="plain">);</span>
<span class="reserved">else</span><span class="plain"> </span><span class="identifier">WRITE_TO</span><span class="plain">(</span><span class="identifier">modified</span><span class="plain">, </span><span class="string">"\</span><span class="plain">\</span><span class="string">%c"</span><span class="plain">, </span><span class="identifier">c</span><span class="plain">);</span>
<span class="reserved">break</span><span class="plain">;</span>
<span class="reserved">case</span><span class="plain"> </span><span class="character">'\</span><span class="plain">"</span><span class="character">'</span><span class="plain">: </span><span class="identifier">WRITE_TO</span><span class="plain">(</span><span class="identifier">modified</span><span class="plain">, </span><span class="string">"[=0x0022=]"</span><span class="plain">); </span><span class="reserved">break</span><span class="plain">;</span>
<span class="reserved">case</span><span class="plain"> </span><span class="character">'\</span><span class="plain">x</span><span class="character">0a'</span><span class="plain">: </span><span class="identifier">WRITE_TO</span><span class="plain">(</span><span class="identifier">modified</span><span class="plain">, </span><span class="string">"[=0x000A=]"</span><span class="plain">); </span><span class="reserved">break</span><span class="plain">;</span>
<span class="reserved">case</span><span class="plain"> </span><span class="character">'\</span><span class="plain">x</span><span class="character">0d'</span><span class="plain">: </span><span class="identifier">WRITE_TO</span><span class="plain">(</span><span class="identifier">modified</span><span class="plain">, </span><span class="string">"[=0x000A=]"</span><span class="plain">); </span><span class="reserved">break</span><span class="plain">;</span>
<span class="reserved">case</span><span class="plain"> </span><span class="character">'\</span><span class="plain">t</span><span class="character">'</span><span class="plain">: </span><span class="identifier">WRITE_TO</span><span class="plain">(</span><span class="identifier">modified</span><span class="plain">, </span><span class="string">"[=0x0009=]"</span><span class="plain">); </span><span class="reserved">break</span><span class="plain">;</span>
<span class="reserved">case</span><span class="plain"> </span><span class="character">'&lt;'</span><span class="plain">: </span><span class="identifier">WRITE_TO</span><span class="plain">(</span><span class="identifier">modified</span><span class="plain">, </span><span class="string">"[=0x003C=]"</span><span class="plain">); </span><span class="reserved">break</span><span class="plain">;</span>
<span class="reserved">case</span><span class="plain"> </span><span class="character">'&gt;'</span><span class="plain">: </span><span class="identifier">WRITE_TO</span><span class="plain">(</span><span class="identifier">modified</span><span class="plain">, </span><span class="string">"[=0x003E=]"</span><span class="plain">); </span><span class="reserved">break</span><span class="plain">;</span>
<span class="reserved">case</span><span class="plain"> </span><span class="character">'_'</span><span class="plain">:</span>
<span class="reserved">if</span><span class="plain"> (</span><span class="functiontext">Str::includes_wide_string_at</span><span class="plain">(</span><span class="identifier">text</span><span class="plain">, </span><span class="identifier">L</span><span class="string">"__backslash___"</span><span class="plain">, </span><span class="identifier">i</span><span class="plain">+1)) {</span>
<span class="identifier">WRITE_TO</span><span class="plain">(</span><span class="identifier">modified</span><span class="plain">, </span><span class="string">"[=0x005C=]"</span><span class="plain">); </span><span class="identifier">i</span><span class="plain">+=14;</span>
<span class="plain">} </span><span class="reserved">else</span><span class="plain"> </span><span class="identifier">PUT_TO</span><span class="plain">(</span><span class="identifier">modified</span><span class="plain">, </span><span class="identifier">c</span><span class="plain">);</span>
<span class="reserved">break</span><span class="plain">;</span>
<span class="reserved">case</span><span class="plain"> </span><span class="character">'&amp;'</span><span class="plain">:</span>
<span class="reserved">if</span><span class="plain"> (</span><span class="functiontext">Str::includes_wide_string_at</span><span class="plain">(</span><span class="identifier">text</span><span class="plain">, </span><span class="identifier">L</span><span class="string">"quot;"</span><span class="plain">, </span><span class="identifier">i</span><span class="plain">+1)) {</span>
<span class="identifier">WRITE_TO</span><span class="plain">(</span><span class="identifier">modified</span><span class="plain">, </span><span class="string">"[=0x0022=]"</span><span class="plain">); </span><span class="identifier">i</span><span class="plain">+=5;</span>
<span class="plain">} </span><span class="reserved">else</span><span class="plain"> </span><span class="reserved">if</span><span class="plain"> (</span><span class="functiontext">Str::includes_wide_string_at</span><span class="plain">(</span><span class="identifier">text</span><span class="plain">, </span><span class="identifier">L</span><span class="string">"lt;"</span><span class="plain">, </span><span class="identifier">i</span><span class="plain">+1)) {</span>
<span class="identifier">WRITE_TO</span><span class="plain">(</span><span class="identifier">modified</span><span class="plain">, </span><span class="string">"[=0x003C=]"</span><span class="plain">); </span><span class="identifier">i</span><span class="plain">+=3;</span>
<span class="plain">} </span><span class="reserved">else</span><span class="plain"> </span><span class="reserved">if</span><span class="plain"> (</span><span class="functiontext">Str::includes_wide_string_at</span><span class="plain">(</span><span class="identifier">text</span><span class="plain">, </span><span class="identifier">L</span><span class="string">"gt;"</span><span class="plain">, </span><span class="identifier">i</span><span class="plain">+1)) {</span>
<span class="identifier">WRITE_TO</span><span class="plain">(</span><span class="identifier">modified</span><span class="plain">, </span><span class="string">"[=0x003E=]"</span><span class="plain">); </span><span class="identifier">i</span><span class="plain">+=3;</span>
<span class="plain">} </span><span class="reserved">else</span><span class="plain"> {</span>
<span class="identifier">WRITE_TO</span><span class="plain">(</span><span class="identifier">modified</span><span class="plain">, </span><span class="string">"[=0x0026=]"</span><span class="plain">);</span>
<span class="plain">}</span>
<span class="reserved">break</span><span class="plain">;</span>
<span class="reserved">default</span><span class="plain">: </span><span class="identifier">PUT_TO</span><span class="plain">(</span><span class="identifier">modified</span><span class="plain">, </span><span class="identifier">c</span><span class="plain">); </span><span class="reserved">break</span><span class="plain">;</span>
<span class="plain">}</span>
<span class="plain">}</span>
<span class="functiontext">Str::copy</span><span class="plain">(</span><span class="identifier">text</span><span class="plain">, </span><span class="identifier">modified</span><span class="plain">);</span>
<span class="identifier">DISCARD_TEXT</span><span class="plain">(</span><span class="identifier">modified</span><span class="plain">);</span>
<span class="plain">}</span>
</pre>
<p class="inwebparagraph"></p>
<p class="endnote">The function Renderer::apply_Inform_escape_characters is used in <a href="#SP11_2_2_3">&#167;11.2.2.3</a>, <a href="#SP11_2_2_3_1">&#167;11.2.2.3.1</a>.</p>
<p class="inwebparagraph"><a id="SP14"></a><b>&#167;14. Rendering cross-references to other sections. </b>These occur when the rawtext contains paragraphs with a very specific
arrangement:
</p>
<p class="inwebparagraph"></p>
<pre class="display">
<span class="plain">(-See Units for a more sophisticated capacity system.)</span>
</pre>
<p class="inwebparagraph">The idea is that, except for the brackets and dash, the text makes sense as
it stands; but in HTML, we can use the section title ("Units" here) to find
which block is meant, and encode this as a link.
</p>
<pre class="display">
<span class="reserved">void</span><span class="plain"> </span><span class="functiontext">Renderer::render_cross_reference</span><span class="plain">(</span><span class="constant">OUTPUT_STREAM</span><span class="plain">,</span>
<span class="reserved">text_stream</span><span class="plain"> *</span><span class="identifier">sname</span><span class="plain">, </span><span class="reserved">text_stream</span><span class="plain"> *</span><span class="identifier">reason</span><span class="plain">, </span><span class="reserved">volume</span><span class="plain"> *</span><span class="identifier">V</span><span class="plain">, </span><span class="reserved">int</span><span class="plain"> </span><span class="identifier">quieter</span><span class="plain">) {</span>
<span class="reserved">if</span><span class="plain"> (</span><span class="identifier">indoc_settings</span><span class="plain">-</span><span class="element">&gt;format</span><span class="plain"> == </span><span class="constant">PLAIN_FORMAT</span><span class="plain">)</span>
<span class="identifier">WRITE</span><span class="plain">(</span><span class="string">"(See %S for %S.)\</span><span class="plain">n</span><span class="string">"</span><span class="plain">, </span><span class="identifier">sname</span><span class="plain">, </span><span class="identifier">reason</span><span class="plain">);</span>
<span class="reserved">if</span><span class="plain"> (</span><span class="identifier">indoc_settings</span><span class="plain">-</span><span class="element">&gt;format</span><span class="plain"> == </span><span class="constant">HTML_FORMAT</span><span class="plain">) {</span>
<span class="identifier">TEMPORARY_TEXT</span><span class="plain">(</span><span class="identifier">dest</span><span class="plain">);</span>
<span class="identifier">WRITE_TO</span><span class="plain">(</span><span class="identifier">dest</span><span class="plain">, </span><span class="string">"index.html"</span><span class="plain">);</span>
&lt;<span class="cwebmacro">Identify the reference destination and be sure it exists</span> <span class="cwebmacronumber">14.1</span>&gt;<span class="plain">;</span>
<span class="identifier">HTML_OPEN_WITH</span><span class="plain">(</span><span class="string">"p"</span><span class="plain">, </span><span class="string">"class=\</span><span class="plain">"</span><span class="string">crossreference\</span><span class="plain">"</span><span class="string">"</span><span class="plain">);</span>
<span class="functiontext">HTML::begin_link_with_class</span><span class="plain">(</span><span class="identifier">OUT</span><span class="plain">, </span><span class="identifier">I</span><span class="string">"xreflink"</span><span class="plain">, </span><span class="identifier">dest</span><span class="plain">);</span>
<span class="functiontext">HTMLUtilities::asterisk_image</span><span class="plain">(</span><span class="identifier">OUT</span><span class="plain">, </span><span class="identifier">I</span><span class="string">"xref.png"</span><span class="plain">);</span>
<span class="identifier">WRITE</span><span class="plain">(</span><span class="string">"&amp;#160;&lt;i&gt;See &lt;/i&gt;&lt;b&gt;%S&lt;/b&gt;"</span><span class="plain">, </span><span class="identifier">sname</span><span class="plain">);</span>
<span class="functiontext">HTML::end_link</span><span class="plain">(</span><span class="identifier">OUT</span><span class="plain">);</span>
<span class="reserved">if</span><span class="plain"> (</span><span class="identifier">quieter</span><span class="plain"> == </span><span class="constant">FALSE</span><span class="plain">) </span><span class="identifier">HTML_OPEN</span><span class="plain">(</span><span class="string">"i"</span><span class="plain">);</span>
<span class="identifier">WRITE</span><span class="plain">(</span><span class="string">" for %S"</span><span class="plain">, </span><span class="identifier">reason</span><span class="plain">);</span>
<span class="reserved">if</span><span class="plain"> (</span><span class="identifier">quieter</span><span class="plain"> == </span><span class="constant">FALSE</span><span class="plain">) </span><span class="identifier">HTML_CLOSE</span><span class="plain">(</span><span class="string">"i"</span><span class="plain">);</span>
<span class="identifier">HTML_CLOSE</span><span class="plain">(</span><span class="string">"p"</span><span class="plain">);</span>
<span class="identifier">DISCARD_TEXT</span><span class="plain">(</span><span class="identifier">dest</span><span class="plain">);</span>
<span class="plain">}</span>
<span class="plain">}</span>
</pre>
<p class="inwebparagraph"></p>
<p class="endnote">The function Renderer::render_cross_reference is used in <a href="#SP11_2_7">&#167;11.2.7</a>.</p>
<p class="inwebparagraph"><a id="SP14_1"></a><b>&#167;14.1. </b><code class="display">
&lt;<span class="cwebmacrodefn">Identify the reference destination and be sure it exists</span> <span class="cwebmacronumber">14.1</span>&gt; =
</code></p>
<pre class="displaydefn">
<span class="reserved">section</span><span class="plain"> *</span><span class="identifier">S</span><span class="plain"> = (</span><span class="reserved">section</span><span class="plain"> *) </span><span class="functiontext">Dictionaries::read_value</span><span class="plain">(</span><span class="identifier">V</span><span class="plain">-</span><span class="element">&gt;sections_by_name</span><span class="plain">, </span><span class="identifier">sname</span><span class="plain">);</span>
<span class="reserved">if</span><span class="plain"> (</span><span class="identifier">S</span><span class="plain">) </span><span class="functiontext">Str::copy</span><span class="plain">(</span><span class="identifier">dest</span><span class="plain">, </span><span class="identifier">S</span><span class="plain">-</span><span class="element">&gt;section_URL</span><span class="plain">);</span>
<span class="reserved">else</span><span class="plain"> </span><span class="functiontext">Errors::with_text</span><span class="plain">(</span><span class="string">"cross-reference to %S points to no section"</span><span class="plain">, </span><span class="identifier">sname</span><span class="plain">);</span>
</pre>
<p class="inwebparagraph"></p>
<p class="endnote">This code is used in <a href="#SP14">&#167;14</a>.</p>
<p class="inwebparagraph"><a id="SP15"></a><b>&#167;15. </b>And similarly, for cross-referencing to examples by name:
</p>
<p class="inwebparagraph"></p>
<pre class="display">
<span class="plain">(See example "Blink")</span>
<span class="reserved">void</span><span class="plain"> </span><span class="functiontext">Renderer::render_example_cross_reference</span><span class="plain">(</span><span class="constant">OUTPUT_STREAM</span><span class="plain">, </span><span class="reserved">text_stream</span><span class="plain"> *</span><span class="identifier">ename</span><span class="plain">, </span><span class="reserved">volume</span><span class="plain"> *</span><span class="identifier">V</span><span class="plain">) {</span>
<span class="reserved">example</span><span class="plain"> *</span><span class="identifier">E</span><span class="plain"> = (</span><span class="reserved">example</span><span class="plain"> *) </span><span class="functiontext">Dictionaries::read_value</span><span class="plain">(</span><span class="identifier">examples_by_name</span><span class="plain">, </span><span class="identifier">ename</span><span class="plain">);</span>
<span class="reserved">if</span><span class="plain"> (</span><span class="identifier">E</span><span class="plain">) </span><span class="functiontext">Examples::render_example_cue</span><span class="plain">(</span><span class="identifier">OUT</span><span class="plain">, </span><span class="identifier">E</span><span class="plain">, </span><span class="identifier">V</span><span class="plain">, 1);</span>
<span class="reserved">else</span><span class="plain"> </span><span class="functiontext">Errors::with_text</span><span class="plain">(</span><span class="string">"cross-reference to %S points to no section"</span><span class="plain">, </span><span class="identifier">ename</span><span class="plain">);</span>
<span class="plain">}</span>
</pre>
<p class="inwebparagraph"></p>
<p class="endnote">The function Renderer::render_example_cross_reference is used in <a href="#SP11_2_7">&#167;11.2.7</a>.</p>
<p class="inwebparagraph"><a id="SP16"></a><b>&#167;16. Handling the formatted file. </b>The idea is that several sections in a row may need to be written to the
same file, or may not. So this routine is called to guarantee that the
right file is open, rather than always to open one.
</p>
<pre class="display">
<span class="reserved">text_stream</span><span class="plain"> *</span><span class="functiontext">Renderer::formatted_file_must_be</span><span class="plain">(</span><span class="constant">OUTPUT_STREAM</span><span class="plain">, </span><span class="reserved">volume</span><span class="plain"> *</span><span class="identifier">V</span><span class="plain">, </span><span class="reserved">section</span><span class="plain"> *</span><span class="identifier">S</span><span class="plain">) {</span>
<span class="reserved">if</span><span class="plain"> (</span><span class="functiontext">Filenames::eq</span><span class="plain">(</span><span class="identifier">S</span><span class="plain">-</span><span class="element">&gt;section_filename</span><span class="plain">, </span><span class="identifier">current_FTD_filename</span><span class="plain">) == </span><span class="constant">FALSE</span><span class="plain">) {</span>
<span class="reserved">if</span><span class="plain"> (</span><span class="identifier">current_FTD_filename</span><span class="plain">) </span><span class="identifier">OUT</span><span class="plain"> = </span><span class="functiontext">Renderer::close_formatted_file</span><span class="plain">(</span><span class="identifier">OUT</span><span class="plain">);</span>
<span class="identifier">current_FTD_filename</span><span class="plain"> = </span><span class="identifier">S</span><span class="plain">-</span><span class="element">&gt;section_filename</span><span class="plain">;</span>
<span class="identifier">OUT</span><span class="plain"> = &amp;</span><span class="identifier">current_FTD_stream</span><span class="plain">;</span>
<span class="reserved">if</span><span class="plain"> (</span><span class="functiontext">Streams::open_to_file</span><span class="plain">(</span><span class="identifier">OUT</span><span class="plain">, </span><span class="identifier">S</span><span class="plain">-</span><span class="element">&gt;section_filename</span><span class="plain">, </span><span class="constant">UTF8_ENC</span><span class="plain">) == </span><span class="constant">FALSE</span><span class="plain">)</span>
<span class="functiontext">Errors::fatal_with_file</span><span class="plain">(</span><span class="string">"can't write documentation"</span><span class="plain">, </span><span class="identifier">S</span><span class="plain">-</span><span class="element">&gt;section_filename</span><span class="plain">);</span>
<span class="reserved">if</span><span class="plain"> (</span><span class="identifier">indoc_settings</span><span class="plain">-</span><span class="element">&gt;wrapper</span><span class="plain"> == </span><span class="constant">WRAPPER_epub</span><span class="plain">) {</span>
<span class="reserved">ebook_page</span><span class="plain"> *</span><span class="identifier">page</span><span class="plain"> =</span>
<span class="functiontext">Epub::note_page</span><span class="plain">(</span><span class="identifier">indoc_settings</span><span class="plain">-</span><span class="element">&gt;ebook</span><span class="plain">, </span><span class="identifier">S</span><span class="plain">-</span><span class="element">&gt;section_filename</span><span class="plain">, </span><span class="identifier">S</span><span class="plain">-</span><span class="element">&gt;section_file_title</span><span class="plain">, </span><span class="identifier">I</span><span class="string">""</span><span class="plain">);</span>
<span class="reserved">if</span><span class="plain"> (</span><span class="identifier">S</span><span class="plain"> == </span><span class="identifier">V</span><span class="plain">-</span><span class="element">&gt;sections</span><span class="plain">[0]) {</span>
<span class="reserved">ebook_volume</span><span class="plain"> *</span><span class="identifier">ev</span><span class="plain"> = </span><span class="functiontext">Epub::starts_volume</span><span class="plain">(</span><span class="identifier">indoc_settings</span><span class="plain">-</span><span class="element">&gt;ebook</span><span class="plain">, </span><span class="identifier">page</span><span class="plain">, </span><span class="identifier">V</span><span class="plain">-</span><span class="element">&gt;vol_title</span><span class="plain">);</span>
<span class="reserved">filename</span><span class="plain"> *</span><span class="identifier">F</span><span class="plain"> = </span><span class="functiontext">Filenames::in_folder</span><span class="plain">(</span><span class="identifier">indoc_settings</span><span class="plain">-</span><span class="element">&gt;destination</span><span class="plain">, </span><span class="identifier">V</span><span class="plain">-</span><span class="element">&gt;vol_CSS_leafname</span><span class="plain">);</span>
<span class="functiontext">Epub::use_CSS</span><span class="plain">(</span><span class="identifier">ev</span><span class="plain">, </span><span class="identifier">F</span><span class="plain">);</span>
<span class="plain">}</span>
<span class="reserved">if</span><span class="plain"> (</span><span class="identifier">S</span><span class="plain">-</span><span class="element">&gt;begins_which_chapter</span><span class="plain">)</span>
<span class="identifier">S</span><span class="plain">-</span><span class="element">&gt;begins_which_chapter</span><span class="plain">-</span><span class="element">&gt;ebook_ref</span><span class="plain"> =</span>
<span class="functiontext">Epub::starts_chapter</span><span class="plain">(</span><span class="identifier">indoc_settings</span><span class="plain">-</span><span class="element">&gt;ebook</span><span class="plain">, </span><span class="identifier">page</span><span class="plain">, </span><span class="identifier">S</span><span class="plain">-</span><span class="element">&gt;begins_which_chapter</span><span class="plain">-</span><span class="element">&gt;chapter_full_title</span><span class="plain">, </span><span class="identifier">S</span><span class="plain">-</span><span class="element">&gt;begins_which_chapter</span><span class="plain">-</span><span class="element">&gt;chapter_URL</span><span class="plain">);</span>
<span class="plain">}</span>
<span class="reserved">formatted_file</span><span class="plain"> *</span><span class="identifier">ftd</span><span class="plain"> = </span><span class="identifier">CREATE</span><span class="plain">(</span><span class="reserved">formatted_file</span><span class="plain">);</span>
<span class="identifier">ftd</span><span class="plain">-</span><span class="element">&gt;name</span><span class="plain"> = </span><span class="identifier">current_FTD_filename</span><span class="plain">;</span>
<span class="reserved">if</span><span class="plain"> (</span><span class="identifier">indoc_settings</span><span class="plain">-</span><span class="element">&gt;format</span><span class="plain"> == </span><span class="constant">HTML_FORMAT</span><span class="plain">) </span>&lt;<span class="cwebmacro">Write the HTML header for the formatted file</span> <span class="cwebmacronumber">16.2</span>&gt;<span class="plain">;</span>
<span class="plain">}</span>
<span class="reserved">return</span><span class="plain"> </span><span class="identifier">OUT</span><span class="plain">;</span>
<span class="plain">}</span>
</pre>
<p class="inwebparagraph"></p>
<p class="endnote">The function Renderer::formatted_file_must_be is used in <a href="#SP9">&#167;9</a>.</p>
<p class="inwebparagraph"><a id="SP16_1"></a><b>&#167;16.1. </b>When we certainly want to dispose of the current file:
</p>
<pre class="display">
<span class="reserved">text_stream</span><span class="plain"> *</span><span class="functiontext">Renderer::close_formatted_file</span><span class="plain">(</span><span class="constant">OUTPUT_STREAM</span><span class="plain">) {</span>
<span class="reserved">if</span><span class="plain"> (</span><span class="identifier">current_FTD_filename</span><span class="plain">) {</span>
<span class="reserved">if</span><span class="plain"> (</span><span class="identifier">indoc_settings</span><span class="plain">-</span><span class="element">&gt;format</span><span class="plain"> == </span><span class="constant">HTML_FORMAT</span><span class="plain">) </span>&lt;<span class="cwebmacro">Write the HTML footer for the formatted file</span> <span class="cwebmacronumber">16.1.1</span>&gt;<span class="plain">;</span>
<span class="functiontext">Streams::close</span><span class="plain">(&amp;</span><span class="identifier">current_FTD_stream</span><span class="plain">);</span>
<span class="identifier">current_FTD_filename</span><span class="plain"> = </span><span class="identifier">NULL</span><span class="plain">;</span>
<span class="plain">}</span>
<span class="reserved">return</span><span class="plain"> </span><span class="identifier">NULL</span><span class="plain">;</span>
<span class="plain">}</span>
</pre>
<p class="inwebparagraph"></p>
<p class="endnote">The function Renderer::close_formatted_file is used in <a href="#SP16">&#167;16</a>, 2/rr (<a href="2-rr.html#SP1">&#167;1</a>).</p>
<p class="inwebparagraph"><a id="SP16_2"></a><b>&#167;16.2. </b>The HTML files are topped and tailed either using a template supplied, or
with a <code class="display"><span class="extract">&lt;head&gt;</span></code> we make ourselves.
</p>
<p class="macrodefinition"><code class="display">
&lt;<span class="cwebmacrodefn">Write the HTML header for the formatted file</span> <span class="cwebmacronumber">16.2</span>&gt; =
</code></p>
<pre class="displaydefn">
<span class="identifier">TEMPORARY_TEXT</span><span class="plain">(</span><span class="identifier">top</span><span class="plain">);</span>
<span class="functiontext">HTMLUtilities::get_tt_matter</span><span class="plain">(</span><span class="identifier">top</span><span class="plain">, 0, 1);</span>
<span class="reserved">if</span><span class="plain"> (</span><span class="functiontext">Str::len</span><span class="plain">(</span><span class="identifier">top</span><span class="plain">) &gt; 0) {</span>
<span class="reserved">match_results</span><span class="plain"> </span><span class="identifier">mr</span><span class="plain"> = </span><span class="functiontext">Regexp::create_mr</span><span class="plain">();</span>
<span class="reserved">if</span><span class="plain"> (</span><span class="functiontext">Regexp::match</span><span class="plain">(&amp;</span><span class="identifier">mr</span><span class="plain">, </span><span class="identifier">top</span><span class="plain">, </span><span class="identifier">L</span><span class="string">"(%c*?)&lt;title&gt;%c*?&lt;/title&gt;(%c*)"</span><span class="plain">))</span>
<span class="identifier">WRITE</span><span class="plain">(</span><span class="string">"%S&lt;title&gt;Inform 7 - %S&lt;/title&gt;%S"</span><span class="plain">, </span><span class="identifier">mr</span><span class="element">.exp</span><span class="plain">[0], </span><span class="identifier">S</span><span class="plain">-</span><span class="element">&gt;section_file_title</span><span class="plain">, </span><span class="identifier">mr</span><span class="element">.exp</span><span class="plain">[1]);</span>
<span class="reserved">else</span>
<span class="identifier">WRITE</span><span class="plain">(</span><span class="string">"%S"</span><span class="plain">, </span><span class="identifier">top</span><span class="plain">);</span>
<span class="functiontext">Regexp::dispose_of</span><span class="plain">(&amp;</span><span class="identifier">mr</span><span class="plain">);</span>
<span class="plain">} </span><span class="reserved">else</span><span class="plain"> {</span>
<span class="functiontext">HTMLUtilities::begin_file</span><span class="plain">(</span><span class="identifier">OUT</span><span class="plain">, </span><span class="identifier">V</span><span class="plain">);</span>
<span class="functiontext">HTMLUtilities::write_title</span><span class="plain">(</span><span class="identifier">OUT</span><span class="plain">, </span><span class="identifier">S</span><span class="plain">-</span><span class="element">&gt;section_file_title</span><span class="plain">);</span>
<span class="reserved">if</span><span class="plain"> (</span><span class="identifier">indoc_settings</span><span class="plain">-</span><span class="element">&gt;javascript</span><span class="plain">) {</span>
<span class="functiontext">HTML::open_javascript</span><span class="plain">(</span><span class="identifier">OUT</span><span class="plain">, </span><span class="constant">FALSE</span><span class="plain">);</span>
<span class="functiontext">HTMLUtilities::write_javascript_for_buttons</span><span class="plain">(</span><span class="identifier">OUT</span><span class="plain">);</span>
<span class="functiontext">HTML::close_javascript</span><span class="plain">(</span><span class="identifier">OUT</span><span class="plain">);</span>
<span class="plain">}</span>
<span class="functiontext">HTML::end_head</span><span class="plain">(</span><span class="identifier">OUT</span><span class="plain">);</span>
<span class="functiontext">HTML::begin_body</span><span class="plain">(</span><span class="identifier">OUT</span><span class="plain">, </span><span class="identifier">I</span><span class="string">"paper papertint"</span><span class="plain">);</span>
<span class="plain">}</span>
<span class="reserved">if</span><span class="plain"> ((</span><span class="identifier">indoc_settings</span><span class="plain">-</span><span class="element">&gt;javascript</span><span class="plain">) &amp;&amp;</span>
<span class="plain">(</span><span class="identifier">indoc_settings</span><span class="plain">-</span><span class="element">&gt;javascript_paste_method</span><span class="plain"> == </span><span class="constant">PASTEMODE_Andrew</span><span class="plain">)) {</span>
<span class="functiontext">HTMLUtilities::paste_script</span><span class="plain">(</span><span class="identifier">OUT</span><span class="plain">, </span><span class="identifier">NULL</span><span class="plain">, 0);</span>
<span class="functiontext">HTMLUtilities::create_script</span><span class="plain">(</span><span class="identifier">OUT</span><span class="plain">, </span><span class="identifier">NULL</span><span class="plain">, 0, </span><span class="identifier">NULL</span><span class="plain">);</span>
<span class="plain">}</span>
<span class="identifier">DISCARD_TEXT</span><span class="plain">(</span><span class="identifier">top</span><span class="plain">);</span>
</pre>
<p class="inwebparagraph"></p>
<p class="endnote">This code is used in <a href="#SP16">&#167;16</a>.</p>
<p class="inwebparagraph"><a id="SP16_1_1"></a><b>&#167;16.1.1. </b><code class="display">
&lt;<span class="cwebmacrodefn">Write the HTML footer for the formatted file</span> <span class="cwebmacronumber">16.1.1</span>&gt; =
</code></p>
<pre class="displaydefn">
<span class="identifier">TEMPORARY_TEXT</span><span class="plain">(</span><span class="identifier">tail</span><span class="plain">);</span>
<span class="functiontext">HTMLUtilities::get_tt_matter</span><span class="plain">(</span><span class="identifier">tail</span><span class="plain">, 0, 0);</span>
<span class="reserved">if</span><span class="plain"> (</span><span class="functiontext">Str::len</span><span class="plain">(</span><span class="identifier">tail</span><span class="plain">) &gt; 0) { </span><span class="identifier">WRITE</span><span class="plain">(</span><span class="string">"%S"</span><span class="plain">, </span><span class="identifier">tail</span><span class="plain">); }</span>
<span class="reserved">else</span><span class="plain"> { </span><span class="functiontext">HTML::end_body</span><span class="plain">(</span><span class="identifier">OUT</span><span class="plain">); }</span>
<span class="identifier">DISCARD_TEXT</span><span class="plain">(</span><span class="identifier">tail</span><span class="plain">);</span>
</pre>
<p class="inwebparagraph"></p>
<p class="endnote">This code is used in <a href="#SP16_1">&#167;16.1</a>.</p>
<hr class="tocbar">
<ul class="toc"><li><a href="2-exm.html">Back to 'Examples'</a></li><li><a href="2-rr.html">Continue with 'Rawtext Reader'</a></li></ul><hr class="tocbar">
<!--End of weave-->
</body>
</html>