[TW5] transclude list items parsing behavior

150 views
Skip to first unread message

stefan.f...@gmx.at

unread,
Apr 15, 2014, 2:31:49 PM4/15/14
to tiddl...@googlegroups.com
Hi all,

I would like to to transclude a list of tiddlers (specified as a filter expression), each containing unordered list items. The transcluded items should render in such a way that they appear as if they were written directly in-place. So for instance I have tiddler A tagged with "foo" and the following content:

* list item
** sub list item

And tiddler B with content:

* list item
** <$list filter="[tag[foo]]"><$transclude field="text" mode="block"/></$list>

Which (expectedly) renders:

<ul>
 
<li>list item</li>
 
<li><ul>
     
<li>list item
       
<ul><li>sub list item</li></ul>
     
</li>
   
</li></ul>
</ul>

But instead, the resulting rendered list should "behave" like:

* list item
** list item
*** sub list item

Which translates to:

<ul>
 
<li>list item
   
<ul>
     
<li>list item
       
<ul><li>sub list item</li></ul>
     
</li>
   
</ul>
 
</li>
</ul>

Is there a simple way to do this? Or do I have to write a custom parser for this?

Thanks!

BTW: TW5 is awesome! :)

Best,
S

Stephan Hradek

unread,
Apr 15, 2014, 4:30:59 PM4/15/14
to tiddl...@googlegroups.com
Try this for tiddler B:

* list item<$list filter="[tag[foo]]"><$transclude field="text" mode="block"/></$list>

stefan.f...@gmx.at

unread,
Apr 15, 2014, 4:59:01 PM4/15/14
to tiddl...@googlegroups.com
Hi Stephan,


On Tuesday, April 15, 2014 10:30:59 PM UTC+2, Stephan Hradek wrote:
Try this for tiddler B:

* list item<$list filter="[tag[foo]]"><$transclude field="text" mode="block"/></$list>


thank you, this works, but it's not what I want. I should have explained my motivation for this kind of markup: I would like to construct outlines where parts are stored inside separate tiddlers. This way I have blocks of logically independent sub-outlines I can use in different outline structures without duplicating them. The kind of markup you suggested works, of course, but it's counterintuitive and it's hard to see clearly the structure of the outline.
 
Best,
Stefan

Stephan Hradek

unread,
Apr 15, 2014, 5:29:40 PM4/15/14
to tiddl...@googlegroups.com


Am Dienstag, 15. April 2014 22:59:01 UTC+2 schrieb stefan.f...@gmx.at:
The kind of markup you suggested works, of course, but it's counterintuitive and it's hard to see clearly the structure of the outline.

And it's hard for me to understand what you mean. Maybe you best show some real life examples?

stefan.f...@gmx.at

unread,
Apr 16, 2014, 1:58:06 PM4/16/14
to tiddl...@googlegroups.com
Hi,


On Tuesday, April 15, 2014 11:29:40 PM UTC+2, Stephan Hradek wrote:

And it's hard for me to understand what you mean. Maybe you best show some real life examples?
 
Okay, maybe this wasn't the best way to introduce the problem. I think there are two separate questions: (1) Why I would want to do this and (2) how I want it to function.

Whilst trying to adress (1) I'm not sure I am able to show you how valuable the suggested use case is or why one would even consider it. It's a conceptual question that relates to the way of using outlines for information/knowledge structuring and to a specific way of thinking. I use outlines to structure thoughts. As it happens most thoughts or propositions cannot be fully expressed as a simple parent/child statement - instead there are many parent/child relations possible, each covering different aspects of an idea, describing connections between ideas and thoughts and concepts and whatnot. For that reason it would be nice to be able to "contextualize" specific outline fragments by including them in different locations/contexts. Practial (artificial) example, while shifting to question (2):

tiddler named "cupcake ingredients":

* cupcake ingredients
** flour
** sugar
** cocoa
** olive oil
** baking soda
** ...

tiddler named "cupcake reciepe":


* cupcake reciepe
**{{cupcake ingredients}}
** directions
*** make some delicious cupcakes

should render:
  • cupcake reciepe
    • cupcake ingredients
      • flour
      • sugar
      • cocoa
      • olive oil
      • baking soda
      • ...
    • directions
      • make some delicious cupcakes
tiddler named "shopping list":

* shopping list
**{{cupcake ingredients}}

