Skip to content

Commit

Permalink
fix: preserve space at the end of diagram code when parsing
Browse files Browse the repository at this point in the history
  • Loading branch information
smsochneg committed Apr 26, 2024
1 parent d10a72c commit 8bf3f95
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions src/runtime/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,15 @@ async function next(): Promise<void> {

for (const element of nodesList) {
const id = `mermaid-${Date.now()}`;
const content = element.getAttribute('data-content') || '';
const text = dedent(decodeURIComponent(content))
.trim()
const content = decodeURIComponent(element.getAttribute('data-content') || '');
let dedentedContent = dedent(content);

if (content.replace(/\n*$/, '').endsWith(' ')) {
dedentedContent += ' ';
}

const text = dedentedContent

Check failure on line 54 in src/runtime/index.ts

View workflow job for this annotation

GitHub Actions / build (18.x)

Replace `⏎························.trimStart()⏎························` with `.trimStart()`
.trimStart()
.replace(/<br\s*\/?>/gi, '<br/>');

const {svg, bindFunctions} = await mermaid.render(id, text, element);
Expand Down

0 comments on commit 8bf3f95

Please sign in to comment.