Automatically decrement header levels with multi-document linking?
Hello all,
New to the forum, and I didn't find this in any discussions:
Is there a way to force Marked 2 to reduce header levels for multi-document files brought into a master index file?
I write a lot of technical content, and sometimes I mix-and-match different sub-sections that have multiple uses.
For example:
topic1.md:
Header topic 1
Sub-header topic 1
...might be useful as a sub-section for a different topic, such as:
newtopic.md:
New Topic
<<[topic1.md]
...in this example I'd like to bring topic1.md into newtopic.md with it's whole header hierarchy reduced by 1, so it's effective a sub-header of New Topic.
Possible?
Keyboard shortcuts
Generic
? | Show this help |
---|---|
ESC | Blurs the current field |
Comment Form
r | Focus the comment reply box |
---|---|
^ + ↩ | Submit the comment |
You can use Command ⌘
instead of Control ^
on Mac
Support Staff 1 Posted by Brett on 10 Jan, 2018 02:24 PM
This can't be done using Marked's custom include syntax, but it can be accomplished using the mmd_merge syntax that Marked supports. Create an index file that contains nothing but filenames/paths and put
#merge
in the first line. You can then use indentation to manually adjust header levels:So if part1, 2 and 3.md have first level headers, it would now show up in the compiled document with a second-level header, and any subsequent headers within the file are decremented appropriately.
2 Posted by david.veldhouse on 10 Jan, 2018 04:10 PM
That's great, and very useful! One problem is that I'm using Discount processing primarily due to its image scaling capabilities. I don't suppose you know if Discount supports #merge?
Thanks again for the FAST response...
Support Staff 3 Posted by Brett on 10 Jan, 2018 04:52 PM
The merge is built into marked, it just compiles the document before passing it to whatever processor you're using.
- Brett
4 Posted by david.veldhouse on 11 Jan, 2018 02:16 AM
I see. That seems to work as advertised, thanks.
Of course, I want my cake and eat it too:
I can't build a dynamic table of contents this way like I can with Mark's slick "include" syntax, can I?
5 Posted by david.veldhouse on 11 Jan, 2018 02:21 AM
Actually, I think I just answered my own question: putting the <!--TOC--> in the first document after the #merge command seems to work!
Support Staff 6 Posted by Brett on 11 Jan, 2018 02:24 AM
You can't stick a toc tag into the merge file, but you can create a toc.txt (or whatever) with a <!--toc--> tag in it and insert it where you want in the merged document.
- Brett
7 Posted by david.veldhouse on 11 Jan, 2018 12:51 PM
Yes, I ended up getting exactly the output I wanted. Thanks so much for the attention, Brett.