Infer titles of pages based on full Markdown parsing (#3191)

Properly parse Markdown and report the first H1 tag rather than naively looking for `# Stuff` at the start of the doc.

This satisfies feature requests such as supporting setext-style headers and fixes attr-list suffixes that failed to be ignored.

Co-authored-by: Hendrik Polczynski <hendrikpolczyn@gmail.com>
Co-authored-by: Darrick Herwehe <darrick@exitcodeone.com>
This commit is contained in:
Oleh Prypin
2023-05-29 21:59:31 +02:00
committed by GitHub
parent 8ecdfb2510
commit 5af8bd3053
4 changed files with 189 additions and 46 deletions

View File

@@ -380,10 +380,14 @@ specific page. The following keys are supported:
MkDocs will attempt to determine the title of a document in the following
ways, in order:
1. A title defined in the [nav] configuration setting for a document.
2. A title defined in the `title` meta-data key of a document.
3. A level 1 Markdown header on the first line of the document body. Please note that [Setext-style] headers are not supported.
4. The filename of a document.
1. A title defined in the [nav] configuration setting for a document.
2. A title defined in the `title` meta-data key of a document.
3. A level 1 Markdown header on the first line of the document body.
([Setext-style] headers are supported *only since MkDocs 1.5*.)
4. The filename of a document.
Upon finding a title for a page, MkDoc does not continue checking any
additional sources in the above list.