Markdown images in split files. (revised question)

Ah, OK, some deep research into Scrivener and MultiMarkdown later, let me rephrase this.

Scrivener compiles images, inMMD mode, to two lines:


and, at the end of the file:

[image_file_name]: image_file_name.png

Then one’s MMD processor links these back together.

I’m curious why it does this, when


would have worked, but be that as it may:

This, of course, doesn’t survive well if you’re splitting the file. I’ve reviewed AmberV’s splitter anise how she handled this. I can copy that, and will do. However, just in case …

Is there a way to make Scrivener put these two related lines together where the image appears?, Or, is there a way to get it to produce the single-line form, which would be most convenient?


It uses the reference format so that it can record the image size as well:

[image_id]: filename.png width=144px height=280px

You do have full control over image syntax if you wish however. There is an alternate method that still affords you the compile automation of exporting the graphic into the compile folder, while providing the syntax yourself—useful if you need do supply additional attributes we don’t support, or if you want manual control over inline or precise reference placement.

The method is described in the Markdown chapter, under §21.5.1, Images, subsection “Reference Images with Document Links”. In figure 21.2, you can see some custom Pandoc syntax being used to assign a class to the img element.

Otherwise, the method I use in the script is perfectly fine, if a little ideologically messy. Both MMD and Pandoc will ignore invalid footnote and image reference IDs, so having the entire output’s list at the end of each file doesn’t hurt anything.

Thanks, Amber, you’re a star as usual.

It’s section 21.4.1, but who’s counting. I had looked at that a number of times, including last night, but didn’t understand what it was telling me. (I often wonder, using Scrivener, whether I am as bright as I think I am. :smiley: )

I’ll try it now … Yay! I made that work. At first, I missed the fact that the image has to be in the Binder already, though the text says that. Why? (I mention this in case it’s useful in revising the manual someday.)

I was confused because other than maybe playing with the tutorial, I’ve never put an image in the Binder before. So I thought I was to option-drag it from desktop or folder into Scrivener with the text in the parens selected. That of course is impossible. So, trying again, I went to binder pane, selected the gear, did Add > Existing Files … and then option-dragged into the markdown’s selected parenthesized text. Voila.

What would have helped me would have been just those instructions, maybe like this:

  1. If the desired image isn’t already in the binder, add it using (idk) Gear > Add > Existing Files. It will show up in Research.
  2. Create a conventional Markdown image link where you want the picture to appear, Put anything in the parenthesized place where the image file will go: Your image text).
  3. Select the text in the parens. (anything).
  4. From the binder, hold Option and drag the image into the editor. The text (anything) will be replaced at compile time with the exported file name of the image. (Trust us on this.)

Anyway, I see how that approach works.

I’m with you that pasting all the references everywhere is a bit nasty but it’s also far more convenient in the long run, and makes the document during editing show the image, which is a big advantage. So, as I was planning before I read this, I think I’ll go ahead and enhance my Ruby script to do that copy, similar to how yours does it.


Oops, yes I was referencing section numbers from the latest revision for 3.0.3. :slight_smile:

Thanks for the feedback, I’ll see about perhaps adding some cross-references in here for those unfamiliar with the tools being described.

It sounds to me as though you read the parenthetical hint on opt-dragging by itself; the core isntruction solely states that what we are doing here is creating a document link pointing to an image in the binder:

So perhaps the hint is distracting and I’ll just leave it to the cross-reference. There are several ways to create document links, opt-dragging is only one of them.

Yes. Another possibility is that I am not quick. Or that I was too quick. Anyway, maybe there’s improvement to be made to aid people like me, if there are any. :smiley: