Convert the iA Writer image format to markdown image format

Long time hugo fan here. I am trying to streamline my writing experience using iA writer as an editor. I use the page bundle format for my posts.

When I drag an image file into iA Editor:

  1. It copies that file into my page bundle
  2. It adds the text of the relative file path on a new line. Like this:

./my-image.png

  1. It shows the image in the preview pane.

It renders that image in the preview pane. This is SO CLOSE to the ideal workflow!

It would be wonderful to find a way to turn that line of text (the relative path of the file) into proper markdown image syntax.

The ia writer team considered using the markdown image syntax, but since the creator of markdown regretted that syntax, they went with this simpler way. Read more about that here: Content Blocks in iA Writer: Include images, tables, text files and code

I’ve been searching for a way to get that relative file path line into the markdown image syntax for hours now. (render hooks, render passthrough hooks, regex in the template).

Would love some help.

James

Ouch. Regrets don’t change standards. Ask Tim Berners-Lee about the double-slash in web addresses.

This is ugly, but works. Everywhere you have this:

{{ .Content }}

Use this instead:

{{ .Content | strings.ReplaceRE `<p>\./(.*(?:gif|jpg|jpeg|png|webp))</p>` (printf "<img src=%q alt=\"\">" "$1") | safeHTML }}
1 Like