Proposal: <<.myClass>> syntax

68 views
Skip to first unread message

Mat

unread,
Apr 11, 2015, 5:17:36 PM4/11/15
to tiddly...@googlegroups.com
If possible, I propose a harmonization of the wikitext syntax for applying styles and classes with that of invocating macros.

Currently we have @@.myClass Here's my text@@ (ref) which as far as I can tell is an arbitrary "one trick pony" in our wikitext syntax. I propose the optional syntax using:

<<.myClass Here's my text>>

and

<<background-color:red; Here's my text>>

Possibly with />> at end instead. And/or to allow something like this

<<.myClass>> Here's my text <</.myClass>>


Blasphemy? Idiocy? Non-sense?


<:-)

Eric Shulman

unread,
Apr 11, 2015, 6:19:09 PM4/11/15
to tiddly...@googlegroups.com
I'm not sure where the need is.  The current syntax supports both
   @@.class.class.class ...@@
and
   @@attr:value;attr:value;...@@
usage.  In addition, the content inside the @@..@@ block can be *any* wiki text -- including macros.  In contrast, your proposed "macro-like" syntax would neccessarily be limited to not being able to embed macros in the content, and would also confuse the usage for *real* macros.

You can even nest the @@...@@ syntax, as long as there is an intervening element to isolate them, like this:

@@.someclassname
//@@font-color:red;THIS IS RED AND ITALIC@@//
@@


Notice how the italics (//) surround the inner @@..@@ block.  This is the trick to isolating the inner block.  Of course, you could use any 'containing' syntax you prefer, such as bold ('') or underline (__)... and, if you don't really want *any* extra formatting applied, you can even use a *made-up* element block, such as <foobar>...</foobar>, like this:

@@.someclassname
<foobar>@@font-color:red;THIS IS RED ONLY@@</foobar>
@@

The only change/addition to syntax that I would like is if there was a diffentiation between the 'open' and 'close' delimiters, so that nesting could be done without needing an intervening element.  Something like "@@(" and ")@@" might work... e.g.:

@@(.someclassname@@(font-color:red;THIS IS RED)@@)@@


your thoughts?

-e
 

PMario

unread,
Apr 11, 2015, 7:10:28 PM4/11/15
to tiddly...@googlegroups.com
On Saturday, April 11, 2015 at 11:17:36 PM UTC+2, Mat wrote:
Blasphemy?

Blasphemy! ...   q;-)

Most widgets have a class=""  attribute. So if you want to have macros with a class, just define it as a parameter.

macro call  <<macroName class:"myClass">> ... done. .. no new syntax needed. It's already in the core :)

have fun!
mario

Mat

unread,
Apr 11, 2015, 7:13:00 PM4/11/15
to tiddly...@googlegroups.com
your thoughts?

My thoughts is that I learnt quite a bit from your informative post ;-)

My general impression is just that we have too many, or at least so many, "syntaxes" where I'm guessing we wouldn't have to. And I believe @@ is special for TW and that maybe it could be reformatted to "harmonize" more with more standard appearences. I reasoned that it superfically operates in a way that a macro might (it calls for some "function" and applies it to whatever is stated next), plus the angled brackets for <<class>> resembles <div id="class"> a bit. At least more than @@class@@.

All the "bracket-syntaxes" add to the learning curve... of course, they serve different purposes, but still... [[.]], {{.}}, <<.>>, [.], {.}, <.>, {{{.}}}, regular brackets, single quotes, double quotes, backticks, triple backticks, slashes in different directions, ... etc etc. And @@. (Hm... we should probably make a character lookup list for tw.com) I'm sure these are all more or less evident for many of you guys but I would also think that even some competent programmers struggle a bit to keep learn them all. I figure that while things do serve different purposes, just maybe some bits can be reused so that if someone is just guessing he might get lucky.

My (naive?) idea was that using something like:


<<.myClass>> Here's my text <</.myClass>>

...could allow for macros inside. I.e the string after the "<<" is matched to the CSS or wherever divs and styles are declared and IF the string is not declared there, then it is a macro invocation. (Or first check for macros then divs/styles).

