Ticket #1259 (closed enhancement: fixed)

Opened 17 months ago

Last modified 17 months ago

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

Changed 17 months ago by FND

  • type changed from defect to enhancement
  • milestone set to 2.7

Changed 17 months ago by FND

This  should be addressed in the context of #1134.

Not marking as dupe just yet; actions on #1134 need to be confirmed first.

Changed 17 months ago by MartinBudden

  • status changed from new to closed
  • resolution set to fixed

Fixed in changeset:12458

Changed 17 months ago by MartinBudden

  • status changed from closed to reopened
  • resolution fixed deleted

Changed 17 months ago by MartinBudden

  • owner changed from JeremyRuston to MartinBudden
  • status changed from reopened to new

Changed 17 months ago by MartinBudden

  • status changed from new to closed
  • resolution set to fixed
Note: See TracTickets for help on using tickets.