Debian Codegraph @

docs/src/markdown/extensions/saneheaders.md

raw
1 ---
2 icon: lucide/hash
3 ---
4 [:octicons-file-code-24:][_saneheaders]{: .source-link }
5
6 # SaneHeaders
7
8 ## Overview
9
10 SaneHeaders is an extension that alters the default hashed headers extension to require headers to have spaces after the
11 hashes (`#`) in order to be recognized as headers. This allows for other extension syntaxes to use `#` in their syntaxes
12 as long as no spaces follow the `#` at the beginning of a line.
13
14 Currently, Pymdown Extensions has two extensions where SaneHeaders can help.
15
16 1. [MagicLink's issue syntax](./magiclink.md#issues-pull-requests-and-discussions) uses hashes followed by numbers
17 (`#998`) to represent issue links. There may be extensions that use names after hashes to provide tags (`#tag`).
18 With SaneHeaders, these syntaxes can coexist. Those familiar with CommonMark may recognize this behavior.
19
20 2. [FancyLists' syntax](./fancylists.md) exposes a generic ordered list style that doesn't require you to provide
21 numbers. This syntax utilize the `#.` marker for list items.
22
23 ```py3
24 import markdown
25 md = markdown.Markdown(extensions=['pymdownx.saneheaders'])
26 ```
27
28 ## Syntax
29
30 The syntax when using SaneHeaders is exactly like Python Markdown's default logic with the only exception being that
31 SaneHeaders will not treat hashes at the beginning of a line as a header if they do not have space after them.
32
33 In Python Markdown, both of these are treated as headers:
34
35 ```
36 ## Header
37
38 ##Also a Header
39 ```
40
41 With SaneHeaders, only the first is a header:
42
43 ```
44 ## Header
45
46 ##Not a Header
47 ```