Emoji parsing should exclude URLs

Bug Report

Parsing of :emojis: should exclude URLs as this causes URLs in the following format render invalid HTML:

[link](https://link.com/:smile:/index)

Note that in my use case, I am also using other :emojis: so I can't set noEmoji: true in config.

Happy to contribute a fix if this bug is accepted.

Steps to reproduce

Example: https://codesandbox.io/s/brave-margulis-tw5t2b?file=/index.html

What is current behaviour

Invalid HTML is rendered:

<a alt="smile" src="https://github.githubassets.com/images/icons/emoji/smile.png" href="https://link.com/&lt;img class=">/index" target="_blank"  rel="noopener"&gt;link</a>

image

What is the expected behaviour

Rendered HTML should produce something like:

<a href="https://link.com/:smile:/index" target="_blank"  rel="noopener">link</a>

Other relevant information

  • Bug does still occur when all/other plugins are disabled?

  • Your OS: macOS

  • Node.js version:

  • npm/yarn version:

  • Browser version: Safari 15.5

  • Docsify version: 4

  • Docsify plugins:

Please create a reproducible sandbox

Edit 307qqv236

Mention the docsify version in which this bug was not present (if any)