refactor: replace hoedown markdown parser with cmark

Signed-off-by: Joshua Goins <josh@redstrate.com>
This commit is contained in:
Joshua Goins
2023-01-06 15:26:26 -05:00
parent 9901ecda49
commit 24a4bd3a1c
10 changed files with 50 additions and 114 deletions

View File

@ -39,12 +39,11 @@
#include <QIcon>
#include "Application.h"
#include "BuildConfig.h"
#include "Markdown.h"
#include <net/NetJob.h>
#include <qobject.h>
#include "HoeDown.h"
namespace {
QString getLink(QString link, QString name) {
return QString("&lt;<a href='%1'>%2</a>&gt;").arg(link).arg(name);
@ -114,10 +113,9 @@ QString getCreditsHtml()
QString getLicenseHtml()
{
HoeDown hoedown;
QFile dataFile(":/documents/COPYING.md");
dataFile.open(QIODevice::ReadOnly);
QString output = hoedown.process(dataFile.readAll());
QString output = markdownToHTML(dataFile.readAll());
return output;
}

View File

@ -7,6 +7,7 @@
#include "FileSystem.h"
#include "Json.h"
#include "Markdown.h"
#include "tasks/ConcurrentTask.h"
@ -17,7 +18,6 @@
#include "modplatform/flame/FlameCheckUpdate.h"
#include "modplatform/modrinth/ModrinthCheckUpdate.h"
#include <HoeDown.h>
#include <QTextBrowser>
#include <QTreeWidgetItem>
@ -369,14 +369,7 @@ void ModUpdateDialog::appendMod(CheckUpdateTask::UpdatableMod const& info)
QString text = info.changelog;
switch (info.provider) {
case ModPlatform::Provider::MODRINTH: {
HoeDown h;
// HoeDown bug?: \n aren't converted to <br>
text = h.process(info.changelog.toUtf8());
// Don't convert if there's an HTML tag right after (Qt rendering weirdness)
text.remove(QRegularExpression("(\n+)(?=<)"));
text.replace('\n', "<br>");
text = markdownToHTML(info.changelog.toUtf8());
break;
}
default:

View File

@ -41,7 +41,7 @@
#include <Json.h>
#include "BuildConfig.h"
#include "HoeDown.h"
#include "Markdown.h"
UpdateDialog::UpdateDialog(bool hasUpdate, QWidget *parent) : QDialog(parent), ui(new Ui::UpdateDialog)
{
@ -89,8 +89,7 @@ void UpdateDialog::loadChangelog()
QString reprocessMarkdown(QByteArray markdown)
{
HoeDown hoedown;
QString output = hoedown.process(markdown);
QString output = markdownToHTML(markdown);
// HACK: easier than customizing hoedown
output.replace(QRegularExpression("GH-([0-9]+)"), "<a href=\"https://github.com/PrismLauncher/PrismLauncher/issues/\\1\">GH-\\1</a>");