Skip to content

Instantly share code, notes, and snippets.

@abackstrom
Created October 28, 2020 16:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save abackstrom/bfb38db57a728c3bf1ac020feecda31e to your computer and use it in GitHub Desktop.
Save abackstrom/bfb38db57a728c3bf1ac020feecda31e to your computer and use it in GitHub Desktop.
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

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