Scrivener+MMD treating JPG, PDF & SVG differently?

Hi,

I use the following formatting to insert figures:

![Fig:<$n:figure:figname> — a) figure legend text here](fignamelink)

Where fignamelink is a scrivener link to an image in my binder>research. If fignamelink is a JPG, then I get the following lovely MMD>HTML:

![Fig:1 — a) figure legend text here](figname.jpg)

<figure>
<img src="figname.jpg" alt="Fig:1—a) figure legent text here" />
<figcaption>Fig:1—a) figure legend text here</figcaption>
</figure>

However, if the linked resource is an PDF, then I only get:

![Fig:2 — a) figure legend text here](figname.pdf)

<img src="figname.pdf" alt="Fig:2—a) figure legend text here" />

Although the MMD Scrivener generates seems OK and it does export the PDF so this is probably an MMD issue…

But worst of all if the linked resource is an SVG, Scrivener fails to generate a working link and doesn’t export the SVG file:

![Fig:3 — a) figure legend text here](fignamelink)

fignamelink was the text in the scriv document, which hasn’t been expanded to figname.svg or the SVG – so MMD can’t do anything with this, although it also renders it without figure/figcaption

How can I get Scrivener>MMD to give me my semantic figure and figcaption markup for PDFs and SVGs – the PDF failure to use figure is an MMD issue? Note PDFs and SVGs are valid formats for img[1]…


I have MMD 4.5 installed (I assume it is being used), Scrivener 2.5 on OS X 10.9.3

[1] dev.w3.org/html5/spec-preview/th … ement.html

Right, OK, the difference for generating figure/figcaption markup is due to user stupidity, I wasn’t enforcing a new paragraph before my link code for the SVG/PDF.

So my remaining issue is getting Scrivener compile to treat SVG like it treats JPG – expand the link to the filename and export the SVG to the compile folder…

I’m pretty sure the only problem here is that SVG is not programmed in as an accepted image format. I’ll see if that is something that can be added to the list so that links to them are treated as graphics.

Meanwhile just handle it the old-school way and export them into the compile folder, leaving the MMD syntax pointing to where the file will be, rather than linking it to get that done automatically.

Thanks AmberV! Just to say that compressed SVG (SVGZ) is also a valid image format, although Apple’s quicklook doesn’t support it (which Scrivener uses to view), browsers do…

Any idea of when a Scrivener point release will make its way into my grubby hands? I’m good running beta releases too!

@AmberV: how exactly do I make this a smooth process. I have ~ 40 SVGs in multiple binder folders, so exporting them exports into a series of directories. Then I have to manually/programmatically move all the files from the export folders into the compile folder. If I’m exporting MD then I regex fix the broken file names, but the main problem is I’m starting collaborating and I need to regularly generate drafts quickly with MD > FODT – I’m sure I can build up some script to edit the XML (as Scrivener generates paragraphs rather than text boxes) but this is going to take me some time to learn how to do. A bug fix for this sure would be helpful to me…

I don’t understand why so much effort needs to be made here. Once these files are placed in your compile folder, there they will remain. Sure, you have to do that manually, but you’re only doing it once, so why try and build a macro or script?

When you need to create a quick draft you just compile to .fodt into that folder, and you’re done. There are no broken links unless you type the image link itself incorrectly. You’re in full control of the situation here; Scrivener isn’t generating any links for you. If you wanted to put your SVG images on another disk entirely, that would be fine, so long as you link to them correctly using an absolute link in your project. But for ease of use, I’d just drop the graphics into a folder with “-mmd” on the end of it, and compile into that whenever you need a draft.

Perhaps a simple illustration will suffice to explain, because I think I’m not getting the simple elegance of this approach across. If I export all of my graphics into a folder, I will have something like this:

my_project-mmd/ image1.svg image2.svg

All right, I select FODT from the compile format list and I select this folder to compile into. The result:

my_project-mmd/ image1.svg image2.svg my_project.fodt

Since I referred to images in my draft using a simple reference like so, everything works flawlessly, with no macros and no XML scripting, when I open the .fodt file in LibreOffice.

Maybe I’m not following the problem however, since there isn’t actually any bug that I’m aware of here. Are you experiencing a bug when compiling to the compile folder?

