Created
January 20, 2016 03:01
-
-
Save preble/756a74e89a0e3c59e4eb to your computer and use it in GitHub Desktop.
Want an OS X Service to convert a Pivotal Tracker story id or URL into a Markdown link? Create a new Service in Automator and enter the following in a Run JavaScript step. Save, give it a name, and you'll be able to select it from the Services menu.
This file contains hidden or 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
/// Convert a Pivotal Tracker story id (#1234, 1234) or URL into a Markdown link using the story number as the link text. | |
function markdownTrackerLink(text) { | |
var regex = /\s*(http.*pivotaltracker\.com\/story\/show\/(\d+)|#?(\d+))\s*/; | |
var id; | |
var groups; | |
if (regex.test(text)) { | |
groups = regex.exec(text); | |
id = groups[3] || groups[2]; | |
return "[#"+id+"](https://www.pivotaltracker.com/story/show/"+id+")"; | |
} | |
else { | |
return url; | |
} | |
} | |
function run(input, parameters) { | |
return markdownTrackerLink(input); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment