diff --git a/src/lib/outline.ts b/src/lib/outline.ts index f835c02..d56fb03 100644 --- a/src/lib/outline.ts +++ b/src/lib/outline.ts @@ -9,7 +9,8 @@ import { $ } from 'dom'; marked.use({ renderer: { - link: markdownParsers.link + link: markdownParsers.link, + codespan: markdownParsers.codespan as any } }); diff --git a/src/lib/parsers/md-parser.ts b/src/lib/parsers/md-parser.ts index f29809f..2b633ae 100644 --- a/src/lib/parsers/md-parser.ts +++ b/src/lib/parsers/md-parser.ts @@ -3,3 +3,33 @@ import { Tokens } from 'marked'; export function link(token: Tokens.Link): string { return `${token.text}`; } + +function decodeHtmlEntities(input: string): string { + if (!input) { + return ''; + } + return input + .replace(/&/g, '&') + .replace(/</g, '<') + .replace(/>/g, '>') + .replace(/"/g, '"') + .replace(/'/g, "'"); +} + +function escapeForCode(input: string): string { + if (!input) { + return ''; + } + // For code content, escape only what is necessary for safe HTML text rendering. + // We intentionally do NOT escape '>' so sequences like `g>g` render literally. + return input + .replace(/&/g, '&') + .replace(/${escaped}`; +}