Next try… Am Dienstag, 24. Dezember 2013 13:17:48 UTC+1 schrieb Jeremy Ruston: > > Am Dienstag, 24. Dezember 2013 10:01:31 UTC+1 schrieb Jeremy Ruston: > >> Hi Stephan >>> >>> I'm afraid a parse rule can't modify the source text that is being >>> parsed. >>> >> >> They can… They just need to do it earlier… >> > > Really, they can't. I'm sure you can wrangle it to work in some > circumstances, but it breaks the underlying assumptions of the parser, and > isn't a viable strategy for achieving what you want. >
Okay… I think I have to surrender ;) My Replace Pragma works but it does not work exactly the same way your pragmas do work. As far as I understood the wikiparser.js, you take the tiddlersource and apply the regular expression for every pragma, blockrule and inlinerule to it. So you will find the position where each rule matches first. At this stage, nothing else was done yet! But at this stage I play with the source. So as soon as my replace pragma's findNext method is called, I mess with the source text. The assumptions here is that I can find the place in the source, where pragmas end, so that I only apply to text not relevant for pragmas. At the moment this is done by finding the last line starting with a "\". The result is: Before wikiparser checks the blockrules and the inlinerules, the source is already changed. And before any rule is really applied, my pragma already did its work. The problems I see: 1. As you said: Pragmas need not start with \. I could easily change the pragma so that it needs a "marker line" after which replacements should be applied. 2. replacepragmas even work inside comments. So if you put a comment blck around it, it will still be applied. Nevertheless: I think it's an idea worth thinking about, don't you agree? Maybe it needs a seperate phase? Like a preprocessor. > > Looking briefly at your code, I'm not sure that the way that you detect > the end of the pragmas is going to work. There's no requirement for pragma > rules to start with a backslash, and it looks like your method won't work > over multiline pragmas like macro definitions. > > The find and replace is problematical because there's nothing to stop it > making replacements before the current parse position, which will upset the > parsing in progress. > > It also looks like you're converting \n to newline and \t to tab, is that > right? > > Best wishes > > Jeremy > > > >> >> I think, I fixed it… >> >> Maybe you want to inspect it? >> > > > > -- > Jeremy Ruston > mailto:jeremy...@gmail.com <javascript:> > -- You received this message because you are subscribed to the Google Groups "TiddlyWiki" group. To unsubscribe from this group and stop receiving emails from it, send an email to tiddlywiki+unsubscr...@googlegroups.com. To post to this group, send email to tiddlywiki@googlegroups.com. Visit this group at http://groups.google.com/group/tiddlywiki. For more options, visit https://groups.google.com/groups/opt_out.