-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
Parse autolinks for urls and emails. #11299
Conversation
I forgot that this fails due to Unfortunately/interestingly I don't think commonmark implementation actually follows it's spec with regards to scheme-sensitivity. I don't think we're following the spec on what/when to escape chars... similarly the commonmark implementation is also not following the spec there either! |
Sorry for taking a ridiculously long time to look at this. Looks good anyway. I don't mind removing |
94c81f9
to
55879de
Compare
Has this been done in Documenter? |
Needs to be part of |
The rebase was over footnotes, seemed to be trivial. Pushed but haven't tested... I'm yet to action on:
What's a clean way to do that? |
Does |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added a suggestion for reading. It would nice to have this merged for 0.6
function autolink(stream::IO, md::MD) | ||
withstream(stream) do | ||
startswith(stream, '<') || return | ||
url = readuntil(stream, '>') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Try url = readuntil(stream, '>', match = ' ')
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are we hitting this definition already?
julia/base/markdown/parse/util.jl
Lines 139 to 159 in 550f5d3
function readuntil(stream::IO, delimiter; newlines = false, match = nothing) | |
withstream(stream) do | |
buffer = IOBuffer() | |
count = 0 | |
while !eof(stream) | |
if startswith(stream, delimiter) | |
if count == 0 | |
return String(take!(buffer)) | |
else | |
count -= 1 | |
write(buffer, delimiter) | |
continue | |
end | |
end | |
char = read(stream, Char) | |
char == match && (count += 1) | |
!newlines && char == '\n' && break | |
write(buffer, char) | |
end | |
end | |
end |
I guess I haven't fully grokked what match/count do there, but it looked to me like it was suggesting you'd use <
as the match character i.e. matching braces.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, I misread it. I think you're right and need to do:
text = readuntil(stream, '>', match = '<')
I originally read it too quickly and thought setting it to ' '
to would stop reading at whitespace.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think readuntil
returns nothing
if the input doesn't have '>'. Try with e.g. Markdown.parse("<link")
. Try to add url ≡ nothing && return
Bump, would love to have this. Anyone know what's busted on CI here? |
failed doc build on travis and failed tests on appveyor, due to the |
So that's a bug, it should be returning false if url is nothing. Perhaps implementation changed somewhere down the line, at any rate will push a fix this evening. |
This is now green. |
end | ||
end | ||
|
||
# This list is take from the commonmark spec |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is taken
'<' in s && return false | ||
|
||
m = match(r"^(.*)://(\S+?)(:\S*)?$", s) | ||
m == nothing && return false |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
=== nothing
Remove `@` from escaped html.
Remind me to merge this in a day or two if we haven't gotten any other feedback. |
You should merge this in a day or two if we don't get more feedback. |
I meant more like now. |
fixes #9564
cc @one-more-minute