Under review

Opening a Markdown link in Safari mishandles escapes

John Meyer 3 years ago in iPad updated 3 years ago 3


in Markdown:
[YouTube vid](https://www\.youtube\.com/watch?v=2SJ977\-CMPg&t=360)

if I try to open this in Safari or copy the link (from the Preview)... I get the following URL, which is malformed...


there's several issues with that URL... first \. in the Markdown should become . in preview, but instead it becomes /.
also \- should become - and & should become & but both are left as is

as a test, the following 2 lines of Markdown will produce the identical string of output characters (although the second line will be wrapped in a "pre" tag), unless escaping is broken in which case the first line will have extra backslashes


I just tested this in Textastic and in the Mac app "Marked 2", and looked at the HTML source generated by both apps.

Textastic uses the MultiMarkdown library, Marked 2 can switch between the Discount library and MultiMarkdown.

Using Discount in Marked 2, the link is unescaped, so "\." becomes ".". But if I use the MultiMarkdown processor in Marked 2, the same thing happens as in Textastic and "\." stays "\.".

I guess the "/." you are seeing is just Safari/iOS trying to interpret the URL. It is not what's in the the generated HTML source code.

So it looks like MultiMarkdown doesn't support escaped characters in Markdown links. Unfortunately there is not much I can do about this, unless I would switch to another Markdown library.

With both libraries, "&amp;" becomes "&amp;amp;" however - so you should just use "&" instead of "&amp;" in the Markdown file.

OK, so this bug report belongs in MultiMarkdown... I suspected as much, although had no idea which library Textastic uses... this is the first time since VSCode exists that I have a tablet that's not Windows, and this all works in VSCode (as well as in Markdown previews inside GitHub & Azure DevOps git repos)... I did open a bug over there

as far as the & escaping... if a browser sees &amp; inside a URL when it's parsing HTML, it renders an & ... and the only way to get &amp; in the HTML from a Markdown file is to put &amp; in the Markdown (technically \& should probably also do it, but most MD to HTML converters usually just output &)

but again, that's an MD converter issue, not Textastic... I doubt I'll do much, if any, coding on my iPad... but I definitely like Textastic... I was looking for an excuse to not subscribe to IAWriter & I found it! (even if it does mean I need to tone down my MD escaping a bit)