(function(){
/*jslint node: true, browser: true */
/*global $tw: false */
"use strict";
exports.name = "myrule";
exports.types = {block: true};
exports.init = function(parser) {
this.parser = parser;
// Regexp to match
this.matchRegExp = /-{3,}\r?(?:\n|$)/mg;
};
exports.parse = function() {
// Move past the match
this.parser.pos = this.matchRegExp.lastIndex;
return [{type: "element", tag: "hr"}];
};
})();
I have already seen spliting of the text field into lines which you could selectively append into a variable, subsequently saving a new text field. You could then process such lines to change something within each and this only with list filters and widgets. What makes this possible is generating a new temporary tiddler then copying it back. If built correctly you could go only half way and clone with changes generating a new version or the next step committing changes to the source.
Another approach may be to use a mechanisium like the draft method currently used for editing
Ultimately a replace function needs to be more than strings but able to interrogate the content. The recent xml plugin can interrogate and extract from xml and html perhaps have a look at that.
Regards
Tony
What you want is: TW wikitext -> AST -> TW wikitext
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 the plugin is probably the way to go :)
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 so complicated in TW :S
I am sorry if I offended you in any way