How can i make a navigation with head label like "h1 h2" #171

Closed
opened 2026-01-29 14:29:24 +00:00 by claunia · 2 comments
Owner

Originally created by @luodaoyi on GitHub (Dec 10, 2017).

How can i make a navigation with head label like "h1 h2"

like:

# first 
blablablablabla
## second
   blablablabla
### three
   blablablabla
### three-2
   blablablabla

## second-2
  blablablabla
### three-3
  blablablabla
### three-4
blablablabla
#### four
blablablabla

except html document
i want to have a nav list like this:

 <nav id="toc">
        <p><strong> Preview List</strong></p>
                <ul>
                    <li>
                        <a href="#first"> first </a>
                        <ul>
                            <li><a href="#second">second</a></li>
                           <ul>
                                  <li><a href="#three">three</a></li>
                                  <li><a href="#three-2">three-2</a></li>
                           </ul>
                            <li><a href="#second-2">second-2</a></li>
                           <ul>
                                  <li><a href="#three-3">three-3</a></li>
                                  <li><a href="#three-4">three-4</a></li>
                                  <ul>
                                        <li><a href="#four">four</a></li>
                                 </ul>
                           </ul>
                        </ul>
                    </li>
                </ul>
</nav>

now the attribute like "id" is ok

var pipeline = new MarkdownPipelineBuilder()
                .UseNoFollowLinks()
                .UseMediaLinks()
                .UseAutoIdentifiers(AutoIdentifierOptions.GitHub)
                .Build();
 var doc = Markdown.Parse(Text, pipeline);

How can i do to generate navigation list?
thanks to Reply !
👍

Originally created by @luodaoyi on GitHub (Dec 10, 2017). How can i make a navigation with head label like "h1 h2" like: ``` # first blablablablabla ## second blablablabla ### three blablablabla ### three-2 blablablabla ## second-2 blablablabla ### three-3 blablablabla ### three-4 blablablabla #### four blablablabla ``` except html document i want to have a nav list like this: ``` <nav id="toc"> <p><strong> Preview List</strong></p> <ul> <li> <a href="#first"> first </a> <ul> <li><a href="#second">second</a></li> <ul> <li><a href="#three">three</a></li> <li><a href="#three-2">three-2</a></li> </ul> <li><a href="#second-2">second-2</a></li> <ul> <li><a href="#three-3">three-3</a></li> <li><a href="#three-4">three-4</a></li> <ul> <li><a href="#four">four</a></li> </ul> </ul> </ul> </li> </ul> </nav> ``` now the attribute like "id" is ok ``` var pipeline = new MarkdownPipelineBuilder() .UseNoFollowLinks() .UseMediaLinks() .UseAutoIdentifiers(AutoIdentifierOptions.GitHub) .Build(); var doc = Markdown.Parse(Text, pipeline); ``` How can i do to generate navigation list? thanks to Reply ! 👍
claunia added the question label 2026-01-29 14:29:24 +00:00
Author
Owner

@xoofx commented on GitHub (Dec 11, 2017):

There is nothing like this builtin into markdig, but you can have a look at a code sample md2toc here that prints something similar to what you are looking for:

5020fdd3b1/src/mdtoc/Program.cs (L70-L98)

It doesn't print HTML but markdown, but it should be pretty easy to modify to your requirements.

@xoofx commented on GitHub (Dec 11, 2017): There is nothing like this builtin into markdig, but you can have a look at a code sample md2toc here that prints something similar to what you are looking for: https://github.com/lunet-io/markdig/blob/5020fdd3b1d7b94663068f905dbc311a36e7957b/src/mdtoc/Program.cs#L70-L98 It doesn't print HTML but markdown, but it should be pretty easy to modify to your requirements.
Author
Owner

@luodaoyi commented on GitHub (Dec 11, 2017):

thank you!

@luodaoyi commented on GitHub (Dec 11, 2017): thank you!
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/markdig#171