Is there any way (commercial or free) to convert Markdown to HTML on iOS?
I know of Christian’s MarkdownMBS plugin which works great for desktop but I need to do the same on iOS (my entire app idea hinges on it). The MBS plugins don’t work on iOS since there is no plugin architecture.
I’ve been trying to write my own Markdown parser in native Xojo to overcome this (source code of the work in progress here but essentially it’s not going to work for two reasons:
1). Markdown is insanely complex to parse
2). My native parser relies on RegEx (which itself is not available on iOS)
Is it possible to use a static library on iOS somehow with Xojo or is there any way to port a Markdown library to one of the Xojo iOS libraries like iOSKit?
[quote=306427:@Derk Jochems]Maybe with ioshtmlviewer
Opening a html file with some javascript that paraes the markdown to html.
Markdown-js[/quote]
Whilst that’s a hack - I really like the ingenuity of it. I think I’ll try and put some test code together to see if it’s possible…
[quote=306429:@Tim Dietrich]@Garry Pettet: I’m not sure if this is an option for you, but you’re welcome to use it:
It’s a simple API that you can use to convert Markdown to HTML. You just HTTP POST some Markdown to it and it returns the HTML.
It’s based on Parsedown, which was written in PHP. I’d love to convert it to Xojo at some point.
Anyway, it’s something to consider, and I hope this helps.[/quote]
Thanks Tim. An equally valid solution but I’m hoping to be able to use the app offline as well as online so server parsing is not realistic. Nice implementation of Parsedown though. Be warned about parsing Markdown with Xojo though - my MarkdownKit is almost there (just a few more nasty regexes to write) but it is insanely mind-bendingly tricky to parse!
[quote=306431:@Michel Bujardet]We have been told back in 2014 that Xojo could not link static libraries because of iOS 7 support. Since then, no news.
As far as I know iOS 7 has been abandoned… So ?[/quote]
I dislike the two year silence on this. I’m sure it’s difficult to implement but allowing the inclusion of static libraries to iOS would open up a whole host of possibilities for Xojo development.
[quote=306507:@Garry Pettet]@Derk Jochems Looks like there’s no way to get the contents of the page with iOSHTMLViewer so a clever use of Javascript won’t help.
[/quote]
Fortunately, Jason King has added cancelLoad and ExecuteJavaScript based on EvaluateJavaScript that returns a value, so you can indeed take advantage of that.
[quote=306507:@Garry Pettet]@Derk Jochems Looks like there’s no way to get the contents of the page with iOSHTMLViewer so a clever use of Javascript won’t help.
Looks like I’m SOL until Xojo get their act together and let us include static libraries on iOS…[/quote]
You should be able to get the content using a declare, i might have read that on the forums. Remember that js has the possibility to write files. You have the possibility to read files in xojo.
[quote=306514:@Michel Bujardet]Fortunately, Jason King has added cancelLoad and ExecuteJavaScript based on EvaluateJavaScript that returns a value, so you can indeed take advantage of that.
I’ve just put up a module on GitHub to convert Markdown to HTML and HTML back to Markdown. It uses Javascript embedded in an iOSHTMLViewer. It’s actually pretty fast (10 ms for a large document) and seems robust.
It’s currently iOS only although I have a working solution for desktops which I’m also about to publish.