[tw5] Re: TW parser to actually "replace" text

2020-05-13 Thread TonyM
Folks, To further this discussion I had a thought, perhaps a companion to freelinks in an editor toolbar button, to search the existing text and search for titles and an optionally replace with a [[hard link]]. Freelinks would let you discover the links, edit mode would allow you to elect

[tw5] Re: TW parser to actually "replace" text

2020-05-13 Thread PMario
On Wednesday, May 13, 2020 at 8:21:55 PM UTC+2, Tony K wrote: .. > I am sorry if I offended you in any way > No offence taken. ... I think, it is a good idea to have a possibility to switch from "feelinks" to "real links" in a simple way. ... As always I personally want to be "in control".

[tw5] Re: TW parser to actually "replace" text

2020-05-13 Thread Tony K
PMario all my apologies, I think you miss-understood me when I said "I could do it in any language in 3 minutes" I was referring to programming languages (Java / Python etc..) I am sorry if I offended you in any way On Wednesday, May 13, 2020 at 8:55:20 PM UTC+3, PMario wrote: > > On

[tw5] Re: TW parser to actually "replace" text

2020-05-13 Thread PMario
On Tuesday, May 12, 2020 at 6:42:55 PM UTC+2, Tony K wrote: ... > what I want to do, in simpler form, is replace all occurrences of a word > (say Word1 ) with [[Word1]] > Hmmm, That is a completely different question. > so, in other terms, converting a "freelink" to a "backlink" > OK So

[tw5] Re: TW parser to actually "replace" text

2020-05-13 Thread Joshua Fontany
I was just going to attempt this description, but I also +1 everything PMario just wrote. It is very important to understand that the internal structure is a series of parsed trees: *TW wikitext -> Parse Tree (AST) -> Widget Tree -> HTML* I think a visual depiction of this would be incredibly

[tw5] Re: TW parser to actually "replace" text

2020-05-12 Thread Saq Imtiaz
@TonyK it's not complicated, you have just been looking in the wrong place. A parser should not be altering source text. Look at the saving tiddler hook that @pmario has pointed out to you. Personally I wouldn't want to use any code that altered my source text, so a big disclaimer/warning in

[tw5] Re: TW parser to actually "replace" text

2020-05-12 Thread Tony K
Hey PMario thank you for your time writing all this to me what I want to do, in simpler form, is replace all occurrences of a word (say Word1 ) with [[Word1]] so, in other terms, converting a "freelink" to a "backlink" I could do it in any language in 3 minutes top can't understand why it is

[tw5] Re: TW parser to actually "replace" text

2020-05-12 Thread PMario
On Tuesday, May 12, 2020 at 4:13:04 PM UTC+2, PMario wrote: ... > What you want is: TW wikitext -> AST -> TW wikitext > Having something like this, with lossless conversion would be unbelievably cool. It would allow us to store tiddler content in AST format, instead of wikitext, which

[tw5] Re: TW parser to actually "replace" text

2020-05-12 Thread Saq Imtiaz
+1 for everything P Mario said. On Tuesday, May 12, 2020 at 4:13:04 PM UTC+2, PMario wrote: > > Hi, > > Referring to my last post, I do think, the parser isn't the right place to > do stuff like this, because the parser does something completely different. > > TW parser converts wiki text

[tw5] Re: TW parser to actually "replace" text

2020-05-12 Thread PMario
Hi, Referring to my last post, I do think, the parser isn't the right place to do stuff like this, because the parser does something completely different. TW parser converts wiki text syntax into a so called AST Abstract Syntax Tree , which

[tw5] Re: TW parser to actually "replace" text

2020-05-12 Thread PMario
Hi Tony, TW core has a so-called "hook" mechanism, that could be used here. It is described in the TW dev edition, with a minimal example, that just shows the basic mechanism. See the th-saving-tiddler hook

[tw5] Re: TW parser to actually "replace" text

2020-05-12 Thread TiddlyTweeter
Ok. Tips... ... The standard parsers dynamically create HTML. The render level is accessible and save able. Both Mark S. & Jed Carty have used that to create savers of HTML-ised vers of tids in past. ... Its possible to create parsers made of raw regexes that run prior to the standard

[tw5] Re: TW parser to actually "replace" text

2020-05-12 Thread Tony K
no sir, it is just a test to learn how to do it i am not looking to replace by html code or change format thank you On Tuesday, May 12, 2020 at 3:15:00 PM UTC+3, TiddlyTweeter wrote: > > Is the aim to have these tiddlers be, basically, at end, in HTML. I.e you > use WikiText to write but on

[tw5] Re: TW parser to actually "replace" text

2020-05-12 Thread TiddlyTweeter
Is the aim to have these tiddlers be, basically, at end, in HTML. I.e you use WikiText to write but on edit save you want the HTML render to be saved not the WikiText? Or is it a more complex mix? On Tuesday, 12 May 2020 11:33:44 UTC+2, Tony K wrote: > > yes sir > > On Tuesday, May 12, 2020 at

[tw5] Re: TW parser to actually "replace" text

2020-05-12 Thread Tony K
yes sir On Tuesday, May 12, 2020 at 12:31:26 PM UTC+3, TiddlyTweeter wrote: > > You mean "a one way ticket"? Where the content of a tiddler is permanently > changed, Once, forever? > > Yes? > > On Tuesday, 12 May 2020 10:51:59 UTC+2, Tony K wrote: >> >> >> (function(){ >> >> /*jslint node: true,

[tw5] Re: TW parser to actually "replace" text

2020-05-12 Thread TiddlyTweeter
You mean "a one way ticket"? Where the content of a tiddler is permanently changed, Once, forever? Yes? On Tuesday, 12 May 2020 10:51:59 UTC+2, Tony K wrote: > > > (function(){ > > /*jslint node: true, browser: true */ > /*global $tw: false */ > "use strict"; > > exports.name = "myrule"; >