Created
October 28, 2020 16:09
-
-
Save abackstrom/bfb38db57a728c3bf1ac020feecda31e to your computer and use it in GitHub Desktop.
TiddlyWiki wikirule for JIRA ticket links
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/*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] | |
}] | |
}]; | |
} | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Should use type
application/javascript
and fieldmodule-type: wikirule
for this.