Anyway, thanks for your informative clarification.

<:-)

Mat

unread,
Apr 11, 2015, 7:15:58 PM4/11/15
to tiddly...@googlegroups.com
pmario
 
Blasphemy! ...   q;-)

hehe

 
Most widgets have a class=""  attribute. So if you want to have macros with a class, just define it as a parameter.

macro call  <<macroName class:"myClass">> ... done. .. no new syntax needed. It's already in the core :)

My point wasn't really about applying a class to widgets but to replace the @@ syntax.
But thanks for that bit of information anyway - I did not know this!

<:-)

PMario

unread,
Apr 12, 2015, 6:44:35 AM4/12/15
to tiddly...@googlegroups.com
On Sunday, April 12, 2015 at 1:15:58 AM UTC+2, Mat wrote:
Most widgets have a class=""  attribute. So if you want to have macros with a class, just define it as a parameter.

macro call  <<macroName class:"myClass">> ... done. .. no new syntax needed. It's already in the core :)

My point wasn't really about applying a class to widgets but to replace the @@ syntax.


There is no need to replace anything. TW wikitext supports html so

<div class="myClass">My text comes here</div>   is very similar to your proposal and is valid HTML code. While the proposal would need to change some core elements. The above example just works.


My first macro suggestion would look like this:

\define myMacro(text, class, el:"div")
<$el$ class="$class$">$text$</$el$>
\end

<<myMacro "some text" class:".myClass">>
or
<<myMacro "some text" class:".myClass" el:"span">>

You can use the development tools, to see the html structure that's created.

If you want ".myClass" to be default the macro code would look like this:

\define myMacro(text, class:".myClass", el:"div")
<$el$ class="$class$">$text$</$el$>
\end

So the call looks like this

<<myMacro "some text">>

Macros are the way to define your own application specific "syntax". You can make macro calls as simple as you want.
But all of this is just using the existing possibilities.

have fun!
mario

Mat

unread,
Apr 13, 2015, 7:51:29 AM4/13/15
to tiddly...@googlegroups.com
Thank you PMario! How would this compare to the @@ benefits that Eric lists, i.e:

[the @@ syntax supports]  @@.class.class.class ...@@  and   @@attr:value;attr:value;...@@
...
content inside the @@..@@ block can be *any* wiki text -- including macros. 
...
nest the @@...@@ syntax


Thank you. FYI, your post has made me look closer at macros thinking I might just manage to learn how to use these!

<:-)

PMario

unread,
Apr 13, 2015, 8:28:08 AM4/13/15
to tiddly...@googlegroups.com
On Monday, April 13, 2015 at 1:51:29 PM UTC+2, Mat wrote:
Thank you PMario! How would this compare to the @@ benefits that Eric lists, i.e:

[the @@ syntax supports]  @@.class.class.class ...@@  and   @@attr:value;attr:value;...@@
...
content inside the @@..@@ block can be *any* wiki text -- including macros. 
...
nest the @@...@@ syntax

TL;DR

- Wikitext create a "predefined" html output.
- Macros let the user create it.

----------------------

As Eric wrote, the wikitext [1] style definition [2] can be easily nested, but the result is "kind of" predefined.

Macros give the user the possibility to create there own structure but are harder to nest. See <$macrocall> [3] widget.

Macros are very useful to remove / hide complexity from the end user. See my <<myMacro "some text">> example. It's much easier to remember, then the first examples. ...

Or have a look at the TW Table Of Contents macro [4] You just need to type: <<toc "Contents>> instead of the whole complex structure [5]. The link contains all toc-xxx macros but anyway. ...

hope that helps
mario

[1] http://tiddlywiki.com/#WikiText
[2] http://tiddlywiki.com/#Styles%20and%20Classes%20in%20WikiText
[3] http://tiddlywiki.com/#MacroCallWidget
[4] http://tiddlywiki.com/#TableOfContentsMacro
[5] http://tiddlywiki.com/#%24%3A%2Fcore%2Fmacros%2Ftoc
Reply all
Reply to author
Forward
0 new messages