Is there any way to get AutoIdentifiers list? #676

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

Originally created by @Nyazira on GitHub (May 4, 2024).

If markdown is as follows:

# 1 你好,世界
## 1.1 你好,世界
# 1 Hello World
## 2 Hello World

then it generates the following code:

<h1 id="section">1 你好,世界</h1>
<h2 id="section-1">1.1 你好,世界</h2>
<h1 id="hello-world">1 Hello World</h1>
<h2 id="hello-world-1">2 Hello World</h2>

Since markdown's title contains both Chinese and English characters, I can't predict what kind of Identifier the title will generate.
Is there any way to get a list of identifiers?
So I can generate a directory from the list.

Originally created by @Nyazira on GitHub (May 4, 2024). If markdown is as follows: ``` # 1 你好,世界 ## 1.1 你好,世界 # 1 Hello World ## 2 Hello World ``` then it generates the following code: ``` <h1 id="section">1 你好,世界</h1> <h2 id="section-1">1.1 你好,世界</h2> <h1 id="hello-world">1 Hello World</h1> <h2 id="hello-world-1">2 Hello World</h2> ``` Since markdown's title contains both Chinese and English characters, I can't predict what kind of Identifier the title will generate. Is there any way to get a list of identifiers? So I can generate a directory from the list.
claunia added the question label 2026-01-29 14:42:45 +00:00
Author
Owner

@MihaZupan commented on GitHub (May 4, 2024):

Try

MarkdownDocument document = Markdown.Parse(content, pipeline);

foreach (HeadingBlock heading in document.Descendants<HeadingBlock>())
{
    Console.WriteLine(heading.GetAttributes().Id);
}

string html = document.ToHtml(pipeline);
@MihaZupan commented on GitHub (May 4, 2024): Try ```c# MarkdownDocument document = Markdown.Parse(content, pipeline); foreach (HeadingBlock heading in document.Descendants<HeadingBlock>()) { Console.WriteLine(heading.GetAttributes().Id); } string html = document.ToHtml(pipeline); ```
Author
Owner

@Nyazira commented on GitHub (May 5, 2024):

Try

MarkdownDocument document = Markdown.Parse(content, pipeline);

foreach (HeadingBlock heading in document.Descendants<HeadingBlock>())
{
    Console.WriteLine(heading.GetAttributes().Id);
}

string html = document.ToHtml(pipeline);

Thank you,it works!

@Nyazira commented on GitHub (May 5, 2024): > Try > > ```cs > MarkdownDocument document = Markdown.Parse(content, pipeline); > > foreach (HeadingBlock heading in document.Descendants<HeadingBlock>()) > { > Console.WriteLine(heading.GetAttributes().Id); > } > > string html = document.ToHtml(pipeline); > ``` Thank you,it works!
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/markdig#676