Hi Eric, I came to this thread and found it very interesting. One use case is to show a code using the $codeblock widget with language to highlight the code for those specified lines and show the rest without highlighting!
I appreciate to instruct me how to do this. I thought to use the $codeblock widget instead of pre tag in showLines but this way I see fragmented output. Best wishes Mohammad On Thu, Nov 26, 2020 at 3:35 AM Eric Shulman <[email protected]> wrote: > 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 [email protected]. > To view this discussion on the web visit > https://groups.google.com/d/msgid/tiddlywiki/f609beb5-695f-4b38-aff3-36afe498cde9n%40googlegroups.com > <https://groups.google.com/d/msgid/tiddlywiki/f609beb5-695f-4b38-aff3-36afe498cde9n%40googlegroups.com?utm_medium=email&utm_source=footer> > . > -- 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 [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/tiddlywiki/CAAV1gMCqyP4saej8GOBDV_3YdH_%3DeOwuE6Zn9kPXAfm1hLBfew%40mail.gmail.com.

