Mohammad,
I have seen this extra leading and trailing space issue a few times. This
is in part why I use the method I proposed which uses the link widget to
create the link.
Others have suggested passing such values with leading and trailing spaces
to another macro to "sanitise them" eg if parameter is the value returned
(Without brackets but leading and trailing spaces.)
<<macro parameter>>
\define macro(input) [$Input$]
Regards
Tony
On Friday, 4 January 2019 21:47:08 UTC+11, Mohammad wrote:
>
> Hi Tony,
>
> Clever solution. I bookmark this solution.
>
> By the way as S. S above indicated there is some confusing cases with
> toc-macro uses caption/title when caption is not existed or empty.
> For my case, I need to remove the extra spaces when caption is used, and I
> realized that is because line breaks in my code! See my first post above.
>
> --Mohammad
>
>
> On Friday, January 4, 2019 at 2:01:23 PM UTC+3:30, TonyM wrote:
>>
>> Mohammad,
>>
>> If the purpose of this macro is to show the caption then if not existing
>> the title then there is now a more elegant way.
>>
>> <$list filter="[all[current]has[caption]get[caption]]
>> ~[{!!title}]"></$list>
>>
>> However this returns a tiddler link even to the caption
>>
>> So Try this
>> <$list filter="[all[current]has[caption]get[caption]] ~[{!!title}]"
>> variable=name>
>> <$link to=<<currentTiddler>> tooltip="Custom tooltip"><<name>></$link>
>> </$list>
>>
>> Or make a macro
>> \define caption-title()
>> <$list filter="[all[current]has[caption]get[caption]] ~[{!!title}]"
>> variable=name>
>> <$link to=<<currentTiddler>> tooltip="Custom tooltip"><<name>></$link>
>> </$list>
>> \end
>>
>> and use <<caption-title>> no paramters to always show first the caption,
>> then the titlewith an active link.
>>
>> Regards
>> Tony
>>
>>
>> On Friday, 4 January 2019 19:18:46 UTC+11, Mohammad wrote:
>>>
>>> I have a macro as below to show the title or caption of a tiddler based
>>> on the availability of caption field
>>>
>>> \define mac(tid)
>>> [<$view tiddler=$tid$ field="caption">
>>> <$view tiddler=$tid$ field="title"/>
>>> </$view>]
>>> \end
>>>
>>> Then I have several tiddlers like t-2016, t-2017, t-2018, t-2019. The
>>> two tiddler t-2017 and t-2018 also have c-2017 and c-2018 as caption.
>>>
>>> Using the above macro as below gives the below results
>>>
>>> Note <<mac t-2017>> and <<mac t-2018>> and <<mac t-2019>> and <<mac t-
>>> 2016>> give different result.
>>>
>>> Result:
>>>
>>> Note [c-2017] and [c-2018] and [ t-2019 ] and [ t-2016 ] give different
>>> result.
>>>
>>> As you can see extra spaces are inserted when title is shown! What is
>>> the problem.
>>>
>>> --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 [email protected].
To post to this group, send email to [email protected].
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/3db8ac50-cab4-4de1-9808-f9f1004b962e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.