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 May, 2018 07:33 PM Suggestion: rubberbanding for scrolling 21 May, 2018 04:40 PM Huge PDF sizes after 2.5.14 (947) update 18 May, 2018 03:09 PM Mathjax fails mid-document. 18 May, 2018 02:27 AM Custom Processor not running 2.5.13 and 2.5.14 18 May, 2018 02:08 AM GitHub style doesn't show blank lines when blank lines between bullet items

Recent Articles

 Highlight sentences longer than a certain number of words In-app purchase issues (Error Domain=Paddle Code=0 "(null)") License code has already been utilized How do I retrieve a lost license (direct version) Custom CSS: Writing custom CSS for Marked