Skip to content

Allow CommonMark local parts in email autolinks - #234

Open
shardulsdk-mpiric wants to merge 1 commit into
tpope:masterfrom
shardulsdk-mpiric:fix-email-autolink-local-part
Open

shardulsdk-mpiric wants to merge 1 commit into
tpope:masterfrom
shardulsdk-mpiric:fix-email-autolink-local-part

Conversation

@shardulsdk-mpiric

Copy link
Copy Markdown

Email autolinks only accept [[:alnum:]_+-] before the @, so a common
address like <first.last@example.com> misses markdownAutomaticLink and
falls through to the HTML tag rule: first is highlighted as a tag name and
the rest as tag body.

From: Jane Doe <jane.doe@example.com>

A ' in the local part (allowed by the spec) is worse: it opens an
htmlString inside the bogus tag that runs into the following lines.

This uses the local-part character set from the CommonMark spec:
https://spec.commonmark.org/0.31.2/#email-autolink

Checked that <foo+bar@example.com>, <https://example.org>, <b>bold</b>
and <a href="mailto:x@y.z"> highlight the same as before.

Related, not in this PR: <file.cfg> is also highlighted as an HTML tag,
though CommonMark does not treat it as one. Happy to look at that separately
if you think it is worth fixing.

The local part of an email autolink only accepted alphanumerics, '_',
'+' and '-', so an address like <first.last@example.com> fell through
to the HTML tag rule and was highlighted as a tag named "first".  Use
the local-part character set from the CommonMark spec instead.

Reference: https://spec.commonmark.org/0.31.2/#email-autolink
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant