TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Commonmark.js: Problem with bare hyperlinks enclosed in angle brackets

1 pointsby jsx24 months ago
I try to use Commonmark.js on a local HTML page. And there is a problem with bare hyperlinks enclosed in angle brackets:<p><pre><code> &lt;div id=&quot;input&quot;&gt; **bold** and &lt;em&gt;italic&lt;&#x2F;em&gt; - &lt;https:&#x2F;&#x2F;example.com&gt; - &lt;https:&#x2F;&#x2F;example.net&gt; &lt;&#x2F;div&gt; &lt;script src=&quot;https:&#x2F;&#x2F;unpkg.com&#x2F;commonmark@0.29.3&#x2F;dist&#x2F;commonmark.js&quot;&gt;&lt;&#x2F;script&gt; &lt;script&gt; window.onload = function() { var markdown = document.querySelector(&#x27;#input&#x27;).innerHTML; var reader = new commonmark.Parser(); var writer = new commonmark.HtmlRenderer(); var parsed = reader.parse(markdown); var result = writer.render(parsed); document.querySelector(&#x27;body&#x27;).innerHTML = result; } &lt;&#x2F;script&gt; Why is that? How to prevent bare hyperlinks enclosed in angle brackets to be treated as tags, and at the same time to keep ability to parse HTML (that is `&lt;em&gt;italic&lt;&#x2F;em&gt;` should be rendered as *italic*)? I tried the Commonmark demo and it doesn’t have this problem.</code></pre>

no comments

no comments