Backlinks operator returning caption if it exists

I am looking at how, when using the backlinks operator, I can get the caption returned instead of the tiddler’s title.

I have foubnd the shadow tiddler,

$:/core/modules/filters/backlinks.js
/*\
title: $:/core/modules/filters/backlinks.js
type: application/javascript
module-type: filteroperator

Filter operator for returning all the backlinks from a tiddler

\*/
(function(){

/*jslint node: true, browser: true */
/*global $tw: false */
"use strict";

/*
Export our filter function
*/
exports.backlinks = function(source,operator,options) {
	var results = new $tw.utils.LinkedList();
	source(function(tiddler,title) {
		results.pushTop(options.wiki.getTiddlerBacklinks(title));
	});
	return results.makeTiddlerIterator(options.wiki);
};

})();

but I am unsure of how to amend the code without stuffing things up.

Could someone advise please?

On a more general note, is it possible to have a flag everytime a tiddler’s title is returned so that the caption is returned if the flag is set? There are a few core functions that already return caption if one is available. Why not extend this function everywhere?

bobj

bobj

bob I am in the process of building a way to retrieve the hard coded pretty links for links and back links. the caption is much easier because you get the title then lookup the caption on that title, falling back to the title.

Every tiddler has a unique title. It is used throughout TiddlyWiki as an “identifier” for that tiddler.
In contrast, captions are used for display purposes, and can be the same for multiple tiddlers.

Thus, if you are using filter such as backlinks[] to obtain the unique identifiers for each tiddler, you absolutely do NOT want to get the caption values.

On the other hand, if you are using backlinks[] to obtain tiddler titles for display purposes, you can use a :map[...] filter run to convert the titles into captions, like this:

{{{ [<currentTiddler>backlinks[]] :map[get[caption]else{!!title}] }}}

-e

Thank you @EricShulman looks like just what I want.

bobj