should render:
  • shopping list
    • cupcake ingredients
      • flour
      • sugar
      • cocoa
      • olive oil
      • baking soda
      • ..
Obviously this can be solved by copypasting lists around, but even in this simple case it is helpful to have not redundancies but linking do the work. After all, if I decide to list "salt" under "ingredients" but forget to add it to the shopping list, I would bake myself some tasteless cupcakes, because I tend to be a mindless list-following groceries shopper...

Do you see how this can be helpful in more complex cases?

It starts to get really powerful for quick-and-dirty information aggregation where, for instance, I would tag several lists with tag "pro" and some others with "con" and have them listed somewhere deep inside another list so I get all pros and cons right in place where I need them plus additional information (e.g. why is it good/bad) encoded as subitems of these pro and con lists. Maybe I also want to use each of these lists independently inside another branch, resulting in completely different contextual meaning.

After thinking about it I realised that there are several difficulties here. For instance I would need (pseudo)markup like

* item
** {{[tag[pro]]}}

to behave as if each item with tag "pro" was included as a subitem in the list with ** preceding each item, additionally stripping each * in the included lists and adding ** to every subitem in these lists. So if there was a tiddler "list" tagged with "pro":

* fact 1
** explanation of fact 1
*** some subitem of explanation

I would in fact need to behave {{[tag[pro]]}} like a loop with additional input pre-processing:

for each tiddler with tag "pro":
 
return
    each line
with additionally (current level-1) asterisks prepended if it is a list item OR
    each line
with additionally (current level) asterisks if there are no list items in the tiddler

And this seems to be a rather unfortunate hack. Of course I could implement a macro like:

* item
<<include-lists "**" "[tag[pro]]">>

But this makes it hard to read and seems not clean either. So maybe it will be better to implement a parser module for this kind of markup.

* item
**<<subitem-each [tag[pro]]>>

But which markup should I use? This seems to be a separate kind of content inclusion mechanism, alongside transclusion and macros.

Does this all look silly to you? Do you understand better now what I mean?

Best,
Stefan

Stephan Hradek

unread,
Apr 16, 2014, 4:35:00 PM4/16/14
to tiddl...@googlegroups.com
I'm still not sure that I get it, but how about this syntax?

* cupcake reciepe{{
cupcake ingredients
||listTransclude
}}
** directions
*** make some delicious cupcakes

Implemented on http://tw5magick.tiddlyspot.com/ Feel free to look around.

Stephan Hradek

unread,
Apr 16, 2014, 4:49:52 PM4/16/14
to tiddl...@googlegroups.com
Something about your tiddlers seems broken to me. Why would you have the first level of the "Cupcake Ingredients" list be "Cupcake Ingredients" while the title already says so?

So I've played around a bit and offer you another approach on the same site, now with Capitalised Titles.

The recipe cann now look like this:

* Cupcake Reciepe
** {{ Cupcake Ingredients||asList }}
** directions
*** make some delicious cupcakesCode hier eingeben...

and the ingredients must be:

* flour
* sugar
* cocoa
* olive oil
* baking soda


Martian

unread,
Apr 12, 2016, 10:14:30 AM4/12/16
to TiddlyWiki
Hello, Stephan!

Sorry for up this question.
I have just tried to copy tiddlers Cupcake Reciepe, Cupcake Ingredients, asList, listTransclude from your http://tw5magick.tiddlyspot.com/ (which is 5.0.7-beta) into my fresh tw5 which is 5.1.11 and see that Cupcake Reciepe don't render as nested list items (as in tw5magick.tiddlyspot.com), but as just inline text 
  • Cupcake Ingredients * flour * sugar * cocoa * olive oil * baking soda


What do you think could be a reason?

I can see that $:/core/modules/filters/is/current.js is slightly differ between 5.0.7-beta and 5.1.11. Could it be the reason?

WBR,
Martian.

среда, 16 апреля 2014 г., 23:49:52 UTC+3 пользователь Stephan Hradek написал:

Martian

unread,
Apr 12, 2016, 10:47:39 AM4/12/16
to tiddl...@googlegroups.com
Ah! I got it!

widget <$transclude /> should now be written as <$transclude mode="block"/> and then it works as in http://tw5magick.tiddlyspot.com/ examples.
Reply all
Reply to author
Forward
0 new messages