Wikitext for "Power Fold" - What would it take?

I’m pretty sure I won’t be able to implement this idea but I’m still curious what it would take:

I want a + (or possibly a §, and possibly preceded by empty row) at the start of a row to be a wikitext command that renders the text as collapsible/expandable. Wikitext, NOT a widget or a macro!

The targeted content should be everything from the + until the next row-prefixing occuence of it, or end-of-tiddler. No closing marker/tag!

Nestable
If the prefix is ++, then this is a “child” to the + parent, and will thus also be hidden if the parent + is collapsed. (This is comparable to the wikitext for ordered/unordered lists i.e # and *)

Hierarchical numbering
Further, the rendered view automatically numbers the sections hierarchically. The following shows what this means:

1
1.1
1.1.1
1.2
1.2.1
2

Toggle button
In view mode, that number (and possibly the “label”, see below) serves as a toggle button to expand/collapse. (Alternatively, an explicit + button.)

Label
If the + is followed by a blank space character ( ), there is no label next to the rendered button. If there is no space, then the label is the string up to the next space character (e.g +mylabel notlabel). And for spaced labels, another + character, that is not a prefix to a new row, marks the end of the label. For example (as seen in editor):

+These words are a label all up to here+ but not these words, which are instead content in the collapsible section.

+BUT this section only has the word "BUT" as label since there is no end marker in the same row, so these very words are instead content.

(As are these words, i.e they're also content to the "BUT" section.)

…so, what would it take to create something like this? I know 5.3.0 brought with it some new possibilities but I’m guessing js would still be needed, right? And, yes, I know it is not “backwards compatible” because of the multitude of users prefixing their sentences with + signs. :wink:

Did I clarify wikitext not a widget or a macro?

TLDR;
The first step would be to implement the desired functionality with pocedures and functions. Once it works as desired they can be configured to be used with the custom markup plugin.


There are several problems with your specification.

  • The TW parser either needs 2 new-lines or an “end-tag” to determine where a block starts and where it ends.
  • So for several paragraphs you’ll need an end-marker

You are a good wikitext programmer. So if you would use procedures to implement your functionality, my custom-markup plugin can convert it into it’s own markup with the limitations pointed out.

With the custom-markup plugin we should be able to “call” every procedure or existing widget.

By default there are 6 block-markers

  • tick (´), single (›), degree (°) … Start-marker for 1 paragraph
  • angle (»), approx (≈), pilcrow (¶) … Start-markers for multi paragraphs which need an end-marker

Aha, that’s encouraging to hear!

Well, the “end-tag” I describe is effectively the “start-tag” of the next block, and, lastly, the end-of-the-tiddler. Is that not possible?

Have you had a look at @Mohammad 's section plugin.
It implements folding for ! headings.
Perhaps that is a way to go.
@saqimtiaz ’ Streams - on a completely different bases - also can behave like this.

Yeah, thanks, the Section plugin definitely has bits of what I’m hoping for, not all though.

I love how succinctly markdown commands “do this here”. It is minimal distraction during authoring, and even reading… at least if the markdown tag is well chosen, i.e if it “resembles” or directly associates with the output (e.g * bullet or __underlined__, and if it is easily accessible on the keyboard.

This may not be exactly what you wanted, but check this tiddler for a demo of collapsible outliner like functionality for unordered list. Here is the instruction to install it.

This is based on solution given by buggyj in another discussion in this forum - buggyj’s code and viewtoolbar button based on the code. It works with chrome only.

1 Like

I think this request is quite specific when we can possibly make something similar if we have some wiggle room.

We may be able to clone the behaviour for * bullets, as a + bullets, also add it to the auto list plugin so you can use enter and tab/shift tab.

  • This different bullet set can use a different class or html tag which causes the children to be hidden until you click the parent line, this CSS is beyond me.
  • Alternatively you could use the existing bullets and introduce a class to each item that may be toggles by its parent.
* something<br> morte info
**.h A child item with the hide class, that can be toggled to open with a click of the parent
1 Like

No, because you do not know what the next start-tag will be, so you cannot search for it.

@arunnbabu81 - is there a plugin for that collapsible outliner? I can’t tell from visiting the links you provide.

Yeah… like for anything, it depends on how much compromise one can accept. My request is specific because it describes what I want. I’ll do some css experiments but I doubt it can turn out good enough…

I don’t understand. IMO the next start-tag is well defined. For example:

This is some preceding text

+ThisPlus is a start marker where ("ThisPlus" is a label)
The section continues here.

And this line also belongs to the section because when the system reads this,
it still didn't hit any new start tag.
++But this is a new section, a child that has the label "But". The system sees
the starting tag, i.e "\n++". In my previous description I did miss out to
mention "\n" (newline) as a part of the starting tag, so it is a starting tag
because it is a newline directly followed by a +. Thereafter comes a second + 
which signifies that it is a child.
++Here comes a sibling++ This "cuts off" the previous child because, again,
it starts with "\n+" and it is really "\n++" so it is on level 2. The label is
everything up until the marker "<characterButNotNewline>++<space>", i.e the
same number of pluscharacteers followed by a space character.
+Yet another top level item. Identifiable via "\n+" (and label "Yet")

Rest of text, until end-of-tiddler, is also included in the top level item.

(One thing I just realized is the need for a “cut off” to end the “power folding” so that one can return to typing regular text. I think a distinctive enough indicator would be a single + on an otherwise empty row.)

@pmario - am I missing something, or what is not specified here?

Indirectly but related to this thread and the if then else thread I just asked this in the developer topic Reveal according to a variable?

  • The reason is it would open up other ways to hide and reveal content
  • I have a hunch with 5.3.x features including custom widgets, hacking a wikitext symbol, or using @pmario’s Custom Wikitext an effective answer exists to the OT.

@twMat Open this tiddler - it looks like the pic above . Drag and drop the pill from that tiddler to get the collapsible list / outliner. It works only in chrome

Thanks. OK, some 10 tiddlers not packaged as a plugin, and no common tag. That’s a bit frustrating. Is that site the original source for this?

Hit the pill and look at the dropdown the tiddlers are listed and you can search to see all tiddlers involved. The pill can be dragged and dropped. Its a new object we call a filter pill rather than a tag pill.

Yea, the problem is that those tiddlers are all “scattered” if I do import them into my wiki. They’re totally arbitrarily titled and it would be very difficult to clean them out as they don’t even share a common tag.

1 Like

@twMat The full concept belongs to buggyj. He shared the javascript code and CSS in this post for the collapsible outliner.

I just created a viewtoolbar button to alternate between normal tiddler body viewtemplate and custom view template cascade for collapsible outliner.
Since I was not the original creator, I just made a demo of the collapsible outliner in one of my tiddlyhost wikis for the participants of that particular thread to see. I used the filter pill macro from this post for easy drag and drop of this functionality (at that time I was organising tiddlers more using fieldvalues rather than tags).

1 Like

One thing I think I recall about the section plugin is that it can’t nest – and nesting is clearly something vital to what @twMat is envisioning.

I too wish that section-editor could handle nesting, but it’s an elegant and flexible solution for many purposes…

As I wrote in an other thread, the TW parser does not read the wikitext line by line.

  1. It starts from a start-marker and then searches the last corresponding end-marker. Once the text in between has been found it takes this text and hands if over to a new parser, that does the same thing. … and so on till no more nesting structure is found. Then it’s done.

  2. If there is no end-marker provided, use 2 or more newlines as the end-marker and cover the text in an HTML P tag. This rule can only be avoided if there is a predefined end-marker as in 1.

So the first parser would star at +ThisPlus and end at +Yet … So I assume as a regexp it would need to be start: ^+ end: ^+ (which means start of the line followed by a plus)

Then there should be a “Label”. So we need a new rule for this label. In your spec the label is 1 word only. So the first word would be used as a label.

As a User I would not be happy with that. What if I want several words to be used as a label?

As a developer and a user There is an existing convention for wikitext rules, which allows to define a CSS class. Eg:

!.css-class text which creates: <h1 class="css-class">text</h1>
or
*.css-class text which creates: <ul><li class="css-class">text</li></ul>

For consistency reasons the new rules should also allow that convention, which makes the “Label” part of your spec much more complex.


Someone may say. OK then I do not want the “class” definition. – I’d say some users may argue, that wikitext syntax needs to be consistent. …

Let me telly you, we need the custom CSS class´ definition for styling. It would be one of the first requests that will come up. Together with “multi word labels”

I think “It is more complex as it seems at first”


As I wrote If there is some procedure code that can do what you want, it can be covered in custom syntax. But there has to be the macro / procedure code first

Hi @twMat I’m searching for “how to fold list outline” today and come across this.

I think to achieve logseq style foldable outline list, maybe we can just modify the core list item widget to achieve this?

I’m not sure if this is possible to be done as a plugin that not overwriting core list element widget, if there are any existing folding-list plugin, please tell me.

Added Feat: allow link to section mark by linonetwo · Pull Request #7744 · Jermolene/TiddlyWiki5 · GitHub

So I can write a plugin to fold a list item, and auto add an ID for that li, then store the folding status in a field. Or maybe just ask @Mohammad to use it in the section editor, so every block can be folded.

Currently what I feel uncomfortable with the section editor is:

  1. need to add se-type. But I hope every tiddler’s list can be folded without config
  2. I want to fold list like logseq
  3. I hope it can store state in a field, so when switch between WYSIWYG editor, the state keeps
    1. and not creating extra tiddler for state
2 Likes

In many ways, especially with shadow tiddlers there is good reason to have external states but it is true we could come up with a method to have a single “state tiddler” for any tiddler, but using separate fields to accommodate different states.

  • Rather than using the Qualify macro we could have an equivalent that returns the state tiddler/fieldname to use for a state.
  • Field names could now even use system prefixes, and the qualify number as well.
    • Eg a field name $:/temp/pluginname/state or if used more than once in a single tiddler $:/temp/pluginname/state-5423879 (like qualify)
  • The advantage of a single state tiddler is we could add them to a payload when moving a tiddler elsewhere, and carry multiple states.
    • This actually highlights something about states and that is does the setting it represents belong to the wiki, or the tiddler.

However remember tiddlywikis statement about tiddlers;

Tiddlers are the fundamental units of information in TiddlyWiki. Tiddlers work best when they are as small as possible so that they can be reused by weaving them together in different ways.