Headings from the first line of a document

Hi,

I’m nearly sure that we have discussed about this issue in the past, but I can’t find it. So, I’ll have to ask (again).

I would like to get the headings (H1, H2, H3…) from the first line of a document, instead of the document name in the Binder.

This is because I would like to leave the document names in the Binder in English, so that the structure continues to be readable even after the project has been translated.

The level of the heading should be created in some other way, not being able to do it, at this point in the dedicated panel, but I can’t figure how.

Is this possible?

Thank you!
Paolo

What format are you using for output?

One alternative would be to use a “body text only” Section Layout, and format the headings as desired in the body of the document.

No particular format, actually. I would use it for Markdown/PDF and Markdown/HTML.

The idea was this one. Use RTF styles to add a visual format to text. But then I wouldn’t have a match in the document’s structure. That is, would I be able to compile this first line of text as an H2 or H3 entity?

Paolo

Scrivener 3 supports true styles, which would pass through to Word and similar. If you’re compiling to a Markdown format, though, the simplest solution is to use Markdown’s Style markup.

Do you mean, I should include in the body of the document the ‘#’ markup for a section level? So, the text should show something like:

## This is my second-level section title

I guess this is a viable solution.

Paolo

Yes.

All the other things that Section Layouts do – like defining page breaks and other separators – will still work as normal, you’re just formatting titles for yourself.

1 Like

And I guess I can also automate this, by adding the hashtags as a Style Prefix in the Compilte > Styles dialog.

Paolo

If you want. But that assumes you’ve already assigned the Styles to the relevant text. If you haven’t, then it’s up to you whether to even use Styles in Scrivener, since Markdown will parse the hashtags whether you do or not.

1 Like

That would be fine for me. I like to use Scrivener as a visual editor, that is capable of exporting to markdown.

Visual, in this case, doesn’t mean that I want the Scrivener document to appear as the final output. I just want that the styles behave as a signal of the structural elements.

Paolo

I did some experiments, and I see that adding the hashtags is not really needed.

I noticed that compiling my RTF project to either Basic MultiMarkdown or Basic Pandoc doesn’t do a good job. For example, I don’t get the double space needed to recognize a new paragraph in markdown.

So, I checked the “Convert rich text to MultiMarkdown” option, and this translated into correct markdown. The heading level (H1, H2…) is inherited from the level hierarchy in the Binder.

This makes me wonder why this option is unchecked by default. Maybe it is because it is supposed that one chooses the “purist” markdown editing method, if choosing this output format?

Paolo