Hi all,
txt2tags plugin is working nicely. I handled the "destructive" nature
of eating the formatter's "match:" element by making a modified
function using enclosedTextHelper as a base. You basically define a
"restore:" element as a text string of what match should have found...
it works in cases where "match:" is more or less static. I threw the
function at the end if you're curious, but that isn't my main query
right now.
My current snag now is that txt2tags supports a markup for numbered
headers. <h2> 2.3. Sub Title </h2>
I need to define some object- an array of integers or something- to
keep track of the numbers at each heading level. The object will be
modified by my plugin's config.t2tFormatters.t2tNumberedHeading and it
needs to be stored throughout the whole tiddler- but not into other
tiddlers!. Is this something I can do from my plugin? Is there an
example of some kind? I was thinking of doing something like if(
headingarray=undefined) { //define headingarray} inside
t2tNumberedHeading to create the object when the formatter is first
used, but does that get destroyed at the end of the tiddler?
My second question is I'm noticing the \n being replaced with \r for
IE. It worries me about the whitespace in my regex's as I only search
for \n when I want to find newlines. Should my formatters match for
[\n\r] instead of just \n? Or maybe tiddly only stores \n and
converting them into \r's is only for internet explorer's
html-interpreter's benefit?
//here's that function
config.formatterHelpers.nonDestructiveEnclosedTextHelper = function(w)
{
this.lookaheadRegExp.lastIndex = w.matchStart;
var lookaheadMatch = this.lookaheadRegExp.exec(w.source);
if(lookaheadMatch && lookaheadMatch.index == w.matchStart) {
var text = lookaheadMatch[1];
if(config.browser.isIE)
text = text.replace(/\n/g,"\r");
createTiddlyElement(w.output,this.element,null,null,text);
w.nextMatch = lookaheadMatch.index + lookaheadMatch[0].length;
} else {
w.output.appendChild(document.createTextNode(this.restore));
}
};
--
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.