Greetings,

While writing the txt2tags parser plugin, I've found that the behavior
of various config.parsers to be destructive.  I'm using v.2.6.1.

Try this in a tiddler:

<<unfinished macro markup.

And you will get this in the tiddler's display:

unfinished macro markup.

Repairing this behavior is essentially a two-line modification to the
handler function:

{
        name: "macro",
        match: "<<",
        lookaheadRegExp: /<<([^>\s]+)(?:\s*)((?:[^>]|(?:>(?!>)))*)>>/mg,
        handler: function(w)
        {
                this.lookaheadRegExp.lastIndex = w.matchStart;
                var lookaheadMatch = this.lookaheadRegExp.exec(w.source);
                if(lookaheadMatch && lookaheadMatch.index == w.matchStart &&
lookaheadMatch[1]) {
                        w.nextMatch = this.lookaheadRegExp.lastIndex;
                        
invokeMacro(w.output,lookaheadMatch[1],lookaheadMatch[2],w,w.tiddler);
//My contribution
                } else {
                        
w.output.appendChild(document.createTextNode(w.matchText));
//End my contribution
                }
        }
},

With this change, the unfinished macro markup isn't consumed.  The
"<<" characters appear in the output.

As far as I can tell, this would require modification to most of the
config.formatters - as most of them have an ambiguous "match" and a
more specific "lookaheadRegExp".  One or two other functions would be
effected as well, such as enclosedTextHelper.  The modifications are
all simple: if the lookaheadMatch and the w.match aren't part of the
same string, then put the matchText into the output.

Currently the config.formatters are loose to trigger a match and more
strict in applying the markup.
This would have the effect of making unmatched markup more obvious in
the output (as the match characters are displayed).
It also allows users to use characters that coincidentally look like
markup but don't strictly follow it (using only one-half of an
enclosed markup).
I'm a bit fuzzy on it's application in some forms of markup.  For
example: if you don't close a bold tag '', then all text after those
two characters are one big bold block.  Is this intentionally lax with
closing the tags?

Comments are encouraged.

-- 
David Young

-- 
You received this message because you are subscribed to the Google Groups 
"TiddlyWikiDev" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/tiddlywikidev?hl=en.

Reply via email to