Have you tried using the <$codeblock> widget?


On Saturday, January 16, 2021 at 11:00:48 PM UTC+1 Soren Bjornstad wrote:

> In my upcoming TiddlyWiki book 
> <https://groups.google.com/g/tiddlywiki/c/NIJQLBLwVHI>, I have a number 
> of snippets where I'd like to present side-by-side wikitext and rendered 
> output. I've accomplished this by creating a template that displays two 
> divs with 50% width, the contents of each div transcluding a different 
> template in turn: a template that displays the current tiddler in block 
> mode, and a template that displays the wikitext of the current tiddler.
>
> The trick is in the wikitext template: I can't figure out how to get the 
> built-in highlight.js syntax highlighter ($:/plugins/tiddlywiki/highlight) 
> to apply to the wikitext being dynamically transcluded in this way. (The 
> *HTML* language does a good enough job on wikitext that it's very helpful 
> to have it.) The obvious methods like using a code fence fail since they 
> literally display the transclusion syntax "{{!!text}}" or 
> "<<currentTiddler>>" instead of the result of that transclusion. Currently 
> my best attempt is the following:
>
> <pre class="html hljs xml"><code><$text text={{!!text}}/></code></pre>
>
> (I pulled the <pre><code> HTML out of my browser developer tools while 
> displaying a normal code-fenced, highlighted snippet.)
>
> This *almost* works, except the highlight plugin doesn't kick in. I 
> suspect this might be since I am using a <$text> widget, but I don't know 
> the plugin well enough to be sure that's the cause. If I try to remove the 
> <$text> widget, TiddlyWiki first renders the contents of the tiddler and 
> then embeds the resulting HTML within the <pre> block, which looks bizarre 
> and still doesn't syntax-highlight anything, so that's no good anyway:
>
> [image: foo.png]
>
> Is there any way I can get the highlight plugin to apply to this 
> transcluded wikitext?
>

-- 
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/45f7604c-3306-492e-a643-99ed55cd1619n%40googlegroups.com.

Reply via email to