Ticket #1259 (closed enhancement: fixed)
getTiddlerText for shadows tiddlers
| Reported by: | tb | Owned by: | MartinBudden |
|---|---|---|---|
| Priority: | undefined | Milestone: | 2.6.2 |
| Component: | core | Version: | |
| Severity: | undefined | Keywords: | |
| Cc: |
Description
Change TiddlyWiki.prototype.getTiddlerText to also fetch sections of shadows... look for FIX
TiddlyWiki.prototype.getTiddlerText = function(title,defaultText)
{
if(!title)
return defaultText;
var pos = title.indexOf(config.textPrimitives.sectionSeparator);
var section = null;
if(pos != -1) {
section = title.substr(pos + config.textPrimitives.sectionSeparator.length);
title = title.substr(0,pos);
}
pos = title.indexOf(config.textPrimitives.sliceSeparator);
if(pos != -1) {
var slice = this.getTiddlerSlice(title.substr(0,pos),title.substr(pos + config.textPrimitives.sliceSeparator.length));
if(slice)
return slice;
}
var tiddler = this.fetchTiddler(title);
//FIX: new variable 'text' for tiddler.text
var text=tiddler?tiddler.text:(this.isShadowTiddler(title)?this.getShadowTiddlerText(title):null);
//check for text to get sections of shadows as well
if(text){
if(!section)return text;
var re = new RegExp("(^!{1,6}[ \t]*" + section.escapeRegExp() + "[ \t]*\n)","mg");
re.lastIndex = 0;
var match = re.exec(text);
if(match) {
var t = text.substr(match.index+match[1].length);
var re2 = /^!/mg;
re2.lastIndex = 0;
match = re2.exec(t); //# search for the next heading
if(match)
t = t.substr(0,match.index-1);//# don't include final \n
return t;
}
return defaultText;
}
if(defaultText != undefined)
return defaultText;
return null;
};
Change History
Note: See
TracTickets for help on using
tickets.
