TiddlyWiki5 icon indicating copy to clipboard operation
TiddlyWiki5 copied to clipboard

[IDEA] Thinking about a possibility to extend styled blocks with parameters eg: mode=block parameter

Open pmario opened this issue 2 years ago • 4 comments

From: [IDEA] multiline syntax for list wikitext elements #6905

we need a syntactic structure that can appear in inline contexts, but contain block content. It doesn't need to be a special capability of the list parser.

In context of styled blocks

Styled blocks already allow several lines of class and style definitions.

@@.tc-tiddler-frame
@@width:400px;
Some text
@@

It may be possible to extend it like this

@@.tc-tiddler-frame
@@width:400px;
@@mode=block;tag=div
Some text
@@

Just and idea, but I think it would be possible and is backwards compatible. .. The only problem is, that it's a bit of an "overload" ...

pmario avatar Aug 15 '22 16:08 pmario

For the output html, we only need to distinguish:

  • add a line break inside of the html element (inline context).
  • add a new element with display block by default.

Here an example of needed output:

<ul>
    <li>list item one</li>
    <li>list item two with 
        <pre><code>block of
code</code></pre></li>
    <li>list item <br>three</li>
</ul>

Just a crazy idea would be a especial parser rule for how the single carriage-return are parsed.

  • For line break it detects the single carriage-return and it changes them for a <br> element.
@@mode=block;
hello
world
@@

output:

<p>hello<br>
world</p>
  • The hard part would be how it would work with the block elements. The key would be the single carriage-return following of a wikitext that will parsed as block element.
@@mode=block;
* this is a
'''
block of
code
'''
@@

Note: The ''' should be triple backticks in TiddlyWiki output:

<ul>
    <li>this is a
        <pre><code>block of
code</code></pre></li>
</ul>

or adding a (unnecessary) br element

<ul>
    <li>this is a<br>
        <pre><code>block of
code</code></pre></li>
</ul>

An alternative way to activate this special break rule could be @@+br;

The syntax started with @@+ could be used for new especial rules which are a applied to text inside of them. Just another crazy idea.

Alzacon avatar Aug 16 '22 13:08 Alzacon

The mode=block rule is intended to be used like the mode=block for the transclusion-widget.

Try the following code. .. The heading will not be detected, because the parser is in "inline-mode" ... That's why we would need a mode=block

*@@.test some text
!! heading in the next line
@@

The linebreak "problem" can be solved with code at the other post: https://github.com/Jermolene/TiddlyWiki5/issues/6905#issuecomment-1215042576

pmario avatar Aug 16 '22 14:08 pmario

We are talking about the same, "inline-mode" to parse in "block-mode", the result of parsing will be a block element. The difference is the syntax of the trigger. Also the utility class for linebreak can be used as trigger.

Alzacon avatar Aug 17 '22 10:08 Alzacon

Also the utility class for linebreak can be used as trigger.

IMO it doesn't need special treating in the parser because it can be solved with CSS

pmario avatar Aug 17 '22 11:08 pmario