Go Xojo!

I know I only just released an open source module for converting Markdown to HTML for Xojo iOS but I’m going to do it again. The approach is the same (i.e it uses javascript embedded in an iOSHTMLViewer to do the work) but I’ve changed the underlying javascript from remarkable.js to commonmark.js. This is for two reasons:

  1. commonmark.js is the reference javascript implementation of the CommonMark Markdown spec
  2. It produces identical output to the reference C implementation (cmark) that I’m using in the recently released desktop Markdown to HTML parser

Usage

CommonMark.Initialise() ' need only call once per project

dim md as Text = "This is **bold** text."
dim html as Text = CommonMark.ToHTML(md) ' This is <strong>bold</strong> text.

Find the code on GitHub.

Update 12th Jan 2017: This project has been replaced with my improved CommonMark-iOS project

I’ve just put the finishing touches on a module I’ve been working on for iOS projects. It’s a module for converting Markdown to HTML and HTML to Markdown. I call it Shakespeare. It’s fast (a few milliseconds per document) and requires no plugins or third party items.

How does it work?

It’s essentially a sneaky hack. Rather than implement a Xojo-based Markdown parser and re-invent the wheel, the module uses two javascript scripts embedded in iOSHTMLViewers to do the conversion. It uses remarkable.js and to-markdown.js.

How do I use it in my projects?

Shakespeare is designed to be easy to use. Simply drop it in a Xojo iOS project, initialise it and call one of its two methods:

Shakespeare.Initialise()

dim md, html as Text

' Convert to HTML
md = "This is **bold** text"
html = Shakespeare.MarkdownToHTML(md) ' This is <strong>bold</strong> text

' Convert to Markdown
html = <h1>My heading</h1>
md = Shakespeare.HTMLToMarkdown(html) ' # My heading

Suggestions and feedback welcome.

I’ve just released an open source Xojo module for encoding/decoding HTML entities. It’s inspired by the HTMLEntities module originally created by Thom McGrath. It’s been completely rewritten to use faster Dictionaries and I ’ve migrated as much of the code as is currently possible to the new Xojo framework. Annoyingly, because Xojo still have not implemented a RegEx engine into the new framework, it doesn’t work on iOS.

About

Certain characters need to be encoded if they are to be displayed in a HTML document. These are known as HTML entities. This module will convert these characters into their respective HTML symbols and back again.

Usage

using HTMLEncode

dim raw as Text = "

Copyright © 2016

" dim encoded as Text = raw.EncodeEntities()

Feedback is always welcome.