Bug? CSS metadata appends colon to filename

to
tomcam
Posts: 13
Joined: Sat Apr 23, 2016 6:26 am
Platform: Mac

Wed Feb 15, 2017 11:35 pm Post

Goal: Create an Kindle eBook from a book in MMD source.

I believe this has to be done through an intermediate HTML file--please correct me if I'm wrong.

So I want to adjust formatting using an external .CSS file. To do this I:

  • Go to File > Compile and choose Compile For: Multimarkdown -> Web Page (.html)
  • Still in the Compile dialog, Choose Meta-Data
  • Click the +
  • Add this metadata. Note the following is copied and pasted directly from my existing Meta-Data settings:
    css: foo.css
  • Click Compile, then save as HTML file per usual.

The foo.css file doesn't get loaded, because this is the code Scrivener generates. Note the unwanted colon appended to the CSS filename:

Code: Select all

<link type="text/css" rel="stylesheet" href="foo.css:"/>


How can I prevent this from happening and get my formatting back? Thanks!

to
tomcam
Posts: 13
Joined: Sat Apr 23, 2016 6:26 am
Platform: Mac

Thu Feb 16, 2017 1:36 am Post

OK, I've found a satisfactory, maybe even preferable, workaround.

If the very first document is named Meta-Data, then you can include MMD metadata. All I had to do was delete the declaration used earlier in the Compile > Meta-Data dialog, create the Meta-Data document and put the same info in it. I also gave it a relative path, so this text in the Meta-Data document:

Code: Select all

css:  scrivener/foo.css

Became this in the generated HTML:

Code: Select all

<link type="text/css" rel="stylesheet" href="scrivener/foo.css"/>


The reason the second approach is preferable-other than the fact that it's the only one that works-is that you can put all your metadata in a single, easy-to-find place and it can be reused easily in your other masterpieces, whereas copying and pasting from the Meta-Data dialog would be an exercise in frustration and likely omissions.

User avatar
AmberV
Posts: 20612
Joined: Sun Jun 18, 2006 4:30 am
Platform: Mac + Linux
Location: Santiago de Compostela, Galiza
Contact:

Thu Feb 16, 2017 12:03 pm Post

I cannot reproduce the first part of this. I copied and pasted your meta-data from the text here into the MMD table as my first check, and then as a second check I typed it in myself using the GUI as you described. In both cases I get the following:

Image

That said it’s nearly always best to troubleshoot Scrivener by compiling to plain “MultiMarkdown”. That’s all we’re responsible for generating, the other settings all invoke the MMD engine to produce an output against that file, so you could just as well be seeing a bug in its engine but be unable to parse the distinct steps that go into the process and find out where it originates from. I think in this case you might just have it typed in oddly, like maybe you put the whole key:value pair into the key field in the GUI?

As for your “workaround” that’s an intentional feature. It is described in §22.7, MMD Meta-Data, pg. 334 of the user manual PDF. It can be used in combination with the GUI settings as well, so if you had two books in one project for instance you could put the Author field in the GUI and leave the Title fields to each compile block.

The reason the second approach is preferable-other than the fact that it’s the only one that works-is that you can put all your metadata in a single, easy-to-find place and it can be reused easily in your other masterpieces, whereas copying and pasting from the Meta-Data dialog would be an exercise in frustration and likely omissions.

Indeed, for many things I prefer the Meta-Data file approach to using the GUI as well. I’m a Markdown person at heart after all, having this stuff in text in front of me is part of the charm. :) It does have its uses though (like the above), and the fact that it can be saved into a compile preset. Consider that MMD meta-data can be used to define the look of a document through such fields as HTML Header, LaTeX Input and so forth—you can thus save document classes as presets and swap between them while using the Meta-Data document approach for local project specific data.

To back things up a few steps though: have you considered using the Pandoc engine for creating your eBook? MultiMarkdown itself doesn’t have a native ePub generator, so you’ll be stitching it together yourself from HTML files (and it uses HTML5, meaning you may be limited to ePub3 without conversion). I haven’t tested it extensively, but you should be able to use the -f markdown_mmd argument with Pandoc to work with Scrivener’s output directly, and if you wish a more native approach (making using of Pandoc’s own flavour of Markdown more directly) there are ways to do so—most of Scrivener’s output works with either engine. But yeah, you’ll get ePub2 or ePub3 output and from there you can take that into Calibre for final polish.
.:.
Ioa Petra'ka
“Whole sight, or all the rest is desolation.” —John Fowles