On Wednesday, November 25, 2020 at 3:19:13 PM UTC-8 TW Tones wrote:

>
>    - And perhaps a code view with line numbers from the source.
>    
>
Here's an updated version that add line numbers AND also fixes a bug 
whereby only one blank line was included in the output

\define showLines(tid,from,to)
<$vars length={{{ [[$to$]subtract[$from$]add[1]] }}}>
<$set name="lines" filter="[[$tid$]get[text]splitregexp[\n]addsuffix[ 
]first[$to$]last<length>]">
<pre><ol start="$from$"><$list filter="[enlist:raw<lines>]" 
variable="line"><li><$text text=<<line>>/></li></$list></ol></pre>
</$set>
</$vars>
\end
 
Notes:
* The $set filter adds a space to end of each line.  This effectively 
preserves multiple blank lines by making them non-empty list items
* The output is wrapped in <ol start="$from$">...</ol> and uses <li>...</li>  
instead of a trailing <br> to add the line numbers

enjoy,
-e

-- 
You received this message because you are subscribed to the Google Groups 
"TiddlyWiki" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to tiddlywiki+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/tiddlywiki/f609beb5-695f-4b38-aff3-36afe498cde9n%40googlegroups.com.

Reply via email to