From 69ce4698965179fc6b0ded77511520571a1ab486 Mon Sep 17 00:00:00 2001 From: mikeller Date: Thu, 15 Feb 2018 01:36:40 +1300 Subject: [PATCH] Added markdown processing for GitHub release notes. --- package-lock.json | 5 +++++ package.json | 3 ++- src/js/tabs/firmware_flasher.js | 6 +++++- src/main.html | 1 + 4 files changed, 13 insertions(+), 2 deletions(-) diff --git a/package-lock.json b/package-lock.json index e33a188c..c4b2b870 100644 --- a/package-lock.json +++ b/package-lock.json @@ -4295,6 +4295,11 @@ "object-visit": "1.0.1" } }, + "marked": { + "version": "0.3.12", + "resolved": "https://registry.npmjs.org/marked/-/marked-0.3.12.tgz", + "integrity": "sha512-k4NaW+vS7ytQn6MgJn3fYpQt20/mOgYM5Ft9BYMfQJDz2QT6yEeS9XJ8k2Nw8JTeWK/znPPW2n3UJGzyYEiMoA==" + }, "matchdep": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/matchdep/-/matchdep-2.0.0.tgz", diff --git a/package.json b/package.json index bada28e8..da96213b 100644 --- a/package.json +++ b/package.json @@ -35,7 +35,8 @@ "license": "GPL-3.0", "dependencies": { "i18next": "^10.3.0", - "i18next-xhr-backend": "^1.5.1" + "i18next-xhr-backend": "^1.5.1", + "marked": "^0.3.12" }, "devDependencies": { "command-exists": "^1.2.2", diff --git a/src/js/tabs/firmware_flasher.js b/src/js/tabs/firmware_flasher.js index afc60584..41620ee0 100755 --- a/src/js/tabs/firmware_flasher.js +++ b/src/js/tabs/firmware_flasher.js @@ -260,8 +260,12 @@ TABS.firmware_flasher.initialize = function (callback) { $('div.release_info .status').text(summary.status); $('div.release_info .file').text(summary.file).prop('href', summary.url); - var formattedNotes = summary.notes.trim('\r').replace(/\r/g, '
'); + var formattedNotes = summary.notes.replace(/#(\d+)/g, '[#$1](https://github.com/betaflight/betaflight/pull/$1)'); + formattedNotes = marked(formattedNotes); $('div.release_info .notes').html(formattedNotes); + $('div.release_info .notes').find('a').each(function() { + $(this).attr('target', '_blank'); + }); $('div.release_info').slideDown(); diff --git a/src/main.html b/src/main.html index fc58ed00..638fd435 100755 --- a/src/main.html +++ b/src/main.html @@ -37,6 +37,7 @@ +