Skip to content

Instantly share code, notes, and snippets.

@zachkinstner
Created May 1, 2013 17:02
Show Gist options
  • Save zachkinstner/5496612 to your computer and use it in GitHub Desktop.
Save zachkinstner/5496612 to your computer and use it in GitHub Desktop.
Trello Card JSON to JIRA Markdown
function buildJiraMarkdown(card) {
var jira =
"{panel}\n"+
"h3. [" + card.name + "|" + card.shortUrl + "]\n" +
card.desc + "\n\n" +
"*Labels:* ";
for (var i = 0; i < card.labels.length; ++i) {
var label = card.labels[i];
var c = label.color;
if (label.color == "yellow") {
c = "#aaaa00";
}
jira += (i === 0 ? "" : ", ") + "{color:" + c + "}" + label.name + "{color}";
}
jira += "\n";
if (card.due) {
jira += "*Due:* " + card.due.substr(0, card.due.indexOf("T")) + "\n";
}
for (i = 0; i < card.checklists.length; ++i) {
var list = card.checklists[i];
var complete = 0;
var text = "";
for (var j = 0; j < list.checkItems.length; ++j) {
var item = list.checkItems[j];
text += "- " + (item.state == "complete" ? "(/)" : "(x)") + " " + item.name + "\n";
complete += (item.state == "complete" ? 1 : 0);
}
jira += "\n*" + list.name + "* (" + Math.round(complete / list.checkItems.length * 100) + "% complete)\n";
jira += text;
}
return jira+"{panel}";
}
////////////////////////
//Exported JSON data
var trelloCard =
{};
alert(buildJiraMarkdown(trelloCard));
@zachkinstner
Copy link
Author

@zachkinstner
Copy link
Author

Various to-do items: include comments, activities, attachments, etc.

Also, update the script to load JSON data directly via Trello URL.

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