List inside macro parameter

56 views
Skip to first unread message

Thibault Boullier

unread,
Aug 16, 2024, 9:25:29 AM8/16/24
to TiddlyWiki
Hi everyone,

I work on tiddlywiki for 5 weeks. and I want to customise tips blockquote for user. 

My users have no knowledge in code. so I want to create snippet and macro to create blockquote for tips, warning and Importante informations. 

for exemple, for tips i would like generate something like this :Tips_Visu.png
to do that I use this code : 

<blockquote class="Tips_BQ">
  <div class="Tips_body">
    <$transclude tiddler="$:/core/images/tip" class="tips-icon"/>
    <strong class="tips-Title">Tips</strong>
    <div class="tips-text">
      Ceci est une liste de conseil :
      <ul>
         <li>premier élément</li>
         <li>second élément</li>
      </ul>
    </div>
  </div>
</blockquote>

(Sorry about the formatting, I couldn't find the tag for the code.)

but for a result like this I add some html code. 
I try something like this : 

\define InsertTips(text)
<blockquote class="Tips_BQ">
  <div class="Tips_body">
    <$transclude tiddler="$:/core/images/tip" class="tips-icon"/>
    <strong class="tips-Title">Tips</strong>
    <div class="tips-text">
          $text$
    </div>
  </div>
</blockquote>
\end

<<InsertTips "Ceci est une liste de conseil :
      <ul>
         <li>premier élément</li>
         <li>second élément</li>
      </ul>
">>

it's working, but there are again html code for user. So I try something like this : 

\define InsertTips(text)
<blockquote class="Tips_BQ">
  <div class="Tips_body">
    <$transclude tiddler="$:/core/images/tip" class="tips-icon"/>
    <strong class="tips-Title">Tips</strong>
    <div class="tips-text">
          $text$
    </div>
  </div>
</blockquote>
\end

<<InsertTips "Ceci est une liste de conseil :

* premier élément
* second élément
">>

but the result is not good : 
2024-08-16_14h54_41.png

because is not in list. 

And finally I try like this : 

\define InsertTips(text)
<blockquote class="Tips_BQ">
  <div class="Tips_body">
    <$transclude tiddler="$:/core/images/tip" class="tips-icon"/>
    <strong class="tips-Title">Tips</strong>
    <div class="tips-text">
      <$wikify name="wikify_Text" text={{!!text}} output="html">
        <$transclude tiddler=wikify_Text />
          $text$
      </$wikify>
    </div>
  </div>
</blockquote>
\end

<<InsertTips "Ceci est une liste de conseil :

* premier élément
* second élément
">>

so the blockquote it's created but without text inside :

2024-08-16_14h59_46.png

I don't understand How I can transmit tiddly text inside macro variable and transform like html code to have liste inside tips blockquote. 

Someone can help me to resolve this point please ?
(I try with ChatGPT but it's have no accurate and good solution for this problem ^^)

P.S: I'm sorry for my english, I try to improve it but it's not my native langage. ;-)

Eric Shulman

unread,
Aug 16, 2024, 10:16:03 AM8/16/24
to TiddlyWiki
Hi!

The problem is that in order to render bullet items, you need the `$text` macro param
to be rendered using "block" mode, rather than "inline" mode.

To achieve this, all you need to do is to include a blank line in your macro,
immediately before the `$text$`, like this:

```
\define InsertTips(text)
<blockquote class="Tips_BQ">
  <div class="Tips_body">
    <$transclude tiddler="$:/core/images/tip" class="tips-icon"/>
    <strong class="tips-Title">Tips</strong>
    <div class="tips-text">

          $text$
    </div>
  </div>
</blockquote>
\end

<<InsertTips "Ceci est une liste de conseil :

* premier élément
* second élément
">>
```

So, as you can see, your solution was only 1 byte away from working!

Also, be advised that most discussion/questions related to TiddlyWiki
has moved to https://talk.tiddlywiki.org/.  Please join us there!

enjoy,
-e
Reply all
Reply to author
Forward
0 new messages