Enabled Markdown formatting for the release info dialog
This commit is contained in:
parent
37b87934a4
commit
f2b6b2d6f2
|
@ -1,4 +1,23 @@
|
||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
|
# SPDX-License-Identifier: GPL-3.0-only
|
||||||
|
# MuseScore-CLA-applies
|
||||||
|
#
|
||||||
|
# MuseScore
|
||||||
|
# Music Composition & Notation
|
||||||
|
#
|
||||||
|
# Copyright (C) 2021 MuseScore BVBA and others
|
||||||
|
#
|
||||||
|
# This program is free software: you can redistribute it and/or modify
|
||||||
|
# it under the terms of the GNU General Public License version 3 as
|
||||||
|
# published by the Free Software Foundation.
|
||||||
|
#
|
||||||
|
# This program is distributed in the hope that it will be useful,
|
||||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
# GNU General Public License for more details.
|
||||||
|
#
|
||||||
|
# You should have received a copy of the GNU General Public License
|
||||||
|
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
import io
|
import io
|
||||||
import sys
|
import sys
|
||||||
|
|
57
build/ci/release/correct_release_info.py
Normal file
57
build/ci/release/correct_release_info.py
Normal file
|
@ -0,0 +1,57 @@
|
||||||
|
#!/usr/bin/env python3
|
||||||
|
# SPDX-License-Identifier: GPL-3.0-only
|
||||||
|
# MuseScore-CLA-applies
|
||||||
|
#
|
||||||
|
# MuseScore
|
||||||
|
# Music Composition & Notation
|
||||||
|
#
|
||||||
|
# Copyright (C) 2021 MuseScore BVBA and others
|
||||||
|
#
|
||||||
|
# This program is free software: you can redistribute it and/or modify
|
||||||
|
# it under the terms of the GNU General Public License version 3 as
|
||||||
|
# published by the Free Software Foundation.
|
||||||
|
#
|
||||||
|
# This program is distributed in the hope that it will be useful,
|
||||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
# GNU General Public License for more details.
|
||||||
|
#
|
||||||
|
# You should have received a copy of the GNU General Public License
|
||||||
|
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
import sys
|
||||||
|
import json
|
||||||
|
import markdown
|
||||||
|
|
||||||
|
RELEASE_INFO_FILE = sys.argv[1]
|
||||||
|
|
||||||
|
print("=== Load json ===")
|
||||||
|
|
||||||
|
json_file = open(RELEASE_INFO_FILE, "r+")
|
||||||
|
release_info_json = json.load(json_file)
|
||||||
|
json_file.close()
|
||||||
|
|
||||||
|
print("=== Make html version of body ===")
|
||||||
|
|
||||||
|
release_body_markdown = release_info_json["body"]
|
||||||
|
|
||||||
|
release_body_html = markdown.markdown(release_body_markdown)
|
||||||
|
|
||||||
|
# Correct result of Markdown parser
|
||||||
|
# Escape single quotes
|
||||||
|
release_body_html = release_body_html.replace("'", "`")
|
||||||
|
|
||||||
|
# Correct new lines next to <ul> and </ul>
|
||||||
|
release_body_html = release_body_html.replace("\n<ul>\n", "<ul>")
|
||||||
|
release_body_html = release_body_html.replace("\n</ul>\n", "</ul>")
|
||||||
|
|
||||||
|
release_info_json["body"] = "'" + release_body_html + "'"
|
||||||
|
release_info_json["bodyMarkdown"] = release_body_markdown
|
||||||
|
|
||||||
|
release_info_json_updated = json.dumps(release_info_json)
|
||||||
|
|
||||||
|
print("=== Write json ===")
|
||||||
|
|
||||||
|
json_file = open(RELEASE_INFO_FILE, "w")
|
||||||
|
json_file.write(release_info_json_updated)
|
||||||
|
json_file.close()
|
|
@ -49,3 +49,8 @@ RELEASE_INFO=$(curl \
|
||||||
mkdir -p $ARTIFACTS_DIR
|
mkdir -p $ARTIFACTS_DIR
|
||||||
echo $RELEASE_INFO > $ARTIFACTS_DIR/release_info.json
|
echo $RELEASE_INFO > $ARTIFACTS_DIR/release_info.json
|
||||||
cat $ARTIFACTS_DIR/release_info.json
|
cat $ARTIFACTS_DIR/release_info.json
|
||||||
|
|
||||||
|
pip install markdown
|
||||||
|
|
||||||
|
HERE="$(cd "$(dirname "$0")" && pwd)"
|
||||||
|
python3 $HERE/correct_release_info.py ${ARTIFACTS_DIR}/release_info.json
|
||||||
|
|
|
@ -71,6 +71,7 @@ mu::RetVal<ReleaseInfo> UpdateService::checkForUpdate()
|
||||||
}
|
}
|
||||||
|
|
||||||
QByteArray json = buff.data();
|
QByteArray json = buff.data();
|
||||||
|
LOGD() << "json: " << json;
|
||||||
|
|
||||||
RetVal<ReleaseInfo> releaseInfo = parseRelease(json);
|
RetVal<ReleaseInfo> releaseInfo = parseRelease(json);
|
||||||
if (!releaseInfo.ret) {
|
if (!releaseInfo.ret) {
|
||||||
|
@ -154,7 +155,7 @@ mu::RetVal<ReleaseInfo> UpdateService::parseRelease(const QByteArray& json) cons
|
||||||
|
|
||||||
QJsonObject release = jsonDoc.object();
|
QJsonObject release = jsonDoc.object();
|
||||||
result.val.title = release.value("name").toString().toStdString();
|
result.val.title = release.value("name").toString().toStdString();
|
||||||
result.val.notes = release.value("body").toString().toStdString();
|
result.val.notes = release.value("bodyMarkdown").toString().toStdString();
|
||||||
|
|
||||||
QString tagName = release.value("tag_name").toString();
|
QString tagName = release.value("tag_name").toString();
|
||||||
result.val.version = tagName.replace("v", "").toStdString();
|
result.val.version = tagName.replace("v", "").toStdString();
|
||||||
|
|
|
@ -64,7 +64,7 @@ ColumnLayout {
|
||||||
horizontalAlignment: Text.AlignLeft
|
horizontalAlignment: Text.AlignLeft
|
||||||
font: ui.theme.largeBodyFont
|
font: ui.theme.largeBodyFont
|
||||||
wrapMode: Text.WordWrap
|
wrapMode: Text.WordWrap
|
||||||
lineHeight: 2.0
|
textFormat: Text.MarkdownText
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue