-
Notifications
You must be signed in to change notification settings - Fork 328
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
Can not load local image and link to local .md file #40
Comments
@Cu-Toof here is my solution. Just drop a text file containing your content anywhere in your project and use the following in your code: import UIKit
import Down
class ViewController: UIViewController {
var downView: DownView?
override func viewDidLoad() {
super.viewDidLoad()
let path = Bundle.main.path(forResource: "NameOfMyFile", ofType: "txt")
let content = try? String(contentsOfFile: path!, encoding: String.Encoding.utf8)
print(content!)
downView = try? DownView(frame: self.view.bounds, markdownString: content) {
self.view.addSubview(self.downView!)
}
}
} |
I want to click a link in the content of WKWebView to show a .md file that is saved in local and my solution is WKScriptMessageHandler. But I have an issue, I can't set WKWebViewConfiguration because DownView class has inited WKWebView with WKWebViewConfiguration default. So, I have not used DowView and custom a new WKWebView. Could you please edit DownView class with init method that can set WKWebViewConfiguration. WKWebViewConfiguration will help developer can handle javascript in WKWebView. |
@Cu-Toof and as for the images not loading, the problem comes from the The solution I found was to:
downView = try? DownView(frame: self.view.bounds, markdownString: content, templateBundle: Bundle.main) {
self.view.addSubview(self.downView!)
} or in the whole import UIKit
import Down
class ViewController: UIViewController {
var downView: DownView?
override func viewDidLoad() {
super.viewDidLoad()
let path = Bundle.main.path(forResource: "content", ofType: "md")
let content = try! String(contentsOfFile: path!, encoding: String.Encoding.utf8)
downView = try? DownView(frame: self.view.bounds, markdownString: content, templateBundle: Bundle.main) {
self.view.addSubview(self.downView!)
}
}
}
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=640"/>
<link charset="utf-8" href="down.min.css" rel="stylesheet">
<script charset="utf-8" src="highlight.min.js" type="text/javascript"></script>
<script charset="utf-8" src="down.js" type="text/javascript"></script>
<title></title>
</head>
<body>
DOWN_HTML
</body>
</html> You can now add your own images in the You can also add your own css and js as long as you reference them in |
@Cu-Toof said:
Try my solution and if it doesn't work, why not make a pull request yourself to add this feature? |
Thanks for your help @ladislas 💯 I'm happy to review any pull requests to improve upon this |
Closing this for now; feel free to re-open for any PRs or further help needed |
I want to load local image and link to local .md file in .md file. So, I want to know subclasses that I have to edit. Could you please tell me?, thank you
The text was updated successfully, but these errors were encountered: