-
Notifications
You must be signed in to change notification settings - Fork 597
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Document SanitizedAnchorName algorithm, copy implementation.
The goal of this change is to reduce number of non-standard library packages (repositories) that blackfriday imports from 1 to 0, and in turn, reduce the cost of importing blackfriday into other projects. Do so by documenting the algorithm of SanitizedAnchorName, and include a copy of the small function inside blackfriday itself. The same functionality continues to be available in the original location, github.com/shurcooL/sanitized_anchor_name.Create. It can be used by existing users and those that look for a small package, and don't need all of blackfriday functionality. Existing users of blackfriday can use the new SanitizedAnchorName function directly and avoid an extra package import. Resolves #350.
- Loading branch information
Showing
5 changed files
with
120 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
// Package blackfriday is a Markdown processor. | ||
// | ||
// It translates plain text with simple formatting rules into HTML or LaTeX. | ||
// | ||
// Sanitized Anchor Names | ||
// | ||
// Blackfriday includes an algorithm for creating sanitized anchor names | ||
// corresponding to a given input text. This algorithm is used to create | ||
// anchors for headings when EXTENSION_AUTO_HEADER_IDS is enabled. The | ||
// algorithm is specified below, so that other packages can create | ||
// compatible anchor names and links to those anchors. | ||
// | ||
// The algorithm iterates over the input text, interpreted as UTF-8, | ||
// one Unicode code point (rune) at a time. All runes that are letters (category L) | ||
// or numbers (category N) are considered valid characters. They are mapped to | ||
// lower case, and included in the output. All other runes are considered | ||
// invalid characters. Invalid characters that preceed the first valid character, | ||
// as well as invalid character that follow the last valid character | ||
// are dropped completely. All other sequences of invalid characters | ||
// between two valid characters are replaced with a single dash character '-'. | ||
// | ||
// SanitizedAnchorName exposes this functionality, and can be used to | ||
// create compatible links to the anchor names generated by blackfriday. | ||
// This algorithm is also implemented in a small standalone package at | ||
// github.com/shurcooL/sanitized_anchor_name. It can be useful for clients | ||
// that want a small package and don't need full functionality of blackfriday. | ||
package blackfriday | ||
|
||
// NOTE: Keep Sanitized Anchor Name algorithm in sync with package | ||
// github.com/shurcooL/sanitized_anchor_name. | ||
// Otherwise, users of sanitized_anchor_name will get anchor names | ||
// that are incompatible with those generated by blackfriday. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters