Skip to content

Commit 9232da2

Browse files
committed
Fix bug that was breaking single-quotes.
1 parent 64c5ac2 commit 9232da2

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

src/parser.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -179,10 +179,10 @@ export class MarkdownParser {
179179
*/
180180
static parseHashtagNumerals(html) {
181181
// Match #123 patterns with word boundaries
182-
// (?<!\w) ensures # is not in the middle of a word
182+
// (?<![&#\w]) ensures # is not in the middle of a word or part of an HTML entity
183183
// (?!\w) ensures the number is followed by a non-word character or end
184184
return html.replace(
185-
/(?<![#\w])(#\d+)(?!\w)/g,
185+
/(?<![&#\w])(#\d+)(?!\w)/g,
186186
'<span class="hashtag">$1</span>'
187187
);
188188
}
@@ -400,9 +400,10 @@ export class MarkdownParser {
400400

401401
// Transform link sanctuary to HTML
402402
// URL should NOT be processed for markdown - use it as-is
403+
// Note: sanctuary.url is already escaped since it came from escaped HTML
403404
const anchorName = `--link-${this.linkIndex++}`;
404405
const safeUrl = this.sanitizeUrl(sanctuary.url);
405-
replacement = `<a href="${safeUrl}" style="anchor-name: ${anchorName}"><span class="syntax-marker">[</span><span class="link-text">${processedLinkText}</span><span class="syntax-marker">](</span><span class="url-part">${this.escapeHtml(sanctuary.url)}</span><span class="syntax-marker">)</span></a>`;
406+
replacement = `<a href="${safeUrl}" style="anchor-name: ${anchorName}"><span class="syntax-marker">[</span><span class="link-text">${processedLinkText}</span><span class="syntax-marker">](</span><span class="url-part">${sanctuary.url}</span><span class="syntax-marker">)</span></a>`;
406407
}
407408

408409
html = html.replace(placeholder, replacement);

0 commit comments

Comments
 (0)