Skip to content

Instantly share code, notes, and snippets.

@abackstrom
Created Oct 28, 2020
Embed
What would you like to do?
TiddlyWiki wikirule for JIRA ticket links
/*jslint node: true, browser: true */
/*global $tw: false */
"use strict";
exports.name = "jiralink";
exports.types = {inline: true};
exports.init = function(parser) {
this.parser = parser;
this.matchRegExp = new RegExp(/[A-Z]+-\d+/, "mg");
};
exports.parse = function() {
// Get the details of the match
var linkText = this.match[0];
var href = "https://path.to.jira.server/browse/" + linkText;
// Move past the macro call
this.parser.pos = this.matchRegExp.lastIndex;
return [{
type: "element",
tag: "a",
attributes: {
href: {type: "string", value: href},
"class": {type: "string", value: "tc-tiddlylink-external"},
target: {type: "string", value: "_blank"},
rel: {type: "string", value: "noopener noreferrer"}
},
children: [{
type: "text", text: this.match[0]
}]
}];
}
})();
@abackstrom
Copy link
Author

abackstrom commented Oct 28, 2020

Should use type application/javascript and field module-type: wikirule for this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment