fixed misalignment of list items when using syntax highlight
This commit is contained in:
parent
45963978be
commit
bfc636f636
|
|
@ -800,9 +800,17 @@ function noteApp() {
|
||||||
// Links [text](url)
|
// Links [text](url)
|
||||||
html = html.replace(/\[([^\]]+)\]\(([^)]+)\)/g, '<span class="md-link">[$1]</span><span class="md-link-url">($2)</span>');
|
html = html.replace(/\[([^\]]+)\]\(([^)]+)\)/g, '<span class="md-link">[$1]</span><span class="md-link-url">($2)</span>');
|
||||||
|
|
||||||
// Lists
|
// Lists - use [ \t] instead of \s to avoid matching newlines
|
||||||
html = html.replace(/^(\s*)([-*+])\s/gm, '$1<span class="md-list">$2</span> ');
|
// Capture rest of line to handle empty bullets properly (issue #142)
|
||||||
html = html.replace(/^(\s*)(\d+\.)\s/gm, '$1<span class="md-list">$2</span> ');
|
html = html.replace(/^(\s*)([-*+])[ \t](.*)$/gm, (match, indent, bullet, rest) => {
|
||||||
|
// If rest is empty/whitespace-only, add zero-width space to prevent line collapse
|
||||||
|
const content = rest.trim() === '' ? '\u200B' : rest;
|
||||||
|
return `${indent}<span class="md-list">${bullet}</span> ${content}`;
|
||||||
|
});
|
||||||
|
html = html.replace(/^(\s*)(\d+\.)[ \t](.*)$/gm, (match, indent, bullet, rest) => {
|
||||||
|
const content = rest.trim() === '' ? '\u200B' : rest;
|
||||||
|
return `${indent}<span class="md-list">${bullet}</span> ${content}`;
|
||||||
|
});
|
||||||
|
|
||||||
// Blockquotes
|
// Blockquotes
|
||||||
html = html.replace(/^(>.*)$/gm, '<span class="md-blockquote">$1</span>');
|
html = html.replace(/^(>.*)$/gm, '<span class="md-blockquote">$1</span>');
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue