Skip to content

Commit a968c09

Browse files
committed
Add comparison with GitHub Flavored Markdown spec
1 parent 0602d13 commit a968c09

1 file changed

Lines changed: 104 additions & 0 deletions

File tree

doc/markup_reference/markdown.md

Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -556,3 +556,107 @@ See [rdoc.rdoc](rdoc.rdoc) for complete directive documentation.
556556
5. **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.
557557

558558
6. **Auto-linking** - RDoc automatically links class and method names in output, even without explicit link syntax.
559+
560+
## Comparison with GitHub Flavored Markdown (GFM)
561+
562+
This section compares RDoc's Markdown implementation with the
563+
[GitHub Flavored Markdown Spec](https://github.github.com/gfm/) (Version 0.29-gfm, 2019-04-06).
564+
565+
### Block Elements
566+
567+
| Feature | GFM | RDoc | Notes |
568+
|---------|:---:|:----:|-------|
569+
| ATX Headings (`#`) ||| Both support levels 1-6, optional closing `#` |
570+
| Setext Headings ||| `=` for H1, `-` for H2 |
571+
| Paragraphs ||| Full match |
572+
| Indented Code Blocks ||| 4 spaces (RDoc also accepts 1 tab) |
573+
| Fenced Code (backticks) | ✅ 3+ | ⚠️ 3 only | RDoc doesn't support 4+ backticks for nesting |
574+
| Fenced Code (tildes) |`~~~` || Conflicts with strikethrough syntax |
575+
| Info strings (language) | ✅ any | ⚠️ `ruby`/`rb`/`c` | Limited syntax highlighting |
576+
| Blockquotes ||| Full match, nested supported |
577+
| Lazy Continuation ||| GFM allows omitting `>` on continuation lines |
578+
| Bullet Lists ||| `*`, `+`, `-` supported |
579+
| Ordered Lists |`.` `)` | ⚠️ `.` only | RDoc doesn't support `)` delimiter |
580+
| Nested Lists ||| 4-space indentation |
581+
| Tables ||| Full alignment support |
582+
| Thematic Breaks ||| `---`, `***`, `___` |
583+
| HTML Blocks | ✅ 7 types | ⚠️ | See below |
584+
585+
#### HTML Blocks
586+
587+
GFM defines 7 types of HTML blocks:
588+
589+
| Type | Description | GFM | RDoc |
590+
|------|-------------|:---:|:----:|
591+
| 1 | `<script>`, `<pre>` |||
592+
| 1 | `<style>` |||
593+
| 2 | HTML comments `<!-- -->` |||
594+
| 3 | Processing instructions `<? ?>` |||
595+
| 4 | Declarations `<!DOCTYPE>` |||
596+
| 5 | CDATA `<![CDATA[ ]]>` |||
597+
| 6 | Block-level tags || ⚠️ |
598+
| 7 | Any complete open/close tag |||
599+
600+
RDoc uses a whitelist of block-level tags defined in
601+
[lib/rdoc/markdown.kpeg](https://github.com/ruby/rdoc/blob/master/lib/rdoc/markdown.kpeg)
602+
(see `HtmlBlockInTags`). HTML5 semantic elements like `<article>`, `<section>`,
603+
`<nav>`, `<header>`, `<footer>` are not supported.
604+
605+
### Inline Elements
606+
607+
| Feature | GFM | RDoc | Notes |
608+
|---------|:---:|:----:|-------|
609+
| Emphasis `*text*` `_text_` ||| Full match |
610+
| Strong `**text**` `__text__` ||| Full match |
611+
| Combined `***text***` ||| Full match |
612+
| Code spans ||| Multiple backticks supported |
613+
| Inline links ||| Full match |
614+
| Reference links ||| Full match |
615+
| Link titles || ⚠️ | Parsed but not rendered |
616+
| Images ||| Full match |
617+
| Autolinks `<url>` ||| Full match |
618+
| Hard line breaks ||| 2+ trailing spaces |
619+
| Backslash escapes ||| Full match |
620+
| HTML entities ||| Named, decimal, hex |
621+
| Inline HTML ||| Full match |
622+
623+
### GFM Extensions
624+
625+
| Feature | GFM | RDoc | Notes |
626+
|---------|:---:|:----:|-------|
627+
| Strikethrough `~~text~~` ||| Full match |
628+
| Task Lists `[ ]` `[x]` ||| Not supported |
629+
| Extended Autolinks ||| See below |
630+
| Disallowed Raw HTML ||| No security filtering |
631+
632+
#### GFM Extended Autolinks
633+
634+
GFM automatically converts certain text patterns into links without requiring
635+
angle brackets (`<>`). RDoc requires the standard `<url>` syntax.
636+
637+
GFM recognizes these patterns as autolinks:
638+
639+
- `www.example.com` — text starting with `www.` followed by a valid domain
640+
- `https://example.com` — URLs starting with `http://` or `https://`
641+
- `user@example.com` — valid email addresses
642+
- `mailto:user@example.com``mailto:` or `xmpp:` followed by an email
643+
644+
Example in GFM:
645+
646+
```markdown
647+
Visit www.example.com or contact support@example.com for help.
648+
```
649+
650+
In GFM, both become clickable links. In RDoc, you must use:
651+
652+
```markdown
653+
Visit <https://www.example.com> or contact <support@example.com> for help.
654+
```
655+
656+
### RDoc-Specific Features (not in GFM)
657+
658+
- [Definition Lists](#definition-lists)
659+
- [Footnotes](#footnotes)
660+
- [Cross-references](#cross-references)
661+
- [Anchor Links](#anchor-links)
662+
- [Directives](#directives)

0 commit comments

Comments
 (0)