How $codeblock works in Tiddlywiki?

219 views
Skip to first unread message

Mohammad Rahmani

unread,
Apr 26, 2021, 11:40:54 AM4/26/21
to tiddl...@googlegroups.com
create a new tiddler
put the below wikitex in that

<$codeblock language=css code="""
.mycls{color:red;}
<span>This </span>
"""/>

<pre><code>
Hello Tiddlywiki
<span>This </span>
</code></pre>



check the result. Tiddlywiki does not allow html code like span tag inside the codeblock but the standard  <pre><code> allows this!
What is wrong here?

Use Case: standout a specific line of code!







Best wishes
Mohammad

Mark S.

unread,
Apr 26, 2021, 11:34:17 PM4/26/21
to TiddlyWiki
When you inspect it, apparently the codeblock widget does much more than simply wrap things it pre/code -- it also converts angle brackets and other special characters into their HTML entities. That's a feature (I think). If you were displaying HTML code, you wouldn't want everything to render, right?

Mohammad Rahmani

unread,
Apr 26, 2021, 11:49:45 PM4/26/21
to tiddl...@googlegroups.com
Hi Mark,
 You are right! but the issue is I cannot do anything inside code block while the original Highlight.js allow this!
  Anyway, the Tiddlywiki Codeblock is you said does more than I expect (using a bare <pre><code>)



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/d2e5f16d-4db0-4bd8-8717-08921f8170c0n%40googlegroups.com.

TiddlyTweeter

unread,
Apr 27, 2021, 1:16:56 AM4/27/21
to TiddlyWiki
Ciao Mohammad & Mark S.

Just FYI I been recently very struck by how brilliant and intelligent the parsing is in TW!
That very cleverness occasionally causes complexities as there is a lot more going on that just using HTML wrappers. 
 
TW, natively, lacks simple <pre> markup which is actually often very needed. 
In some experiments with PMario I used  his excellent Custom Markup (beta) to show , for instance, what a Windows console looks like ... using <pre> in a fairly standard way via novel markup.

Best wishes
TT

Mohammad wrote:
 You are right! but the issue is I cannot do anything inside code block while the original Highlight.js allow this!
  Anyway, the Tiddlywiki Codeblock is you said does more than I expect (using a bare <pre><code>)
 
 'Mark S.' via TiddlyWiki <tiddl...@googlegroups.com> wrote:

Mohammad Rahmani

unread,
Apr 27, 2021, 2:32:12 AM4/27/21
to tiddl...@googlegroups.com
On Tue, Apr 27, 2021 at 9:46 AM TiddlyTweeter <Tiddly...@assays.tv> wrote:
Ciao Mohammad & Mark S.

Just FYI I been recently very struck by how brilliant and intelligent the parsing is in TW!
That very cleverness occasionally causes complexities as there is a lot more going on that just using HTML wrappers. 

I am working on a tiny new plugin that lets you show a code using codeblock with line number and specified lines highlighted (stand out).
If I could use the html inside codblock then the life was much more easier!


 

 
TW, natively, lacks simple <pre> markup which is actually often very needed. 
In some experiments with PMario I used  his excellent Custom Markup (beta) to show , for instance, what a Windows console looks like ... using <pre> in a fairly standard way via novel markup.

WOW, that is amazing! Emulating the console output!

 

Best wishes
TT

Mohammad wrote:
 You are right! but the issue is I cannot do anything inside code block while the original Highlight.js allow this!
  Anyway, the Tiddlywiki Codeblock is you said does more than I expect (using a bare <pre><code>)
 
 'Mark S.' via TiddlyWiki <tiddl...@googlegroups.com> wrote:
When you inspect it, apparently the codeblock widget does much more than simply wrap things it pre/code -- it also converts angle brackets and other special characters into their HTML entities. That's a feature (I think). If you were displaying HTML code, you wouldn't want everything to render, right?

--
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.

TiddlyTweeter

unread,
Apr 27, 2021, 4:35:15 AM4/27/21
to TiddlyWiki
Mohammad wrote:
I am working on a tiny new plugin that lets you show a code using codeblock with line number and specified lines highlighted (stand out).
If I could use the html inside codblock then the life was much more easier!

FYI it is ONLY invoking the parser wia WikiText that creates  the issues ...

Using "code" direct with HTML works EXCEPT you may need to adjust the styling cascade ...

  • <code><h2>No issue (well except styles)</h2></code>

 Screenshot 2021-04-27 103131.jpg

Best wishes
TT

Jeremy Ruston

unread,
Apr 27, 2021, 4:40:15 AM4/27/21
to tiddl...@googlegroups.com
Just to confirm that the <$codeblock code="x"> widget is essentially a synonym for <pre><code><$text text="x"/></code></pre>, but with some special processing to let the highlight plugin do its work.

As TiddlyTweeter points out, if you want to display wikified text in a codeblock then one can simply use the HTML tags.

Best wishes

Jeremy


On 27 Apr 2021, at 09:35, TiddlyTweeter <tiddly...@assays.tv> wrote:


Mohammad wrote:
I am working on a tiny new plugin that lets you show a code using codeblock with line number and specified lines highlighted (stand out).
If I could use the html inside codblock then the life was much more easier!

FYI it is ONLY invoking the parser wia WikiText that creates  the issues ...

Using "code" direct with HTML works EXCEPT you may need to adjust the styling cascade ...

  • <code><h2>No issue (well except styles)</h2></code>

 
<Screenshot 2021-04-27 103131.jpg>

Best wishes
TT

--
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/230d2027-61b5-45b8-be39-a42931b42f2fn%40googlegroups.com.
<Screenshot 2021-04-27 103131.jpg>
Reply all
Reply to author
Forward
0 new messages