Skip to content

Commit

Permalink
fix: inline code parser problems
Browse files Browse the repository at this point in the history
  • Loading branch information
BartoszGrajdek committed Dec 11, 2024
1 parent cddf8a0 commit 7bc4ef0
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/parseExpensiMark.ts
Original file line number Diff line number Diff line change
Expand Up @@ -153,9 +153,10 @@ function parseTreeToTextAndRanges(tree: StackItem): [string, MarkdownRange[]] {
} else if (node.tag === '<br />') {
text += '\n';
} else if (node.tag.startsWith('<pre')) {
appendSyntax(`\`\`\`${unescapeText(node.tag.match(/new-line-char="([^"]*)"/)![1]!)}`);
const content = node.children.join('').replaceAll('&#32;', ' ');
addChildrenWithStyle(content, 'pre');
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const [_, lb, content] = node.children.join('').match(/^(\r?\n)([\s\S]*)$/) as RegExpMatchArray;
appendSyntax(`\`\`\`${lb}`);
addChildrenWithStyle(`${content}`, 'pre');
appendSyntax('```');
} else if (node.tag.startsWith('<a href="')) {
const rawHref = node.tag.match(/href="([^"]*)"/)![1]!; // always present
Expand Down

0 comments on commit 7bc4ef0

Please sign in to comment.