blob: 5a89915209d60537f9e962fb40e7091b9724b948 [file] [log] [blame]
[# Safely display user-content text, such a program source code, with
line numbers.
Other EZT variables used:
file_lines: List of lines in the file, each with a line number and content.
should_prettify: whether the text should be syntax highlighted.
prettify_class: additional CSS class used to tell prettify.js how to
best syntax highlight this source file.
[# Display the line numbers and source lines in separate columns.
See corresponding comments L1, L2, L3 and S1, S2, S3 below.
This is messy because the pre tags have significant whitespace, so we
break lines inside the tags themslves to make our templates readable.]
<table class="opened"><tr>
<td id="nums">
[# L1. Start with a nocursor row at the top to space the line numbers down the
same amount as the source code lines w/ their initial cursor_hidden row.]
<pre><table width="100%"><tr class="nocursor"><td></td></tr></table></pre>
[# L2. Display each line number in a row that we can refer
to by ID, and make each line number a self-link w/ anchor.]
<pre><table width="100%" id="nums_table_0">[for file_lines]<tr id="gr_[file_lines.num]"
><td id="[file_lines.num]"><a href="#[file_lines.num]">[file_lines.num]</a></td></tr
[# L3. Finish the line numbers column with another nocursor row to match
the spacing of the source code column's final cursor_hidden row.]
<pre><table width="100%"><tr class="nocursor"><td></td></tr></table></pre>
<td id="lines">
[# S1. Start the source code column with a cursor row. ]
<pre><table width="100%"><tr class="cursor_stop cursor_hidden"><td></td></tr></table></pre>
[# S2. Display each source code line in a table row and cell
that we can identify by id.]
<pre [if-any should_prettify]class="prettyprint [prettify_class]"[end]><table id="src_table_0">[for file_lines]<tr
><td class="source">[file_lines.line]<br></td></tr
[# S3. Finish the line numbers column with another cursor stop.]
<pre><table width="100%"><tr class="cursor_stop cursor_hidden"><td></td></tr></table></pre>