Fix markdown rendering

pull/5204/head
Kamran Ahmed 9 months ago
parent a9734c7eeb
commit 8d677f3a22
  1. 20
      src/lib/markdown.ts
  2. 1
      src/lib/question-group.ts

@ -2,15 +2,19 @@
import MarkdownIt from 'markdown-it'; import MarkdownIt from 'markdown-it';
export function markdownToHtml(markdown: string, isInline = true): string { export function markdownToHtml(markdown: string, isInline = true): string {
const md = new MarkdownIt({ try {
html: true, const md = new MarkdownIt({
linkify: true, html: true,
}); linkify: true,
});
if (isInline) { if (isInline) {
return md.renderInline(markdown); return md.renderInline(markdown);
} else { } else {
return md.render(markdown); return md.render(markdown);
}
} catch (e) {
return markdown;
} }
} }

@ -81,6 +81,7 @@ export async function getAllQuestionGroups(): Promise<QuestionGroupType[]> {
if (answerText.endsWith('.md')) { if (answerText.endsWith('.md')) {
const answerFilePath = `/src/data/question-groups/${questionGroupDir}/content/${answerText}`; const answerFilePath = `/src/data/question-groups/${questionGroupDir}/content/${answerText}`;
answerText = answerText =
answerFilesMap[answerFilePath]?.default ||
answerFilesMap[answerFilePath] || answerFilesMap[answerFilePath] ||
`File missing: ${answerFilePath}`; `File missing: ${answerFilePath}`;

Loading…
Cancel
Save