#### david.veldhouse

10 Jan, 2018 01:49 PM

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:

...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?

1. Support Staff 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:

#merge
index.md
part1.md
part2.md
part3.md


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...

3. Support Staff 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!

6. Support Staff 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.

Formatting help / Preview (switch to plain text) No formatting (switch to Markdown)

### »

#### Attached Files

You can attach files up to 10MB

If you don't have an account yet, we need to confirm you're human and not a machine trying to post spam.

# Keyboard shortcuts

### Generic

? Show this help Blurs the current field

### Comment Form

r Focus the comment reply box Submit the comment

You can use Command ⌘ instead of Control ^ on Mac

## Recent Discussions

 21 Feb, 2020 11:32 PM Option to use MathJax 3? 20 Feb, 2020 03:12 PM Regular crashes 13 Feb, 2020 09:22 PM Markdown Formatting 11 Feb, 2020 11:53 AM Custom themes not working 10 Feb, 2020 06:48 PM KaTex Preview Update

## Recent Articles

 Using JavaScript in Marked Custom CSS: Writing custom CSS for Marked License code has already been utilized Highlight sentences longer than a certain number of words How do I retrieve a lost license (direct version)