13 // markdown documents. You can assign a custom renderer and set various options |
13 // markdown documents. You can assign a custom renderer and set various options |
14 // to the Markdown processor. |
14 // to the Markdown processor. |
15 // |
15 // |
16 // If you're interested in calling Blackfriday from command line, see |
16 // If you're interested in calling Blackfriday from command line, see |
17 // https://github.com/russross/blackfriday-tool. |
17 // https://github.com/russross/blackfriday-tool. |
|
18 // |
|
19 // Sanitized Anchor Names |
|
20 // |
|
21 // Blackfriday includes an algorithm for creating sanitized anchor names |
|
22 // corresponding to a given input text. This algorithm is used to create |
|
23 // anchors for headings when AutoHeadingIDs extension is enabled. The |
|
24 // algorithm is specified below, so that other packages can create |
|
25 // compatible anchor names and links to those anchors. |
|
26 // |
|
27 // The algorithm iterates over the input text, interpreted as UTF-8, |
|
28 // one Unicode code point (rune) at a time. All runes that are letters (category L) |
|
29 // or numbers (category N) are considered valid characters. They are mapped to |
|
30 // lower case, and included in the output. All other runes are considered |
|
31 // invalid characters. Invalid characters that precede the first valid character, |
|
32 // as well as invalid character that follow the last valid character |
|
33 // are dropped completely. All other sequences of invalid characters |
|
34 // between two valid characters are replaced with a single dash character '-'. |
|
35 // |
|
36 // SanitizedAnchorName exposes this functionality, and can be used to |
|
37 // create compatible links to the anchor names generated by blackfriday. |
|
38 // This algorithm is also implemented in a small standalone package at |
|
39 // github.com/shurcooL/sanitized_anchor_name. It can be useful for clients |
|
40 // that want a small package and don't need full functionality of blackfriday. |
18 package blackfriday |
41 package blackfriday |
|
42 |
|
43 // NOTE: Keep Sanitized Anchor Name algorithm in sync with package |
|
44 // github.com/shurcooL/sanitized_anchor_name. |
|
45 // Otherwise, users of sanitized_anchor_name will get anchor names |
|
46 // that are incompatible with those generated by blackfriday. |