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

1 point by jsx2 5 months ago | 0 comments
I try to use Commonmark.js on a local HTML page. And there is a problem with bare hyperlinks enclosed in angle brackets:

    <div id="input">

    **bold** and <em>italic</em>

    - <https://example.com>
    - <https://example.net>

    </div>

    <script src="https://unpkg.com/commonmark@0.29.3/dist/commonmark.js"></script>
    <script>
    window.onload = function() {
      var markdown = document.querySelector('#input').innerHTML;
      var reader = new commonmark.Parser();
      var writer = new commonmark.HtmlRenderer();
      var parsed = reader.parse(markdown);
      var result = writer.render(parsed);
      document.querySelector('body').innerHTML = result;
    }
    </script>

 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 `<em>italic</em>` should be rendered as *italic*)?

 I tried the Commonmark demo and it doesn’t have this problem.