This *second version* of hslines even accepts a text as source code no need
to provide a tiddler (of course I may recommend to put your code inside
tiddler)
This can be used to teach Tiddlywiki scripts ;-)

A minor bug is version 1 has been fixed. You can set the opacity to blur
the other lines .


See below examples

[image: 497_msedge.png]


Best wishes
Mohammad


On Fri, Jan 8, 2021 at 7:26 PM Mohammad Rahmani <[email protected]>
wrote:

> Attached is an interesting solution to transclude codes from a tiddler.
> This is useful when you want to discuss part of the code.
>
> 1. The code has a macro and a stylesheet
> 2. It is possible to transclude any part of code (say from line n to line
> m)
> 4. Macro accepts ALSO a composite range like "2-5, 7 9, 13-18" and *stands
> out* those lines no matter in what order you pass the selected range
> 5. The stand out lines have different background and high contrast while
> other parts of the code are a little faded out
> 6. To give a try
> 6.1. Download attached JSON
> 6.2. Drag and drop to https://tiddlywiki.com/prerelease/
> 6.3. Open highlight-selected-lines/test01
>
> I would like to get feedback and tell me how the efficiency can be
> improved.
>
> Best wishes
> Mohammad
>
> The macro and its sub macro is given below (
> highlight-selected-lines/macro)
>
> \define hslines(tid, from, to, rng, language)<$wikify name="numbers" 
> text=<<rawlist>> ><$vars length={{{ [[$to$]subtract[$from$]add[1]] }}} ><$set 
> name="lines" filter="[[$tid$]get[text]splitregexp[\n]addsuffix[ 
> ]first[$to$]last<length>]"><ol start="$from$" class="code-list"><$list 
> filter="[range[$from$,$to$,1]]" variable=num><$list 
> filter="[enlist<numbers>nsort[]match<num>then[code-selected]else[code-notselected]]"
>  variable=selectedClass><$vars pos={{{ [<num>subtract[$from$]add[1]] }}} 
> ><span class=<<selectedClass>> ><li><$codeblock code={{{ 
> [enlist:raw<lines>nth<pos>]  }}} language=<<__language__>>/></li> 
> </span></$vars></$list></$list></ol></$set></$vars></$wikify>
> \end
>
> \define rng2list() {{{[range[$(start)$,$(end)$]addsuffix[ ]]}}}
>
> \define rawlist()<$list filter="[<__rng__>split[,]split[ ]!is[blank]]" 
> variable=num><$list filter="[<num>search:title[-]]" emptyMessage=<<num>> 
> variable=vrng><$vars start= {{{ [<vrng>split[-]first[]] }}}
>        end=   {{{ [<vrng>split[-]last[]] }}} >
>              <<rng2list>></$vars>                      </$list></$list>
> \end
>
>

-- 
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/CAAV1gMASCQLDR_CMWPkxvCh4jn%2Bh_Skp8cdJef4fS_kkyioJog%40mail.gmail.com.

Attachment: highlight-selected-lines-v2.json
Description: application/json

Reply via email to