\rules pragma

144 views
Skip to first unread message

Jean-Pierre Rivière

unread,
Apr 9, 2021, 4:10:55 AM4/9/21
to TiddlyWiki
I recently had a look at pragmas. One of them is \rules which is used in https://tiddlywiki.com/static/Using%2520Stylesheets.html with arguments. It's still not much documentation although it's worthwhile reading.

 Where could I fetch some more information about \rules (its grammar, its parameters, why use it)  ?

TIA!
-- 
JeanPierre

PMario

unread,
Apr 9, 2021, 5:53:42 PM4/9/21
to TiddlyWiki
Hi JeanPierre,

There isn't too much docs about pragmas[1], because the \rules pragma can have unexpected side effects, if you don't know the underlying parser process well.

TW has many wikitext - rules: https://tiddlywiki.com/#WikiText

Every one of them has 1 or 2 core javascript modules [2] associated. They have a module-type: wikirule. A wikirule can be a "block" or "inline" type.
eg:
<<<
blockquote
<<<

The associated js-name is: quoteblock

So there are the following pragma rules that can be used for blockquote

\rules only quoteblock
or
\rules except quoteblock

So if you use \rules only in a tiddler, the only rule the will be detected is the blockquote wikitext rule.
If you use \rules except, all wikitext rules will be active, except the blockquote.

only and except are 2 basic parameters that are allowed for the \rules pragma.

Every rule can have several wiki-rule names. eg: The one you linked to [3]

\rules only filteredtranscludeinline transcludeinline macrodef macrocallinline html

The rule above only uses the defined wikitext rules and deactivates all others. .. This mechanism is heavily used in the rendering templates, that is used by the TW save mechanism. ... It allows us to control the parsing mechanism on an almost "per wiki-rule" basis. ...

The downside is, that you need to know the parser code quite well. eg:

\rules only quoteblock

! heading

<<<
test
<<<

>asdf


Will only render the test text as a blockquote. The asdf text will be plain text, because the associated name is: list [4]

list handles:  *  #  ;  :  > ... So if you use \rules only list ... you'll get all of them.

The other names can be found, if you look at the source code of every single rule that is module-type: wikirule and looks similar to the quteblock [5] code.

I hope this helps. have fun!
mario

[1] https://tiddlywiki.com/#Pragma

PMario

unread,
Apr 9, 2021, 6:13:23 PM4/9/21
to TiddlyWiki
Hi,

WARNING: Be careful if you change settings there. It can brick your wiki!
-m

Jean-Pierre Rivière

unread,
Apr 16, 2021, 11:41:44 AM4/16/21
to TiddlyWiki
Sorry for being late to thank you for your very interesting response. Things are clearer. It's enough to have an idea of the beast. this could be useful later on, and it's good to know that such things could be dno if need be.

Regards.

PMario

unread,
Apr 16, 2021, 12:04:54 PM4/16/21
to TiddlyWiki
On Friday, April 16, 2021 at 5:41:44 PM UTC+2 jn.pierr...@gmail.com wrote:
Sorry for being late to thank you for your very interesting response. Things are clearer. It's enough to have an idea of the beast. this could be useful later on, and it's good to know that such things could be dno if need be.

Regards.

You are welcome!
-m
Reply all
Reply to author
Forward
0 new messages