[tw5] commenting your wikitext macros?

334 views
Skip to first unread message

Mark Brown

unread,
Nov 21, 2014, 8:15:49 PM11/21/14
to tiddl...@googlegroups.com
Hi all.

It's amazing how much you can do with widgets and macros in tw5. Some of my macros have become quite complex and difficult to read. For example, one of my citation macros is:

\define cite(citekeys:"")
(<$list filter="$citekeys$ +[sort[]] +[each[authors]] +[first[]]"><<citeauths>><$list filter="$citekeys$ +[authors{!!authors}] +[sort[]]">, <$link tiddler="currentTiddler">{{!!year}}</$link></$list></$list><$list filter="$citekeys$ +[sort[]] +[each[authors]] +[rest[]]">; <<citeauths>><$list filter="$citekeys$ +[authors{!!authors}] +[sort[]] ">, <$link tiddler="currentTiddler">{{!!year}}</$link></$list></$list>)
\end

What's best practice for inserting comments? Or is that antitthetical to tw5 philosophy? Should I be constructing macros differently?

Stephan Hradek

unread,
Nov 22, 2014, 2:18:29 AM11/22/14
to tiddl...@googlegroups.com
As whitespace helps in commenting but whitespace is meaningfull in wikitext, I would create a seperate tiddler where I reformat and describe the text. So no inline comments in the macro.

OTOH - as this is at least double effort  - you could try what happens if you insert comments containing linebreaks. like <!--

this is a comment

-->so

Jeremy Ruston

unread,
Nov 22, 2014, 11:36:16 AM11/22/14
to TiddlyWiki
Hi Mark

> Some of my macros have become quite complex and difficult to read

You can use line breaks to make things a bit easier to read:

\define cite(citekeys:"")
(<$list filter="$citekeys$ +[sort[]] +[each[authors]] +[first[]]">
<<citeauths>>
<$list filter="$citekeys$ +[authors{!!authors}] +[sort[]]">,
<$link tiddler="currentTiddler">{{!!year}}</$link>
</$list>
</$list>
<$list filter="$citekeys$ +[sort[]] +[each[authors]] +[rest[]]">;
<<citeauths>>
<$list filter="$citekeys$ +[authors{!!authors}] +[sort[]] ">,
<$link tiddler="currentTiddler">
{{!!year}}
</$link>
</$list>
</$list>)
\end

You can also include comments of the form <!-- this is a comment -->

The only thing to watch out for is that in a very few situations those line breaks will affect formatting. The line breaks are preserved into the HTML. HTML semantics generally mean that adjacent whitespace is collapsed together, so typically the whitespace generated by the linebreaks is collapsed into adjacent white space.

Best wishes

Jeremy.



--
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 http://groups.google.com/group/tiddlywiki.
For more options, visit https://groups.google.com/d/optout.



--
Jeremy Ruston
mailto:jeremy...@gmail.com
Reply all
Reply to author
Forward
0 new messages