Is it possible to generate style tags in the head section of HTML output from the MMD to HTML compile?
I see how to generate metadata in the head tags.
I also see how to generate inline styles by connecting the stylesheets to compile styles and appending the HTML in the prefix and suffix fields. (This works pretty well except when Scrivener would otherwise generate HTML—when generating the HTML for a hyperlink, for instance. The process outputs only the HTML in the prefix and suffix fields, unless I am missing something.)
Its simple enough to open the resulting html file and paste in a stylesheet, but I am just wondering if it is possible to do it in one step inside Scrivener.
I’m not exactly sure how you are doing this, but I would approach this from a slightly different angle than it sounds like you are. As is often the case, it is best to work backwards from what we want, and then see how to get that result in Scrivener. Focussing only the elements of HTML integral to making this work, here is what I would like:
[code]
.test { color: red }
Now we will test the style.
[/code]
To get that result, here is the MultiMarkdown output intention, using the HTML header metadata key:
[code]Title: Blah
HTML Header: .test { color: red }
This is a test of embedding styles
Now we will test the style.
[/code]
So how do we get that from Scrivener? It sounds like you’ve already got the part in the test paragraph figured out, but to recap for clarity:
Create a style in the Styles compile format pane and set its prefix/suffix to the span HTML with the “test” class.
If using RTF->MMD conversion, make sure your raw HTML is handled as raw markup with the checkbox.
Now how to get that header? Well if you know a thing or two about the “Title” part you may already know how to do the rest:
In the Metadata compile format pane, add a new key called “HTML Header”.
Copy and paste your style block into the text field below. You may use multiple lines, but be aware of the rules (in the introduction of the previously linked to reference) for doing so safely, to avoid prematurely terminating the metadata block or having your CSS keys incorrectly interpreted as metadata keys (since they follow the same name:value syntax).
And now you get red text when you style it appropriate in the text editor, without any pasting into HTML files after compiling.
As for Scrivener doing that automatically, that would be an undesired assumption in some cases. If your .test class was in fact set up in a .css file that you link to with MMD’s metadata key for doing so, then Scrivener would be effectively overwriting your classes by inserting its own assumptions at a higher level of priority in the cascade, in the HTML head.