Skip to content

Commit 12972ed

Browse files
committed
Update documentation
1 parent 8243db8 commit 12972ed

File tree

3 files changed

+40
-9
lines changed

3 files changed

+40
-9
lines changed

ExampleMarkdown.md

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,18 @@ For the following styles, see ExampleRDoc.rdoc for style examples:
1414

1515
These items all use the same styles as RDoc format files.
1616

17+
## Anchor Links
18+
19+
RDoc supports GitHub-style anchor links. You can link to any heading using its
20+
anchor, which is the heading text converted to lowercase with spaces replaced
21+
by hyphens and special characters removed.
22+
23+
For example:
24+
25+
* [Link to Footnotes](#footnotes)
26+
* [Link to Blockquotes](#blockquotes)
27+
* [Link to Anchor Links](#anchor-links)
28+
1729
## Footnotes
1830

1931
Footnotes are rendered at the bottom of the documentation section[^1]. For
@@ -36,4 +48,3 @@ Here is how a blockquote looks.
3648
> > 75 years?
3749
3850
This text is from [Riker Ipsum](http://rikeripsum.com)
39-

ExampleRDoc.rdoc

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,18 @@
33
This document contains example output to show RDoc styling. This file was
44
created from a RDoc Markup file.
55

6+
== Anchor Links
7+
8+
RDoc generates GitHub-style anchors for headings. The anchor is the heading
9+
text converted to lowercase with spaces replaced by hyphens and special
10+
characters removed.
11+
12+
You can link to headings using Markdown-style syntax:
13+
14+
- {Link to Headings}[#headings]
15+
- {Link to Paragraphs}[#paragraphs]
16+
- {Link to Verbatim sections}[#verbatim-sections]
17+
618
== Headings
719

820
You should not use headings beyond level 3, it is a sign of poor organization

doc/rdoc/markup_reference.rb

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -957,22 +957,30 @@
957957
#
958958
# [Heading]
959959
#
960-
# - Link: <tt>RDoc::RD@LICENSE</tt> links to RDoc::RDoc::RD@LICENSE.
960+
# Headings generate GitHub-style anchors: lowercase, spaces as hyphens,
961+
# special characters removed. For example, <tt>== Hello World</tt> generates
962+
# anchor <tt>hello-world</tt>.
961963
#
962-
# Note that spaces in the actual heading are represented by <tt>+</tt> characters
963-
# in the linkable text.
964+
# Link to headings are recommended to use the GitHub-style anchor format:
964965
#
965-
# - Link: <tt>RDoc::Options@Saved+Options</tt>
966-
# links to RDoc::Options@Saved+Options.
966+
# - <tt>RDoc::Options@saved-options</tt> links to RDoc::Options@saved-options.
967+
# - <tt>RDoc::RD@license</tt> links to RDoc::RD@license.
967968
#
968-
# Punctuation and other special characters must be escaped like CGI.escape.
969+
# To link to headings on the same page, you can also use Markdown-style anchor links:
970+
#
971+
# - <tt>{link text}[#hello-world]</tt> links to the heading <tt>== Hello World</tt>.
972+
# - <tt>{link text}[#saved-options]</tt> links to the heading <tt>== Saved Options</tt>.
973+
#
974+
# The legacy format with <tt>+</tt> for spaces is also supported, but not recommended:
975+
#
976+
# - <tt>RDoc::Options@Saved+Options</tt> links to RDoc::Options@Saved+Options.
969977
#
970978
# Pro tip: The link to any heading is available in the alphabetical table of contents
971-
# at the top left of the page for the class or module.
979+
# at the right sidebar of the page.
972980
#
973981
# [Section]
974982
#
975-
# See {Directives for Organizing Documentation}[#class-RDoc::MarkupReference-label-Directives+for+Organizing+Documentation].
983+
# See {Directives for Organizing Documentation}[#class-rdoc-markupreference-directives-for-organizing-documentation].
976984
#
977985
# - Link: <tt>RDoc::Markup::ToHtml@Visitor</tt> links to RDoc::Markup::ToHtml@Visitor.
978986
#

0 commit comments

Comments
 (0)