-
Notifications
You must be signed in to change notification settings - Fork 333
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
[DownView] Load multiple .md files (link support) #68
Comments
@karstengresch You'd likely need to form proper url links so the browser understands what you're trying to do. This is no different than rendering markdown on Github (except they render those relative urls correctly). Safari likely doesn't point to local filesystem unless you help it out. Also, what happens when you try to intercept link tap handling yourself? e.g. https://stackoverflow.com/a/44409486/308315 |
Thanks @iwasrobbed - your answer is very appreciated. Thanks also for Down in general - it's really a fantastic Markdown processor (wrapper)!
Thanks, I knew the WKWebView API, used a clone of DownView, made it it's own WKNavigationDelegate (could have used my ViewController, too) and used public func webView(_ webView: WKWebView, decidePolicyFor navigationAction: WKNavigationAction, decisionHandler: @escaping (WKNavigationActionPolicy) -> Void) {
guard let url = navigationAction.request.url else { return }
switch navigationAction.navigationType {
case .linkActivated:
decisionHandler(.cancel)
print("MyWebView: decidePolicyForNavigationAction: \(url)")
#if os(iOS)
if #available(iOS 10.0, *) {
UIApplication.shared.open(url, options: [:], completionHandler: nil)
} else {
UIApplication.shared.openURL(url)
}
#elseif os(OSX)
NSWorkspace.shared.open(url)
#endif
default:
decisionHandler(.allow)
}
} which in fact triggers the link so it can be handled. Anyway, my idea was to have local Markdown support out-of-the-box in DownView. This came in handy especially if you deal with a larger set of Markdown documents referencing each other. I guess @128keaton got the idea by tagging this issue as enhancement. Probably there are more developers outside that'd love to have a view control capable of rendering e.g. their documentation...? |
Glad to hear @karstengresch ! We'll leave this open for now and we can add this conditionally behind a boolean flag in the future for that use case |
Hi @iwasrobbed - wonderful, thank you very much.
Sounds really great, thanks again! |
If I understand this correctly, I believe my recent additions suffice to close this issue. Take a look at the testCustomURLSchemeHandler test case for an example that uses a custom URL scheme handler. The only possible inconvenience may be that you'd have to use a custom URL scheme (like "down://" in the test case). |
Going to close this out since we haven't heard back from @karstengresch for Chris' comment above |
I've especially noticed Can not load local image and link to local .md file #40 and here one issue with local images could successfully be solved.
Report
Help needed. For either DownView or a hint how to implement this.
Alternatively, the example could perhaps get a bit extended.
What did you do?
Loading a local .md file that has a link to another local .md file. E.g. you have
What did you expect to happen?
Tapping on the link should load the other markdown file.
What happened instead?
Nothing. Also no exception or else in the console.
The text was updated successfully, but these errors were encountered: