[Question] can I split a tiddler by lines?

264 views
Skip to first unread message

Tony K

unread,
May 16, 2020, 4:38:03 PM5/16/20
to TiddlyWiki
I'm unable to find the delimiter equivalent to \n in TW5

Assuming I have a tiddler and I want to parse it line by line. Is it doable?

Thanks

Mark S.

unread,
May 16, 2020, 5:11:10 PM5/16/20
to TiddlyWiki
You can use the splitregexp operator. Here's an example that works on TiddlyWiki.com:

<$list filter="[[HelloThere]get[text]splitregexp[\n]!is[blank]nth[3]]">
<$text text=<
<currentTiddler>>/><br/>
</$list>


Tony K

unread,
May 17, 2020, 12:14:05 AM5/17/20
to TiddlyWiki
oh thank you Mark, I should have asked days ago

a follow-up question please, is there a way to "add" '\n' that is not using <br /> 

i.e in TWCrosslinks when then entry is added to the input box the plugins appends it to a tiddler, for now I am using <br /> which, visually, doesn't look so good if you open the tiddler.

thank you 

TonyM

unread,
May 17, 2020, 2:41:35 AM5/17/20
to TiddlyWiki
Tony K,

I have not seen an answer to your second question, however I too would be keen to know, I wonder if we can use a html or css entity for new line?

Or ascii or something.

LF 10 line feed
CR 13 carriage return

Tony

Tony K

unread,
May 17, 2020, 1:01:33 PM5/17/20
to TiddlyWiki
Thanks Tony

I really wish someone can shed light on this

Mark S.

unread,
May 17, 2020, 2:05:58 PM5/17/20
to TiddlyWiki
I don't think it is possible with the current operators and widgets. I think it would take a javascript macro to do the substitution.

TonyM

unread,
May 17, 2020, 7:41:45 PM5/17/20
to TiddlyWiki
Mark,

Yes perhaps this is true, but the current edit widgets, and the core editor all accept the <enter> and imbed line feed in text area fields. Somehow we need to get this to occur in demand, I wonder if a regex could extract it from a known tiddler an store it in a variable we can append later?

It would be a nice pre-provisioned variable.

I have actually being considering the use of 
182&para;pilcrow sign
Perhaps this could be a way to get the editor to treat a sentence like a paragraph and wrap it in P tag on render.


Regards
Tony

Eric Shulman

unread,
May 17, 2020, 8:24:00 PM5/17/20
to TiddlyWiki
On Saturday, May 16, 2020 at 1:38:03 PM UTC-7, Tony K wrote:
I'm unable to find the delimiter equivalent to \n in TW5

Assuming I have a tiddler and I want to parse it line by line. Is it doable?


Here's a little example:
<$vars lf="
">
line count=<$count filter="[{SomeTiddler}split<lf>]"/><br>
<$list filter="[{SomeTiddler}split<lf>]" variable="thisline">
   <<thisline>> ({{{ [<thisline>length[]] }}} chars)<br>
</$list>
</$vars>

The trick is to use $vars to define a variable ("lf") that contains a *literal* newline (note the explicit line break in the code!)
You can then use <lf> in your filter syntax, as shown above.

enjoy,
-e

Tony K

unread,
May 18, 2020, 1:49:44 AM5/18/20
to TiddlyWiki
Eric this is genius 

it actually solves my second question :o)

thank you  

TiddlyTweeter

unread,
May 18, 2020, 7:06:01 AM5/18/20
to TiddlyWiki
Is this a one-way need occasionally?

I.e. does permanent change work best, or do you need dynamic?

Do you want to change the text or preserve it?

TT

TonyM

unread,
May 18, 2020, 9:27:18 AM5/18/20
to TiddlyWiki
Eric

So often you see what I should of seen but did not.

This should allow custom parsers in wiki text and widgets. Parse each line and transform it including adding line breaks, possibly the only invisible character in wiki text apart from tabs.

Build a new variable with the output and set a, or the, text field to the variable.

This also enables line based add (insert) change delete, append and prepend.

With what you have done here I am tempted to have a global of variable to complement those such as "[[" etc for use with string operations or concatinations. Perhaps even propose for the core?

this seems to me to open many possibilities.

Thanks
Tony

Reply all
Reply to author
Forward
0 new messages