Testing text formatting within Macro Definitions in WikiText

80 views
Skip to first unread message

SteveH

unread,
Aug 19, 2018, 7:46:01 PM8/19/18
to TiddlyWiki
Hi there,

I'm having trouble understanding why certain text formats work 'within' Macro Definitions and others don't.

For example Italics and bold work for the Test Text; but not lists or headings.

Thanks

\define say-hi-using-variables()


"""
//Test text//
"""
''Test text''
"""

* Test text
"""
! Test text

Hi, I'm $(name)$ and I live in $(address)$.



"""
//Test text//

"""
''Test text''
"""

* Test text
! Test text
\end

\define name() Bugs
<$set name="address" value="Rabbit Hole Hill">
<<say-hi-using-variables>>
</$set>

TonyM

unread,
Aug 19, 2018, 8:57:24 PM8/19/18
to TiddlyWiki
Steve,

In the above code you do not close the "name" macro with an end, also in that ext the """ is imbalanced (7), place your text in an empty tiddler and get that working before you place it in the macro. What do you intend using """?

Also macros need to reliably return their content - for example if it contained a select and/or list widget. As a result they are not wikified until the last moment - for example if
<<currentTiddler>>

where contained in a macro it would only be evaluated at the time of the macro call, then the result wikified.

I was looking for a good example how to wikify the content of your above macro, or more to the point, let it be wikified, rather than being returned as mostly static text. However I now see it is broken wiki text to start with.

Try this
\define say-hi-using-variables()
//Test text//
''Test text''

* Test text
! Test text

Hi, I'm $(name)$ and I live in $(address)$.
//Test text//

''Test text''

* Test text
! Test text
\end
<$set name="address" value="Rabbit Hole Hill">

<<say-hi-using-variables>>
</$set>


Note: The blank line above <<say-hi-using-variables>> is important, I am not sure why for the moment.

Regards
Tony

SteveH

unread,
Aug 19, 2018, 11:56:55 PM8/19/18
to TiddlyWiki

Hi Tony,

I've tried your example and it didn't work for me (refer attached pdf).

Here's three tiddlers to show you what I'm trying to achieve. (I'm not using the rabbit hole address part of the macro)

Tiddller 1:

Title:Variables example 1 Female Refund


\define say-hi-using-variables()

{{$(name)$##Salutation}}
{{$(name)$##HerFirstName}}
"""
{{$(name)$##HerLastName}}
{{$(name)$##PostAddress1}}
{{Suburb##Cast}}



"""

"""
Dear {{$(name)$##HerFirstName}},

//INCOME TAX ASSESSMENT 2018//

"""
 
"""
We attach your income tax assessment for the {{CYR}}, which has been checked and agreed with your return as lodged.

"""
"""
The tax office shows a refund  of  ${{$(name)$##HerTax17}}  for you  which should have been  forwarded  to your  nominated  bank account.
 
"""
Please contact us if you have any queries.
 


{{YoursFaithfullySteveHarding}}
"""

\end

\define name() Newclient C


<$set name="address" value="Rabbit Hole Hill">

<<say-hi-using-variables>>
</$set>


Tiddler 2 (data tiddler)

Title:Newclient C


HerTax17:9,999
Salutation:Ms
HerFirstName:Clear
HerLastName:Person
PostAddress1:2 Victoria Street

Tiddler 3
Title:YoursFaithfullySteveHarding

"""
Yours Faithfully,




Steve Harding

Tony's example.pdf

SteveH

unread,
Aug 20, 2018, 12:06:37 AM8/20/18
to TiddlyWiki
This setup lets me change the client name on the template letter (tiddler 2).

However, as alluded to I can't use wikitext formatting in the body of the letter: eg !INCOME TAX ASSESSMENT 2018 instead of
//INCOME TAX ASSESSMENT 2018//.



Mark S.

unread,
Aug 20, 2018, 12:16:57 AM8/20/18
to TiddlyWiki
The triple quotes turns off the headers. It appears to work when not wrapped in triple quotes.

Like Tony mentioned, there appears to be an imbalance of triple quotes. The very last one doesn't seem to be necessary. This version looks almost like a formatted form letter:

\define say-hi-using-variables()

"""
{{$(name)$##Salutation}} {{$(name)$##HerFirstName}}  {{$(name)$##HerLastName}}
{{$(name)$##PostAddress1}}
{{Suburb##Cast}}

Dear {{$(name)$##HerFirstName}},

"""


! //INCOME TAX ASSESSMENT 2018//


 
"""
We attach your income tax assessment for the {{CYR}}, which has been checked and agreed with your return as lodged.

The tax office shows a refund  of  ${{$(name)$##HerTax17}}  for you  which should have been  forwarded  to your  nominated  bank account.
 
Please contact us if you have any queries.

{{YoursFaithfullySteveHarding}}

"""


\end


Good luck!
-- Mark

SteveH

unread,
Aug 20, 2018, 12:42:32 AM8/20/18
to TiddlyWiki
Thanks Mark (and Tony),

I'll try that when I get a chance.

Yes, it is a form/template letter setup that I'm trying. - I change the name (accessing the tiddler using Vim); then print the letter.


Regards

Steve

Reply all
Reply to author
Forward
0 new messages