cut a String

65 views
Skip to first unread message

Gerald Weis

unread,
Mar 21, 2020, 2:00:51 PM3/21/20
to TiddlyWiki
Hi friends,

my Problem is the follow. i create an Wiki for my Software-DVDs.


at to keep track i have into the titles of the tiddlers Prefixes. the i have an lot groups of software

Now i want a caption on the tableheader without the prefixes.

Example

Tiddlertitle : Software: Abelesoft Audio Creator

tableheader: Abelesoft Audio Creator

i can not accept that i must wrote twice the name of the software

i'd love to have an general macro where i can say wich prefix shoud be removed.

Any ideas


thanks

Mat

unread,
Mar 21, 2020, 2:33:13 PM3/21/20
to TiddlyWiki
Sure

{{{ [<currentTiddler>removeprefix[Software: ]] }}}

<:-)

Mark S.

unread,
Mar 21, 2020, 2:34:56 PM3/21/20
to TiddlyWiki
This is a variation of the articles problem (A/An/The in English) discussed here https://groups.google.com/d/msg/tiddlywiki/ko0TwEryKiM/OeHvf8g3BwAJ

The question is, do you have a known set of title prefixes (e.g. Software: ). Or some way to tell what part of the title is a prefix. (Like a colon).

TonyM

unread,
Mar 21, 2020, 7:34:46 PM3/21/20
to TiddlyWiki
Folks

As with the prefix sort issue its a simple matter to make a sort field in every tiddler and use that instead.

However other than prefixes in natural language including more in a title is building a compound key. This always results in complications like this. I would avoid prefixes in tiddler except as a namespace like $:/

rregards
Tony populate it with a list and actions inside a button.

Mat

unread,
Mar 21, 2020, 8:11:46 PM3/21/20
to TiddlyWiki
I just posted this gh request. Like it if you agree or explain why it is a bad idea.

<:-)

TonyM

unread,
Mar 21, 2020, 9:32:54 PM3/21/20
to TiddlyWiki
Folks,

I back my last post up with an example you can test on TiddlyWiki.com

;Exceptions before
<$list filter="[!is[system]prefix[The ]] [!is[system]prefix[A ]] [!is[system]prefix[An ]] +[sort[]]">

</$list>


<$button>
<$list filter="[!is[system]!prefix[The ]] [!is[system]!prefix[A ]] [!is[system]!prefix[An ]]">
    <$action-setfield $field="sort-key" $value=<<currentTiddler>> />
</$list>
<$list filter="[!is[system]prefix[The ]]">
    <$action-setfield $field="sort-key" $value={{{ [<currentTiddler>removeprefix[The ]] }}} />
</$list>
<$list filter="[!is[system]prefix[A ]]">
    <$action-setfield $field="sort-key" $value={{{ [<currentTiddler>removeprefix[A ]] }}} />
</$list>
<$list filter="[!is[system]prefix[An ]]">
    <$action-setfield $field="sort-key" $value={{{ [<currentTiddler>removeprefix[An ]] }}} />
</$list>
Set ALL sort Keys
</$button>



;Exceptions after
<$list filter="[!is[system]prefix[The ]] [!is[system]prefix[A ]] [!is[system]prefix[An ]] +[sort[sort-key]]">

</$list>

Notes
  • The above is a first draft, and it updates every tiddler not just those with unwanted prefixes
  • The code could be a list that feeds the prefixes into it and be much more compact.
  • There may be a way to sort based on title except for those with a sort-key, but not sure yet
Regards
Tony

TonyM

unread,
Mar 21, 2020, 9:59:41 PM3/21/20
to TiddlyWiki
Wrap the content within the button with
<$list filter="[!is[system]!has[sort-key]]">

</$list>
so that on subsequent clicks only tiddlers without a sort-key will be updated/touched.

I believe there would also be a way to generate a list of titles without stop words and their matching tiddler title in a data tiddler (or JSON to handle other characters in the title) and use this as the input to an ordered list. This may leave the option to list the item twice, once without the stop words, once with it.

Regards
tony

Gerald Weis

unread,
Mar 22, 2020, 6:26:15 AM3/22/20
to TiddlyWiki
thanks for help so quickly

Am Samstag, 21. März 2020 19:33:13 UTC+1 schrieb Mat:
Sure

{{{ [<currentTiddler>removeprefix[Software: ]] }}}

<:-)
Reply all
Reply to author
Forward
0 new messages