From 720b5531b788588d905513bdfb30bc2dcfc4282d Mon Sep 17 00:00:00 2001 From: Stan Lo Date: Mon, 5 Jan 2026 23:26:42 +0000 Subject: [PATCH] Add comparison with GitHub Flavored Markdown spec --- doc/markup_reference/markdown.md | 107 ++++++++++++++++++++++++++++++- test/rdoc/rdoc_markdown_test.rb | 81 +++++++++++++++++++++++ 2 files changed, 185 insertions(+), 3 deletions(-) diff --git a/doc/markup_reference/markdown.md b/doc/markup_reference/markdown.md index 7550cefe09..50ae573410 100644 --- a/doc/markup_reference/markdown.md +++ b/doc/markup_reference/markdown.md @@ -98,7 +98,9 @@ Use triple backticks with an optional language identifier: end ``` -Supported language for syntax highlighting: `ruby`, `rb` (alias to `ruby`), and `c`. +Supported languages for syntax highlighting: `ruby` (and `rb` alias) with server-side +highlighting, and `c`, `bash`/`sh`/`shell`/`console` with client-side JavaScript highlighting. +Other info strings are accepted and added as a CSS class but receive no highlighting. ### Blockquotes @@ -420,6 +422,9 @@ For example: * [Link to Blockquotes](#blockquotes) * [Link to Anchor Links](#anchor-links) +When multiple headings produce the same anchor, RDoc appends `-1`, `-2`, etc. +to subsequent duplicates, matching GitHub's behavior. + ## Footnotes ### Reference Footnotes @@ -535,7 +540,7 @@ See [rdoc.rdoc](rdoc.rdoc) for complete directive documentation. | Headings | `= Heading` | `# Heading` | | Bold | `*word*` | `**word**` | | Italic | `_word_` | `*word*` | -| Monospace | `+word+` | `` `word` `` | +| Monospace | `+word+` or `` `word` `` | `` `word` `` | | Links | `{text}[url]` | `[text](url)` | | Code blocks | Indent beyond margin | Indent 4 spaces or fence | | Block quotes | `>>>` | `>` | @@ -551,8 +556,104 @@ See [rdoc.rdoc](rdoc.rdoc) for complete directive documentation. 3. **Footnotes are collapsed** - Multiple paragraphs in a footnote become a single paragraph. -4. **Syntax highlighting** - Only `ruby` and `c` are supported for fenced code blocks. +4. **Syntax highlighting** - Only `ruby`/`rb` (server-side) and `c`, `bash`/`sh`/`shell`/`console` (client-side) receive syntax highlighting. Other info strings are accepted but not highlighted. 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. 6. **Auto-linking** - RDoc automatically links class and method names in output, even without explicit link syntax. + +## Comparison with GitHub Flavored Markdown (GFM) + +This section compares RDoc's Markdown implementation with the +[GitHub Flavored Markdown Spec](https://github.github.com/gfm/) (Version 0.29-gfm, 2019-04-06). + +### Block Elements + +| Feature | GFM | RDoc | Notes | +|---------|:---:|:----:|-------| +| ATX Headings (`#`) | ✅ | ✅ | Both support levels 1-6, optional closing `#` | +| Setext Headings | ✅ | ✅ | `=` for H1, `-` for H2 | +| Paragraphs | ✅ | ✅ | Full match | +| Indented Code Blocks | ✅ | ✅ | 4 spaces or 1 tab | +| Fenced Code (backticks) | ✅ 3+ | ⚠️ 3 only | RDoc doesn't support 4+ backticks for nesting | +| Fenced Code (tildes) | ✅ `~~~` | ❌ | Conflicts with strikethrough syntax | +| Info strings (language) | ✅ any | ⚠️ limited | `ruby`/`rb`, `c`, and `bash`/`sh`/`shell`/`console` highlighted; others accepted as CSS class | +| Blockquotes | ✅ | ✅ | Full match, nested supported | +| Lazy Continuation | ✅ | ⚠️ | Continuation text is included in blockquote but line break is lost (becomes a space) | +| Bullet Lists | ✅ | ✅ | `*`, `+`, `-` supported | +| Ordered Lists | ✅ `.` `)` | ⚠️ `.` only | RDoc doesn't support `)` delimiter; numbers are always renumbered from 1 | +| Nested Lists | ✅ | ✅ | 4-space indentation | +| Tables | ✅ | ✅ | Full alignment support | +| Thematic Breaks | ✅ | ✅ | `---`, `***`, `___` | +| HTML Blocks | ✅ 7 types | ⚠️ | See below | + +#### HTML Blocks + +GFM defines 7 types of HTML blocks: + +| Type | Description | GFM | RDoc | Notes | +|------|-------------|:---:|:----:|-------| +| 1 | `