Highlight Selected Lines

97 views
Skip to first unread message

Mohammad Rahmani

unread,
Apr 29, 2021, 6:53:18 AM4/29/21
to tiddl...@googlegroups.com
I am working on a tool for my own use case reading a tiddler (including the current tiddler) extracting part of wikitext and showing the code using the code block widget!
It has features to show the line number and highlight selected lines in different background colors to emphasize. 
My own use case is writing wikitext and teaching Tiddlywiki itself to others. I also use it for teaching Numerical Methods in Engineering where
you have to show and explain the Fortran/Matlab/Python to students!

This will be merged into Tamasha.
I am thinking of publishing it as a small independent pugin! I am not sure if there is any interest in the community for that! 

Some screenshots

Fig 1. Using light palette (Tiddlywiki Vanilla)
img_94_chrome.png

  Fig 2. Using dark palette (Tiddlywiki Cupertino Dark)

img_95_chrome.png


Best wishes
Mohammad


Mohammad Rahmani

unread,
Apr 30, 2021, 11:49:55 AM4/30/21
to tiddl...@googlegroups.com
This is a plugin now!

See https://kookma.github.io/TW-Hsl/

If you have the Kookma Plugin Library! Just open your wiki and install through Get More Plugin!
This plugin best works when the official Tiddlywiki Highlight.js plugin is installed


Best wishes
Mohammad

Javier Eduardo Rojas Romero

unread,
May 3, 2021, 10:37:25 AM5/3/21
to tiddl...@googlegroups.com
On Thu, Apr 29, 2021 at 03:22:55PM +0430, Mohammad Rahmani wrote:
> I am thinking of publishing it as a small independent pugin! I am not sure
> if there is any interest in the community for that!

I've just had a look, and this is great! I've started using Tw for
making slides, and this feature you now bring fills one of the gaps I
had.

I have a small suggestion: since you have whole tiddlers dedicated to
the code you show/hightlight, would you consider storing in those
tiddlers the language type? say, for a python code tiddler, add in a
particular field the language name, and have the hightlight macro refer
to that field, instead of having the macro user say that the file is a
python one?

Nonetheless, this is quite nice, thanks for your work!

--
Javier

Mohammad Rahmani

unread,
May 3, 2021, 10:46:27 AM5/3/21
to tiddl...@googlegroups.com
Hi Javier,
Glad you like it!
It does not read a whole tiddler, it read what you pass to src parameter! It can read a whole tiddler like mytiddler as src:{{myTiddler}}
For your case you can have your own macro as below with any customization you like



\define hjl(tid begin end hlrange language offset:0)
<$macrocall $name=hsline src={{{[<__tid__>get[text]] }}} begin=<<__begin__>> end=<<__end__>> hlrange=<<__hlrange__>>
            language={{{[<__tid__>get[lang]] }}} offset=<<__offset__>> />
\end

This wrapper gets the tiddler name contains the code and extract the text and language from text and lang fields to pass to hslines!
You can have more customization!


Best wishes
Mohammad


--
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/YJAKmjakdai0HNKE%40alamut.home.org.
Reply all
Reply to author
Forward
0 new messages