Skip to content

Commit

Permalink
Fix to match GHs algorithm 1
Browse files Browse the repository at this point in the history
Related to GH-5.
Related to GH-6.
  • Loading branch information
wooorm committed Feb 3, 2021
1 parent f5b9aaa commit cfa1f13
Show file tree
Hide file tree
Showing 18 changed files with 491 additions and 300 deletions.
5 changes: 3 additions & 2 deletions html.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,9 @@ function literalAutolinkHttp(token) {

function anchorFromToken(token, protocol) {
var url = this.sliceSerialize(token)
var href = this.encode(normalizeUri(url))
this.tag('<a href="' + (protocol || '') + href + '">')
this.tag(
'<a href="' + this.encode(normalizeUri((protocol || '') + url)) + '">'
)
this.raw(this.encode(url))
this.tag('</a>')
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
"syntax.js"
],
"dependencies": {
"micromark": "~2.11.0"
"micromark": "~2.11.3"
},
"devDependencies": {
"nyc": "^15.0.0",
Expand Down
15 changes: 14 additions & 1 deletion readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,20 @@

**[micromark][]** extension to support GitHub flavored markdown [literal
autolinks][].
This syntax extension matches the GFM spec and github.com.

This syntax extension matches the GFM spec and how literal autolinks work
in several places on github.com.
Do note that GH employs two algorithms to autolink: one at parse time,
one at compile time (similar to how @mentions are done at compile time).
This difference can be observed because character references and escapes
are handled differently.
But also because issues/PRs/comments omit (perhaps by accident?) the second
algorithm for `www.`, `http://`, and `https://` links (but not for email links).

As this is a syntax extension, it focuses on the first algorithm.
The `html` part of this extension does not operate on an AST and hence can’t
perform the second algorithm.
`mdast-util-gfm-autolink-literal` adds support for the second.

This package provides the low-level modules for integrating with the micromark
tokenizer and the micromark HTML compiler.
Expand Down
Loading

0 comments on commit cfa1f13

Please sign in to comment.