This document is the comprehensive reference for Markdown support in RDoc. It covers all syntax, extensions, and formatting options available.
For Ruby-specific features that require actual code (like cross-reference targets and directives that only work in Ruby comments), see RDoc::Example.
- Examples show Markdown syntax.
- Rendered output is shown in blockquotes where helpful.
Markdown documents consist of various block types:
- Paragraphs: ordinary text blocks.
- Headings: section titles.
- Code Blocks: verbatim text with syntax highlighting.
- Blockquotes: quoted passages.
- Lists: bullet, numbered, and definition lists.
- Tables: tabular data.
- Horizontal Rules: visual separators.
A paragraph is one or more consecutive lines of text, separated from other blocks by blank lines.
Example:
This is the first paragraph. It can span
multiple lines.
This is the second paragraph.Single newlines within a paragraph become spaces in the output.
Use # characters at the start of a line. Levels 1-6 are supported:
# Heading Level 1
## Heading Level 2
### Heading Level 3
#### Heading Level 4
##### Heading Level 5
###### Heading Level 6Optional closing # characters are allowed:
## Heading ##Underline text with = for level 1 or - for level 2:
Heading Level 1
===============
Heading Level 2
---------------Indent code by 4 spaces or 1 tab:
This is a paragraph.
def hello
puts "world"
end
This is another paragraph.Use triple backticks with an optional language identifier:
```ruby
def hello
puts "world"
end
```
Supported language for syntax highlighting: ruby, rb (alias to ruby), and c.
Prefix lines with >:
> This is a blockquote.
> It can span multiple lines.
>
> Multiple paragraphs are supported.Blockquotes can contain other elements:
> ## Heading inside blockquote
>
> - List item 1
> - List item 2
>
> Code inside blockquote:
>
> def example
> :ok
> endNested blockquotes:
> Outer quote
>
> > Nested quoteUse *, +, or - followed by a space:
* Item 1
* Item 2
* Item 3Or:
- Item 1
- Item 2
- Item 3Use digits followed by . and a space:
1. First item
2. Second item
3. Third itemThe actual numbers don't matter; they're renumbered in output:
1. First
1. Second
1. ThirdIndent with 4 spaces to nest:
* Item 1
* Nested item A
* Nested item B
* Item 2
1. Numbered nested
2. Also numberedUse a term on one line, then : followed by the definition:
term
: Definition of the term.
cat
: A small furry mammal.
ant
: A little insect.Multiple definitions for one term:
apple
: A fruit
: A technology companyCreate tables with pipes and dashes:
| Column 1 | Column 2 | Column 3 |
|----------|----------|----------|
| Cell 1 | Cell 2 | Cell 3 |
| Cell 4 | Cell 5 | Cell 6 |Use colons to specify alignment:
| Left | Center | Right |
|:---------|:--------:|---------:|
| Left | Center | Right |
| aligned | aligned | aligned |:---or---for left alignment (default):---:for center alignment---:for right alignment
Tables support inline formatting in cells:
| Feature | Syntax |
|-------------|-----------------|
| **Bold** | `**text**` |
| *Italic* | `*text*` |
| `Code` | `` `text` `` |Use three or more -, *, or _ on a line by themselves:
---
* * *
___Inline text can be formatted with various markup:
- Italic: emphasized text.
- Bold: strong emphasis.
- Bold and Italic: combined emphasis.
- Strikethrough: deleted text.
- Inline Code: monospace text.
Use single asterisks or underscores:
This is *italic* text.
This is _also italic_ text.This is italic text. This is also italic text.
Note: Underscores within words are not interpreted as emphasis:
foo_bar_baz remains plain textUse double asterisks or underscores:
This is **bold** text.
This is __also bold__ text.This is bold text. This is also bold text.
Use triple asterisks or underscores:
This is ***bold and italic*** text.
This is ___also bold and italic___ text.This is bold and italic text. This is also bold and italic text.
Use double tildes:
This is ~~strikethrough~~ text.This is
strikethroughtext.
Use backticks:
Use the `puts` method.Use the
putsmethod.
For code containing backticks, use multiple backticks:
Use `` `backticks` `` in code.Use
`backticks`in code.
[Link text](https://example.com)With optional title (title is parsed but not used in RDoc output):
[Link text](https://example.com "Title")Define a reference, then use it:
[Link text][ref]
[ref]: https://example.comImplicit reference (link text matches reference):
[Example][]
[Example]: https://example.comURLs and emails in angle brackets become links:
<https://example.com>
<user@example.com>Link to RDoc-documented classes, modules, and methods:
[RDoc module](rdoc-ref:RDoc)
[Options class](rdoc-ref:RDoc::Options)
[document method](rdoc-ref:RDoc::RDoc#document)See rdoc.rdoc for complete cross-reference documentation.
Basic image syntax:
Image as a link:
[](https://example.com)RDoc supports GitHub-style anchor links. You can link to any heading using its anchor, which is the heading text converted to lowercase with spaces replaced by hyphens and special characters removed.
For example:
Add a footnote reference in text, then define it:
Here is some text[^1] with a footnote[^note].
[^1]: This is the first footnote.
[^note]: This is another footnote.Create footnotes inline:
Here is text ^[with an inline footnote].Footnotes are collected and rendered at the bottom of the section, separated by a horizontal rule.
Raw HTML blocks are preserved:
<div class="note">
<p>This is HTML content.</p>
</div>Supported block-level tags include: <address>, <blockquote>, <div>,
<fieldset>, <form>, <h1>-<h6>, <ol>, <p>, <pre>, <table>, <ul>.
Inline HTML is also preserved:
This has <b>bold</b> and <em>emphasized</em> HTML.Use backslash to escape special characters:
\*not italic\*
\`not code\`
\[not a link\]
\# not a headingEscapable characters: ` \ : | * _ { } [ ] ( ) # + . ! > < -
Named, decimal, and hexadecimal entities are supported:
© — π
A AEnd a line with two or more spaces for a hard line break:
Line one
Line twoRDoc directives work in Markdown files within Ruby comments.
Use the :markup: markdown directive to specify Markdown format.
# :markup: markdown
# This class uses **Markdown** for documentation.
#
# ## Features
#
# - Bold with `**text**`
# - Italic with `*text*`
class MyClass
endCommon directives (same as RDoc markup):
:nodoc:- Suppress documentation:doc:- Force documentation:stopdoc:/:startdoc:- Start/stop documentation parsing:call-seq:- Custom calling sequence:section:- Create documentation sections
See rdoc.rdoc for complete directive documentation.
| Feature | RDoc Markup | Markdown |
|---|---|---|
| Headings | = Heading |
# Heading |
| Bold | *word* |
**word** |
| Italic | _word_ |
*word* |
| Monospace | +word+ |
`word` |
| Links | {text}[url] |
[text](url) |
| Code blocks | Indent beyond margin | Indent 4 spaces or fence |
| Block quotes | >>> |
> |
| Tables | Not supported | Supported |
| Strikethrough | <del>text</del> |
~~text~~ |
| Footnotes | Not supported | [^1] |
-
Link titles are parsed but not used - The title in
[text](url "title")is ignored. -
Underscores in words -
foo_baris never italicized; emphasis requires whitespace boundaries. -
Footnotes are collapsed - Multiple paragraphs in a footnote become a single paragraph.
-
Syntax highlighting - Only
rubyandcare supported for fenced code blocks. -
Fenced code blocks - Only triple backticks are supported. Tilde fences (
~~~) are not supported as they conflict with strikethrough syntax. Four or more backticks for nesting are also not supported. -
Auto-linking - RDoc automatically links class and method names in output, even without explicit link syntax.