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

Refactor link detection to be more robust #281

Open
mojavelinux opened this issue Apr 26, 2013 · 9 comments
Open

Refactor link detection to be more robust #281

mojavelinux opened this issue Apr 26, 2013 · 9 comments
Assignees
Labels
Milestone

Comments

@mojavelinux
Copy link
Member

@mojavelinux mojavelinux commented Apr 26, 2013

Currently, the link matching is being performed by two regular expressions that are trying to handle entirely too many cases. Rework the detection so that it's more robust against special characters at the end of links that should not be part of the link. Otherwise, we'll be playing whack-a-mole trying to deal with all the special cases that arise.

@mojavelinux
Copy link
Member Author

@mojavelinux mojavelinux commented Apr 26, 2013

As reported by @davidfavor:

When a link exists in parens - (for example http://foo.com), then the trailing ')' is rendered inside both the href + link text.

@mojavelinux
Copy link
Member Author

@mojavelinux mojavelinux commented Apr 26, 2013

There is also a case in the AsciiDoc User Guide where this fails:

...for example (from http://www.808.dk/?code-html-5-video):
@mojavelinux mojavelinux modified the milestones: v1.5.1, v1.6.0 Sep 18, 2014
@mojavelinux mojavelinux modified the milestones: v1.6.0, v1.7.0 Dec 21, 2015
@mojavelinux mojavelinux modified the milestones: v1.7.0, M3 Jan 9, 2019
@Norcim133
Copy link

@Norcim133 Norcim133 commented Mar 20, 2019

I assume that a complex URL can't be used with an image?

@mojavelinux
Copy link
Member Author

@mojavelinux mojavelinux commented Mar 20, 2019

For the record, the cited example now works.

@mojavelinux
Copy link
Member Author

@mojavelinux mojavelinux commented Mar 20, 2019

@Norcim133 can you cite a case you don't think is working?

@Norcim133
Copy link

@Norcim133 Norcim133 commented Mar 20, 2019

I was trying to embed an image from draw.io but it seemed not to handle the complex URL:
https://www.draw.io/?lightbox=1&highlight=0000ff&edit=_blank&layers=1&nav=1&title=CS6440-IFD.drawio#Uhttps%3A%2F%2Fdrive.google.com%2Fuc%3Fid%3D1IS2gZHxSEzETYo2m7XJ6dC-wNb1ZTIpj%26export%3Ddownload

Don't get me wrong. I'm sure this might fail for additional reasons. But I couldn't get it to fully accept the url to test various approaches to embedding.

@mojavelinux
Copy link
Member Author

@mojavelinux mojavelinux commented Mar 21, 2019

First prove to me that you can actually use that URL in a regular HTML document. Only then will you find that you can use it as the target of an AsciiDoc image. When I visit that URL, I get a whole HTML document, which is not going to work in HTML.

In other words, what I'm trying to say is that that isn't an image URL.

@Norcim133
Copy link

@Norcim133 Norcim133 commented Mar 21, 2019

So what I actually want was this giant thing of embed code (below) that I know works in html.

This exact bit won't work verbatim as I've created a break in the middle to leave out 50 pages of text.

<img src="data:image/png;base64,iVBORw0KGgoAAAA... ...mCC" style="cursor:pointer;max-width:100%;" onclick="(function(img){if(img.wnd!=null&&!img.wnd.closed){img.wnd.focus();}else{var r=function(evt){if(evt.data=='ready'&&evt.source==img.wnd){img.wnd.postMessage(decodeURIComponent(img.getAttribute('src')),'*');window.removeEventListener('message',r);}};window.addEventListener('message',r);img.wnd=window.open('https://www.draw.io/?client=1&lightbox=1&edit=_blank');}})(this);"/>

@mojavelinux
Copy link
Member Author

@mojavelinux mojavelinux commented Mar 21, 2019

You probably just want to use a pass block then. You can abstract it away using a custom block macro like drawio::<id>[]. You are really doing pretty low-level HTML work. Asciidoctor certain supports that, just not using the built-in image macros.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants