File: auto_identifiers.md

package info (click to toggle)
haskell-commonmark-extensions 0.2.5.5-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 368 kB
  • sloc: haskell: 2,574; makefile: 9
file content (92 lines) | stat: -rw-r--r-- 2,156 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
## Auto identifiers (extension)

The `auto_identifiers` extension causes identifiers to be
added to headings that lack them.  Identifiers derive their
names from the heading text.  The following recipe is used
(this derives from the practice on GitHub and is slightly
different from legacy pandoc auto identifiers):

- Render the textual content of the heading, without
  any formatting (tags)
- Strip leading and trailing space
- Convert to lowercase
- Convert spaces into hyphens
- Remove all punctuation except `-`, `_`, and punctuation in
  the categories NonSpacingMark, SpacingCombiningMark,
  EnclosingMark, and ConnectorPunctuation.
- Replace emojis with their textual aliases

```````````````````````````````` example
#   Heading  with_two_spaces! 
.
<h1 id="heading--with_two_spaces">Heading  with_two_spaces!</h1>
````````````````````````````````

```````````````````````````````` example
Heading  with_two_spaces!
-------------------------
.
<h2 id="heading--with_two_spaces">Heading  with_two_spaces!</h2>
````````````````````````````````

Auto identifiers are not assigned to headings
that have explicit identifiers:

```````````````````````````````` example
# Heading {#foo}
.
<h1 id="foo">Heading</h1>
````````````````````````````````

```````````````````````````````` example
{#foo}
# Heading
.
<h1 id="foo">Heading</h1>
````````````````````````````````

Auto identifiers are not assigned to non-headings:

```````````````````````````````` example
Hi
.
<p>Hi</p>
````````````````````````````````

Numerical suffixes will be added to avoid
duplicate identifiers:

```````````````````````````````` example
# Hi
# Hi
# Hi
.
<h1 id="hi">Hi</h1>
<h1 id="hi-1">Hi</h1>
<h1 id="hi-2">Hi</h1>
````````````````````````````````

Deduplication should work also when auto identifiers
are mixed with explicit identifiers:

```````````````````````````````` example
# Hi
# Hi {#hi}
# Hi

Hi
==
.
<h1 id="hi-1">Hi</h1>
<h1 id="hi">Hi</h1>
<h1 id="hi-2">Hi</h1>
<h1 id="hi-3">Hi</h1>
````````````````````````````````

Emojis should be replaced with aliases:

```
# Introduction ❤️💯
.
<h1 id="introduction-heart-100">Introduction ❤️💯</h1>
```