Hi,
I tried to implement a partial solution to transclude selected lines of 
code from a tiddler contains the whole code.
Then I transcluded the whole code with those selected lines. The whole code 
is opaque but those lines are clear with sharp contrast.
This way one can show a code with few lines stand out to get the viewer 
attention.

To give a try 
1. download attached example, 
2. drop on https://tiddlywiki.com/prerelease/   (use prerelease which has 
the Highlight.js installed)
3.  open test/code-lines  and see how the code looks like

You can do more examples by opening  test/code-lines  and editing the lines.

*Note*: I am not happy with this solution, it seems a little tedious and 
low in performance (a lot of <pre><code> tags are created. What is the 
better solution.



On Friday, January 8, 2021 at 11:10:31 AM UTC+3:30 Mohammad wrote:

> 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 <elsd...@gmail.com> 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 tiddlywiki+...@googlegroups.com.
>> 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 tiddlywiki+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/tiddlywiki/49fe773f-bb0e-4389-beb2-f5a4579d642an%40googlegroups.com.

Attachment: standout-lines-of-code.json
Description: application/json

Reply via email to