Inserting macro-call into tiddlers with CSS stylesheets

103 views
Skip to first unread message

Andres Gongora

unread,
Apr 24, 2018, 6:03:22 AM4/24/18
to tiddl...@googlegroups.com
I'm trying to insert a macro-call into several tiddlers through stylesheets, such that the macro is processed/called within the tiddler it has been parsed into.
Specifically, I'm trying to add a call to my custom TOC macro at the end of all tiddlers tagged with TOC.

However, it does not work. I can call my macro inside tiddlers with   <$macrocall $name="mytoc" category={{!!title}}/>   and it works fawlessly. But I'm unable to "inject" it with CSS.
What am I missing?



my code:

$:/macros/mytoc (tagged $:/tags/Macro )
\define mytoc(category)
   
<div class="tc-custom-toc">
       
<div class="tc-table-of-contents">
           
<<toc-selective-expandable tag:"""$category$""" sort:"""sort[title]""">>
       
</div>
    </
div>
\end


$:/custom_styles (tagged $:/tags/Stylesheet and of type text/vnd.tiddlywiki)
(this simply applies a box shadow to my TOCs)
<pre> .tc-custom-toc {
    border-radius: 4px;
    padding: 5px 10px;
    border: 1px solid <
<colour message-border>>;
    <
<box-shadow "2px 2px 10px rgba(0, 0, 0, 0.5)">>
}
</pre>


$:/custom_styles2 (tagged $:/tags/Stylesheet and of type text/css)
(This should add the TOC macro call to all tiddlers tagged with "toc"), inserted at the end of the body. If i write   content: 'hello';   it works perfectly.
\rules only filteredtranscludeinline transcludeinline macrodef macrocallinline

.
tc-tagged-toc .tc-tiddler-body:after {
    content
: '<$macrocall $name="mytoc" category={{!!title}}/>';
}




Jeremy Ruston

unread,
Apr 24, 2018, 6:10:38 AM4/24/18
to tiddl...@googlegroups.com
Hi Andres

Does your stylesheet include the following pragma at the top?

\rules only filteredtranscludeinline transcludeinline macrodef macrocallinline


If so, the problem will be that the list of allowed rules doesn't include the rule that understands widget calls like you <$macrocall> widget.


The cleanest way around this would be to put your macrocall widget into a macro at the top of the stylesheet tiddler, and then invoke it in your :after declaration (the rules pragma above allows the macro invocation syntax).


Best wishes


Jeremy



On 24 Apr 2018, at 11:03, Andres Gongora <gongo...@gmail.com> wrote:

I'm trying to insert a macro-call into several tiddlers through stylesheets, such that the macro is processed/called within the tiddler it has been parsed into.
Specifically, I'm trying to add a call to my custom TOC macro at the end of all tiddlers tagged with TOC.

However, it does not work. I can call my macro inside tiddlers with <$macrocall $name="mytoc" category={{!!title}}/> and it works fawlessly. But I'm unable to "inject" it with CSS.
What am I missing?



my code:

$:/macros/mytoc (tagged $:/tags/Macro )
\define mytoc(category)
   
<div class="tc-custom-toc">
       
<div class="tc-table-of-contents">
           
<<toc-selective-expandable tag:"""$category$""" sort:"""sort[title]""">>
       
</div>
    </
div>
\end


$:/custom_styles (tagged $:/tags/Stylesheet and of type text/vnd.tiddlywiki)
(this simply applies a box shadow to my TOCs)
<pre> .tc-custom-toc {
    border-radius: 4px;
    padding: 5px 10px;
    border: 1px solid <
<colour message-border>>;
    <
<box-shadow "2px 2px 10px rgba(0, 0, 0, 0.5)">>
}
</pre>


$:/custom_styles2 (tagged $:/tags/Stylesheet and of type text/css)
(This should add the TOC macro call to all tiddlers tagged with "toc")
.tc-tagged-toc .tc-tiddler-body:after {
    content
: '<$macrocall $name="mytoc" category={{!!title}}/>';
}




--
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 post to this group, send email to tiddl...@googlegroups.com.
Visit this group at https://groups.google.com/group/tiddlywiki.
To view this discussion on the web visit https://groups.google.com/d/msgid/tiddlywiki/ce605a91-21c3-49f8-8598-a4a5b6098304%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Andres Gongora

unread,
Apr 24, 2018, 6:29:35 AM4/24/18
to TiddlyWiki
Thank you for your incredibly fast reply!
I tried as you suggested, but still no luck. I've included a new macro (mytoc2) rigth into the stylesheet, as well as the above rules, with no luck. I've tried to call in within the "content" section as well as a direct call to it. Still no luck.

tagged $:/tags/Stylesheet
\rules only filteredtranscludeinline transcludeinline macrodef macrocallinline

\define mytoc2(category)

   
<div class="tc-custom-toc">
       
<div class="tc-table-of-contents">
           
<<toc-selective-expandable tag:"""$category$""" sort:"""sort[title]""">>
       
</div>
    </
div>
\end

.tc-tagged-toc .tc-tiddler-body:after {
    content
: '<$macrocall $name="mytoc2" category={{!!title}}/>';
}

PMario

unread,
Apr 24, 2018, 7:23:54 AM4/24/18
to TiddlyWiki

On Tuesday, April 24, 2018 at 12:03:22 PM UTC+2, Andres Gongora wrote:
I'm trying to insert a macro-call into several tiddlers through stylesheets,

Why? .. There are much simpler ways to do this?

eg: create a tiddler: $:/myFooter  and
tag it: $:/tags/ViewTemplate

content:

<$list filter="[all[current]tag[TOC]]">
.... your toc comes here ...
</$list>



You basically can use any field name / value combination you want, to activate the block. ... Just if you don't want to use  a tag.

-m

Andres Gongora

unread,
Apr 24, 2018, 7:28:04 AM4/24/18
to TiddlyWiki
I LOVE YOU!
This worked perfectly and did exactly what I wanted. Plus: the name of the tiddlers (one of my macro parameters) are resolved exactly at the correct spot. Thank you very much.

PS: How can I marked this thread as solved? It's the first time I post here

Mat

unread,
Apr 24, 2018, 1:17:38 PM4/24/18
to TiddlyWiki
PS: How can I marked this thread as solved? It's the first time I post here

Don't do that actually. It is only distracting and people have a tendency to pick up on posts regardless if the original question has been answered or not.

BTW, good to see you here!

<:-) 
Reply all
Reply to author
Forward
0 new messages