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

[DownView] Load multiple .md files (link support) #68

Closed
1 task done
karstengresch opened this issue Jan 18, 2018 · 6 comments
Closed
1 task done

[DownView] Load multiple .md files (link support) #68

karstengresch opened this issue Jan 18, 2018 · 6 comments
Labels
DownView Issues specific to DownView, the webview renderer feature request

Comments

@karstengresch
Copy link

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

  ## In markdown file number one (one.md)
  [To markdown file number two](two.md)

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.

@iwasrobbed
Copy link
Collaborator

iwasrobbed commented Jan 21, 2018

@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

@karstengresch
Copy link
Author

Thanks @iwasrobbed - your answer is very appreciated. Thanks also for Down in general - it's really a fantastic Markdown processor (wrapper)!

Also, what happens when you try to intercept link tap handling yourself? e.g.
https://stackoverflow.com/a/44409486/308315

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.
Maybe a naive approach to get you busy implementing this and not me ;)

Probably there are more developers outside that'd love to have a view control capable of rendering e.g. their documentation...?

@iwasrobbed
Copy link
Collaborator

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

@karstengresch
Copy link
Author

Hi @iwasrobbed - wonderful, thank you very much.

We'll leave this open for now and we can add this conditionally behind a
boolean flag in the future for that use case

Sounds really great, thanks again!

@iwasrobbed iwasrobbed added the DownView Issues specific to DownView, the webview renderer label Nov 10, 2018
@iwasrobbed iwasrobbed changed the title DownView: Load multiple .md files (link support) [DownView] Load multiple .md files (link support) Nov 10, 2018
@chriszielinski
Copy link
Contributor

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).

@iwasrobbed
Copy link
Collaborator

Going to close this out since we haven't heard back from @karstengresch for Chris' comment above

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
DownView Issues specific to DownView, the webview renderer feature request
Projects
None yet
Development

No branches or pull requests

4 participants