Well, I’m constantly editing various of those figures (which change on each revision) across my binder hierarchy (3 organisational folders deep in the binder), so I can’t just export once and be done with it, I have to either keep a list of changed figures and then do individual exports every compile, or just keep having to flatten the directory structure export creates on every revision…

The second problem is that I don’t use the filename, but links to the binder items, so Figure 6 SVG.svg is renamed as Figure 6 SVG in the binder and thus becomes ![figure legend](Figure 6 SVG) in the figure link as Scrivener doesn’t understand it should do this for me. I like the binder links so I’ve tried to keep them:

  • One problem I realised was spaces in the name breaks multimarkdown (Scrivener fixes this automagically for you) but I have to do it manually for SVG links (which I’ve now done).
  • So I thought I probably have to now rename my binder items with the file suffix .svg explicitly, so Figure 6 SVG.svg is renamed as Figure6SVG.svg in the binder. But of course then Scrivener adds another .svg suffix to the filename on export: Figure6SVG.svg.svg.

So all I can do is break the binder links and use plain text, and then manage my filenames manually in my links (so if I change binder filename I have to find the text and change this each time).

Once I’ve done that, then hopefully the fodt shouldn’t need editing, but I still need to keep juggling my changed figures and folders on each revision, and this still takes me away from writing into fiddling mode on each compile. Is there an automatic way to export while flattening the binder hierarchy?


EDIT: another annoyance of export is that I keep several versions and the Adobe Illustrator originals in the binder, all this gets exported, then I have to manually remove those files from compile…

Okay, well I would have just considered keeping the SVG resources outside of Scrivener permanently. It would be easier to just work with them at the file system level than to continually be going through Scrivener and then export them every time you need to compile, on top of compiling. I have a few projects where I have elaborate compile folders with a lot of material that Scrivener doesn’t produce—I’ve never seen the need to store that material in the project.

But if you must, consider putting all of your .svg files into a Collection and exporting from that, then compiling the .fodt into that export folder.

That’s precisely what I was proposing before, sorry if I didn’t make that clear. Scrivener provides a few conveniences, but it does not replicate the entire range of things one can do with MMD. If you need to do something Scrivener itself doesn’t support, you can always step back to using real syntax.

Meanwhile Keith has found a way to add SVG to the list. In fact we didn’t even have an image list, it was just using the Mac’s definition of what a picture is, to determine whether the thing a Scrivener Link is pointing at is an image that needs to be exported and linked. To be clear it may be a while before that is available to you however, so you will need to find another approach for now.

OK, manual wrangling it is. Thanks for the, as ever, excellent support!

This is just a gentle :bump: to ask if fixing SVG compiling could be pushed into the next point release, instead of waiting for Scrivener 3. I’ve been fiddling with manual compile, but I do still much much prefer using Scrivener to manage my figures — you guys do realise how awesome the binder is at managing resources right!? I do move figures around, edit figures often, try different versions etc. and keeping this synced in large documents manually is still fiddle-factor that detracts from writing…

Did you try the collection method I described? This is what I use when I have a whole batch of images or support files that I need to export routinely, and those items are sorted into folders (or nested among themselves). Since a collection is a flat list it just dumps everything out simply and cleanly for easy access from the file. Having a collection of figures does not restrict you from using the Binder, in case you’ve never tried using them before—they are just lists of items from the Binder.

Thanks Ioa, yes I’m using a collection and manual search / replace for text to keep it all in sync when I make changes. Actually, for work where things get changed a lot, I’ve just accepted PNGs which I can then use scrivener links and full compile support, losing the vector quality as a compromise along the way…

Just an update that this has now been fixed in 2.7:

https://forum.literatureandlatte.com/t/scrivener-2-7-now-available-and-submitted-to-mas/31318/1

Many many thanks for this KB and the gang, SVG support will make a great update to my final document output (you can zoom into scientific figures etc)… :smiley:

Just to note that there is a bug in 2.7 where .svg is ignored for MMD -> HTML output. It works for all other MMD outputs, though. I’ve fixed it for 2.8 so that .svg will be output for HTML too.

OK, good to know thanks! Compressed SVG (.svgz) is not exported yet but that is a minor issue (and as quicklook doesn’t preview svgz only svg I prefer not to use it in Scrivener anyway)… 8)