More precise formatting (MarkDown?) in Title prefix/suffix


Being relatively new to Scrivener, I already love it. It fits my needs in many, many ways. I like almost all concepts and how they are implemented, one of those being the separation between content and presentation through the compilation process. Working on one project I encountered a (rather specific) layout request of my audience that is hard to do in a straightforward manner:

Each chapter in the project is from a different author. Their name, and their function, must be mentioned in the output, but placing and styling differs for each customer. The same project is output for more than just a few customers, all with their own styling demands. I use different compilation presets to achieve different looks when creating PDF’s, which is the most common target. So, I intend to keep all presentation specifics in these presets.

The author and author’s function are added as two custom metadata keywords to each chapter. One customer demands that author and function follow the chapter title, aligned to the right, the author in bold, the function in regular. So I inserted two custom tags in the title suffix, with appropriate line breaks, and align that section to the right and style it as desired. However, I could not find a way to only get the first custom tag in bold. Styling is obviously assigned to the whole suffix section. (See screenshot)

I tried using markdown in the suffix: <$custom:author> and use the transformations option, but that does not work (neither does having markdown in the keyword content, but that would defeat the concept of separation). A workaround is to have these two lines in the chapter synopsis (that does support markdown with transformation), with markdown on the first, and include that in the output in stead of the title suffix. However, that moves presentation detail to the text (synopsis), and renders the synopsis useless for its real purpose (that I intend to use).

My question: is there any way to do this?

Would it be possible to enable the use of markdown in the title prefix/suffix sections in a future version? Better yet: include a tag type that inserts formatted sections of custom text that in itself may contain content tags…

I know: it is a seemingly small detail, but I am sure I will run into related hard to do demands later on.

Any comments would be welcomed, TIA!

Bart van Hofwegen

Hm, mmd in the prefix/suffix does compile properly:

But as you can see the markdown for bold is not seen in the HTML preview because the default stylesheet normally shows headings bolded. But it is in the source:

<h1 id="1—abstract—26082017"><em>1</em> — Abstract — <strong>26/08/2017</strong> </h1>

\part{\emph{1} — Abstract — \textbf{26\slash 08\slash 2017} }

So you need to create a stylesheet which does not bold headings by default. But the solution depends on what what format you compile to?

Thanks nontroppo! Very interesting, since HTML will probably be on the request list sooner or later. I will make a note of this.

But many targets are PDF for my audience, and markdown in the prefix and suffix is not transformed, even with the correct option selected in transformations. It compiles as literal characters…

Ah OK, I thought because you mentioned markdown, you were using it as your compile target (then generating your PDF from there), but you are compiling straight to PDF, not using MMD to produce the PDF. In that case markdown will not work.

Currently the prefix, title and suffix can each be independently styled in Compile > Formatting, but there is no other way, other than using MMD to create your PDF that I can think of to style within the suffix.

One hack maybe to place the <$title> and <$author> name in the prefix and then the author-function in the suffix alone. That way you style the prefix bold and suffix normal. But if you want the title not bold, only author then that won’t work…

Yes, I thought as much… Unfortunately, the demand is Title aligned to the left + bold + small caps, author right and bold and function below that, right and regular. I guess that the fastest route for this customer is take the PDF into a PDF editor after compile, and manually change the function entries to bold. For about 20 chapters, this is doable. Thanks for the help anyway!

This is the advantage of using full multimarkdown compiles, because you can customise the transformation to the output format more precisely. But you would have to learn a new workflow and install command line tools to generate the PDF to complement Scrivener’s functionality. The only other way as is to write the titles in the documents themselves (not the synopsis), but I agree this also breaks the elegant separation of content and style that compiling is otherwise great at… Though if you say markdown is converted in a PDF compile for synopsis, I can’t see why it couldn’t do this for titles, perhaps you can post this as a formal wish list post?

Hm, I tried to put markdown in the synopsis but it doesn’t convert for me if I use PDF output?

Screen Shot 2017-08-27 at 12.31.10_SMALL.png

EDIT: OK I forgot to enable that transformation in compile, now it works.

Yes, I had already found out that is what I could use as a workaround, and then only switching the synopsis on in compile for that specific customer, but then the synopsis is not usable for its real purpose… And it moves presentation details to the text, something I at least try to avoid. Having a background in software development myself, I think that it may be relatively easy for the developer to enable markdown in the title prefix and suffix, since it is already available in other parts such as the synopsis. Then again, it may not be that easy.

I believe that a better solution would be to introduce a tag that introduces a predefined chunk of styled (formatted) text that in itself could contain one or more of the already existing tags. If nesting those “insert formatted text” tags would be allowed, so much the better. But this could be complicated and might be considered as bloat by some.

The easiest fix would just be to allow Scrivener to convert markdown in Compiled titles like it does for other text. You should make this a formal wishlist post. There may be a good reason Keith didn’t enable it, probably to do with conflicting order of styling (compile says bold, markdown says italic, who to follow?) but I think that could be worked out…

It seems this feature has been added since this was posted. I’m using Scrivener 3.0.3 (3032) and compiling to EPUB. I’m trying to include a link to a website in the suffix. Markdown to RTF conversion works for bold and italics but not for links:

I write this in the section layout title suffix:

I enable Markdown to RTF conversion in titles:

Bold and italics work, but not the link:

Am I doing something wrong or are just links not supported? Thanks!

Your findings are correct. As described in the user manual in §23.4.3, General Options, under the “Rich Text Options” section:

Hi, good question and I don’t know the answer, and sadly don’t have much time to test ATM;

@AmberV do you have an idea about MMD link transformation for suffixes in EPub output?

Using regular old RTF stuff, I think the best I could come up with is to use HTML in the compile settings.

  1. Create a style called “Source Link” in the Styles compile format pane, and check off Treat as raw markup. Text marked with this style won’t have its special characters escaped automatically, meaning the output will pass through into the ePub itself.
  2. In the Section Prefix, drop in your HTML with the custom metadata placeholder.[size=80][1][/size] Select the line and style it with “Source Link”.
  3. Probably set Place prefix after title.

[size=80][1] You could use title suffix as well—does it need to be in the Table of Contents or something? The method words either way, the implementation is only slightly different in terms of how the style is applied.[/size]

Thanks Nontroppo and AmberV for your quick replies.

@AmberV, I used your HTML solution, thank you very much! It would be quite nice to have full MMD support in titles, but this workaround gets me close enough to what I was looking for.

@Nontroppo, I like your Scrivener/Pandoc integration, I might use that in my next project 8)

Glad to hear that works for you. I wouldn’t really call it a workaround though—these are all features designed specifically to do things like this. :slight_smile:

The only really good way to get full MultiMarkdown (or Pandoc) processing in all areas of the output is going to be to use one of those systems.