URL-encoding of relative file links

Rob's Avatar

Rob

12 Dec, 2012 04:11 PM

I notice (previewing FoldingText files in Marked, for example) that relative paths to image files need to be URL encoded for Marked to digest them happily into embedded images.

For example, this is rendered as an image:

![Screen shot](./Screen%20Shot%202012-12-08%20at%2013.54.01.png)

whereas this appears as a text literal:

![Screen shot](./Screen Shot 2012-12-08 at 13.54.01.png)

i.e.

<figure>
<img src="./Screen%20Shot%202012-12-08%20at%2013.54.01.png" alt="Screen shot" />
<figcaption>Screen shot</figcaption></figure>

<p>![Screen shot](./Screen Shot 2012&#8211;12&#8211;08 at 13.54.01.png)</p>

Does it look feasible to relax that requirement, and get Marked to sub-contract the encoding when it is noticeably absent within an image link ?

It guess it might well slow things down ...

  1. Support Staff 1 Posted by Brett on 12 Dec, 2012 04:31 PM

    Brett's Avatar

    Well, the biggest issue we'd have is that spaces aren't valid in a url. The _have_ to be encoded.

  2. 2 Posted by rob on 12 Dec, 2012 04:40 PM

    rob's Avatar

    Sure – I wasn't being clear :-)

    What I meant was, does it look feasible to detect unencoded filenames within the ![name](url) context, and encode them for the user ?

  3. Support Staff 3 Posted by Brett on 12 Dec, 2012 04:47 PM

    Brett's Avatar

    No, you were clear, but it's a bad idea to fix invalid markup in a preview
    when it's still going to break everywhere else. Might be a good idea in an
    editor, but not when you're just lying to the user about whether their
    markup is working. Do you see what I mean?

  4. 4 Posted by Rob on 12 Dec, 2012 04:56 PM

    Rob's Avatar

    Good, that makes sense - not the right stage at which to fix these things.

    (The context is that FoldingText also uses relative MarkDown links to local files as Finder shortcuts, and these, of course, are not encoded. Perhaps the answer is just a simple pre-processing script to prepare for export, or toggle between the two kinds of links).

    Thanks for your help, (and for all the work that has gone into a really excellent piece of design and engineering - makes a huge difference to the way I'm working with documents at the moment)

    Rob

Reply to this discussion

Internal reply

Formatting help / Preview (switch to plain text) No formatting (switch to Markdown)

Attaching KB article:

»

Attached Files

You can attach files up to 10MB

If you don't have an account yet, we need to confirm you're human and not a machine trying to post spam.

Keyboard shortcuts

Generic

? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac