after much experimenting I just realized that text needs to be located in the „Draft“ section of the binder in order to get the correct header markup in the resulting markdown file. If the text contains a hierarchy of files, the headings will automatically be formatted with the correct number of hash signs around according to the level of the text within that hierarchy.
But, when I choose the text content during the compile as „current selection“, all headers only contain one hash sign, as if there were topl-level headers, regardless of their position in the hierarchy.
Also, when the texts are in the „Research“ section of the Binder, I cannot choose them directly for the compile but need to use „current selection“, resulting in the same phenomenon.
Is this the intended behaviour of Scrivener that a „current selection“ is treated differently from a directly chosen folder/document in the Binder? Why? It doesn’t seem to be documented in the manual but then again the manual (Revision: 2.6.0-01c) says something along these lines on page 349 („When using the current selection“) but then again I do not get the point about the selection as a filter.
It clearly states that compiles from selections and collections will be treated as flat lists that don’t preserve hierarchy. You can use a selection as a filter, and if you do that it will preserve the # levels and if you use section numbering it will be correct. I just tested this and it works as expected, screenshot shows a Level 2 + Level 3 subdocument. Note the Draft is selected at to and I filter on the selection. This gives the correct ## 4.2 Effects on Moon ## and ### 4.2.1 Lunar Cycles ### formatting on compile.