chore(ui): replace showdown markdown renderer (#936)

This commit is contained in:
Alex
2026-04-27 09:33:39 +01:00
committed by GitHub
parent 95cd73d0bb
commit 75568d3ce6
4 changed files with 78 additions and 34 deletions
@@ -1,8 +1,8 @@
import { Component, inject, OnInit, signal } from '@angular/core';
import { ReleaseNote, VersionService } from '../../../service/version.service';
import showdown from 'showdown';
import DOMPurify from 'dompurify';
import MarkdownIt from 'markdown-it';
import {DatePipe} from '@angular/common';
import {DynamicDialogRef} from 'primeng/dynamicdialog';
import {Button} from 'primeng/button';
@@ -27,7 +27,7 @@ export class VersionChangelogDialogComponent implements OnInit {
changelog: ReleaseNote[] = [];
loading = signal(true);
private converter = new showdown.Converter({ tables: true, emoji: true });
private markdown = new MarkdownIt({ html: true });
ngOnInit(): void {
this.versionService.getChangelog().subscribe({
@@ -42,7 +42,7 @@ export class VersionChangelogDialogComponent implements OnInit {
}
markdownToHtml(markdown: string): string {
let html = this.converter.makeHtml(markdown);
let html = this.markdown.render(markdown);
html = html.replace(/<h2\b([^>]*)>/g, '<h3$1>').replace(/<\/h2>/g, '</h3>');
return DOMPurify.sanitize(html);
}