Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(markdown) Images with empty alt or links with empty text #3233

Merged
merged 3 commits into from Jun 14, 2021
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGES.md
Expand Up @@ -2,6 +2,7 @@

Grammars:

- fix(markdown) Images with empty alt or links with empty text (#3233) [Josh Goebel][]
- fix(python) identifiers starting with underscore not highlighted (#3221) [Antoine Lambert][]
- enh(clojure) added `edn` alias (#3213) [Stel Abrego][]
- enh(elixir) much improved regular expression sigil support (#3207) [Josh Goebel][]
Expand Down
6 changes: 5 additions & 1 deletion src/languages/markdown.js
Expand Up @@ -105,12 +105,16 @@ export default function(hljs) {
},
// whatever else, lower relevance (might not be a link at all)
{
begin: /\[.+?\]\(.*?\)/,
begin: /\[.*?\]\(.*?\)/,
relevance: 0
}
],
returnBegin: true,
contains: [
{
// empty strings for alt or link text
match: /\[(?=\])/
},
{
className: 'string',
relevance: 0,
Expand Down
4 changes: 4 additions & 0 deletions test/markup/markdown/links.expect.txt
@@ -0,0 +1,4 @@
![](<span class="hljs-link">https://example.com</span>)
[](<span class="hljs-link">https://example.com</span>)
![<span class="hljs-string">alt</span>](<span class="hljs-link">https://example.com</span>)
[<span class="hljs-string">text</span>](<span class="hljs-link">https://example.com</span>)
4 changes: 4 additions & 0 deletions test/markup/markdown/links.txt
@@ -0,0 +1,4 @@
![](https://example.com)
[](https://example.com)
![alt](https://example.com)
[text](https://example.com)