Update documentation for MD051/link-fragments to mention encodeURIComponent (refs #1858).

This commit is contained in:
David Anson 2025-11-16 15:36:12 -08:00
parent 4b948627aa
commit 846475f203
3 changed files with 27 additions and 12 deletions

View file

@ -86,11 +86,16 @@ This makes it easy to link directly to different sections within a document.
However, section links change if headings are renamed or removed. This rule However, section links change if headings are renamed or removed. This rule
helps identify broken section links within a document. helps identify broken section links within a document.
Section links are **not** part of the CommonMark specification. This rule Note: Section links are **not** part of the CommonMark specification; this rule
enforces the [GitHub heading algorithm][github-heading-algorithm] which is: enforces the [GitHub heading algorithm][github-heading-algorithm]:
convert heading to lowercase, remove punctuation, convert spaces to dashes,
append an incrementing integer as needed for uniqueness.
1. Convert text to lowercase
2. Remove punctuation characters
3. Convert spaces to dashes
4. Append an incrementing integer (as needed for uniqueness)
5. [URI-encode][encodeURIComponent] the result
[encodeURIComponent]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/encodeURIComponent
[github-section-links]: https://docs.github.com/en/get-started/writing-on-github/getting-started-with-writing-and-formatting-on-github/basic-writing-and-formatting-syntax#section-links [github-section-links]: https://docs.github.com/en/get-started/writing-on-github/getting-started-with-writing-and-formatting-on-github/basic-writing-and-formatting-syntax#section-links
[github-heading-algorithm]: https://github.com/gjtorikian/html-pipeline/blob/f13a1534cb650ba17af400d1acd3a22c28004c09/lib/html/pipeline/toc_filter.rb [github-heading-algorithm]: https://github.com/gjtorikian/html-pipeline/blob/f13a1534cb650ba17af400d1acd3a22c28004c09/lib/html/pipeline/toc_filter.rb
[github-linking-to-content]: https://docs.github.com/en/get-started/writing-on-github/working-with-advanced-formatting/creating-a-permanent-link-to-a-code-snippet#linking-to-markdown [github-linking-to-content]: https://docs.github.com/en/get-started/writing-on-github/working-with-advanced-formatting/creating-a-permanent-link-to-a-code-snippet#linking-to-markdown

View file

@ -2284,11 +2284,16 @@ This makes it easy to link directly to different sections within a document.
However, section links change if headings are renamed or removed. This rule However, section links change if headings are renamed or removed. This rule
helps identify broken section links within a document. helps identify broken section links within a document.
Section links are **not** part of the CommonMark specification. This rule Note: Section links are **not** part of the CommonMark specification; this rule
enforces the [GitHub heading algorithm][github-heading-algorithm] which is: enforces the [GitHub heading algorithm][github-heading-algorithm]:
convert heading to lowercase, remove punctuation, convert spaces to dashes,
append an incrementing integer as needed for uniqueness.
1. Convert text to lowercase
2. Remove punctuation characters
3. Convert spaces to dashes
4. Append an incrementing integer (as needed for uniqueness)
5. [URI-encode][encodeURIComponent] the result
[encodeURIComponent]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/encodeURIComponent
[github-section-links]: https://docs.github.com/en/get-started/writing-on-github/getting-started-with-writing-and-formatting-on-github/basic-writing-and-formatting-syntax#section-links [github-section-links]: https://docs.github.com/en/get-started/writing-on-github/getting-started-with-writing-and-formatting-on-github/basic-writing-and-formatting-syntax#section-links
[github-heading-algorithm]: https://github.com/gjtorikian/html-pipeline/blob/f13a1534cb650ba17af400d1acd3a22c28004c09/lib/html/pipeline/toc_filter.rb [github-heading-algorithm]: https://github.com/gjtorikian/html-pipeline/blob/f13a1534cb650ba17af400d1acd3a22c28004c09/lib/html/pipeline/toc_filter.rb
[github-linking-to-content]: https://docs.github.com/en/get-started/writing-on-github/working-with-advanced-formatting/creating-a-permanent-link-to-a-code-snippet#linking-to-markdown [github-linking-to-content]: https://docs.github.com/en/get-started/writing-on-github/working-with-advanced-formatting/creating-a-permanent-link-to-a-code-snippet#linking-to-markdown

View file

@ -100,11 +100,16 @@ This makes it easy to link directly to different sections within a document.
However, section links change if headings are renamed or removed. This rule However, section links change if headings are renamed or removed. This rule
helps identify broken section links within a document. helps identify broken section links within a document.
Section links are **not** part of the CommonMark specification. This rule Note: Section links are **not** part of the CommonMark specification; this rule
enforces the [GitHub heading algorithm][github-heading-algorithm] which is: enforces the [GitHub heading algorithm][github-heading-algorithm]:
convert heading to lowercase, remove punctuation, convert spaces to dashes,
append an incrementing integer as needed for uniqueness.
1. Convert text to lowercase
2. Remove punctuation characters
3. Convert spaces to dashes
4. Append an incrementing integer (as needed for uniqueness)
5. [URI-encode][encodeURIComponent] the result
[encodeURIComponent]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/encodeURIComponent
[github-section-links]: https://docs.github.com/en/get-started/writing-on-github/getting-started-with-writing-and-formatting-on-github/basic-writing-and-formatting-syntax#section-links [github-section-links]: https://docs.github.com/en/get-started/writing-on-github/getting-started-with-writing-and-formatting-on-github/basic-writing-and-formatting-syntax#section-links
[github-heading-algorithm]: https://github.com/gjtorikian/html-pipeline/blob/f13a1534cb650ba17af400d1acd3a22c28004c09/lib/html/pipeline/toc_filter.rb [github-heading-algorithm]: https://github.com/gjtorikian/html-pipeline/blob/f13a1534cb650ba17af400d1acd3a22c28004c09/lib/html/pipeline/toc_filter.rb
[github-linking-to-content]: https://docs.github.com/en/get-started/writing-on-github/working-with-advanced-formatting/creating-a-permanent-link-to-a-code-snippet#linking-to-markdown [github-linking-to-content]: https://docs.github.com/en/get-started/writing-on-github/working-with-advanced-formatting/creating-a-permanent-link-to-a-code-snippet#linking-to-markdown