-
Notifications
You must be signed in to change notification settings - Fork 447
Add comparison with GitHub Flavored Markdown spec #1550
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
st0012
wants to merge
1
commit into
master
Choose a base branch
from
add-gfm-comparison
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+104
−0
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -556,3 +556,107 @@ See [rdoc.rdoc](rdoc.rdoc) for complete directive documentation. | |
| 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 (RDoc also accepts 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 | ⚠️ `ruby`/`rb`/`c` | Limited syntax highlighting | | ||
| | Blockquotes | ✅ | ✅ | Full match, nested supported | | ||
| | Lazy Continuation | ✅ | ❌ | GFM allows omitting `>` on continuation lines | | ||
| | Bullet Lists | ✅ | ✅ | `*`, `+`, `-` supported | | ||
| | Ordered Lists | ✅ `.` `)` | ⚠️ `.` only | RDoc doesn't support `)` delimiter | | ||
| | 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 | | ||
| |------|-------------|:---:|:----:| | ||
| | 1 | `<script>`, `<pre>` | ✅ | ✅ | | ||
| | 1 | `<style>` | ✅ | ❌ | | ||
| | 2 | HTML comments `<!-- -->` | ✅ | ✅ | | ||
| | 3 | Processing instructions `<? ?>` | ✅ | ❌ | | ||
| | 4 | Declarations `<!DOCTYPE>` | ✅ | ❌ | | ||
| | 5 | CDATA `<![CDATA[ ]]>` | ✅ | ❌ | | ||
| | 6 | Block-level tags | ✅ | ⚠️ | | ||
| | 7 | Any complete open/close tag | ✅ | ❌ | | ||
|
|
||
| RDoc uses a whitelist of block-level tags defined in | ||
| [lib/rdoc/markdown.kpeg](https://github.com/ruby/rdoc/blob/master/lib/rdoc/markdown.kpeg) | ||
| (see `HtmlBlockInTags`). HTML5 semantic elements like `<article>`, `<section>`, | ||
| `<nav>`, `<header>`, `<footer>` are not supported. | ||
|
|
||
| ### Inline Elements | ||
|
|
||
| | Feature | GFM | RDoc | Notes | | ||
| |---------|:---:|:----:|-------| | ||
| | Emphasis `*text*` `_text_` | ✅ | ✅ | Full match | | ||
| | Strong `**text**` `__text__` | ✅ | ✅ | Full match | | ||
| | Combined `***text***` | ✅ | ✅ | Full match | | ||
| | Code spans | ✅ | ✅ | Multiple backticks supported | | ||
| | Inline links | ✅ | ✅ | Full match | | ||
| | Reference links | ✅ | ✅ | Full match | | ||
| | Link titles | ✅ | ⚠️ | Parsed but not rendered | | ||
| | Images | ✅ | ✅ | Full match | | ||
| | Autolinks `<url>` | ✅ | ✅ | Full match | | ||
| | Hard line breaks | ✅ | ✅ | 2+ trailing spaces | | ||
| | Backslash escapes | ✅ | ✅ | Full match | | ||
| | HTML entities | ✅ | ✅ | Named, decimal, hex | | ||
| | Inline HTML | ✅ | ✅ | Full match | | ||
|
|
||
| ### GFM Extensions | ||
|
|
||
| | Feature | GFM | RDoc | Notes | | ||
| |---------|:---:|:----:|-------| | ||
| | Strikethrough `~~text~~` | ✅ | ✅ | Full match | | ||
| | Task Lists `[ ]` `[x]` | ✅ | ❌ | Not supported | | ||
| | Extended Autolinks | ✅ | ❌ | See below | | ||
| | Disallowed Raw HTML | ✅ | ❌ | No security filtering | | ||
|
|
||
| #### GFM Extended Autolinks | ||
|
|
||
| GFM automatically converts certain text patterns into links without requiring | ||
| angle brackets (`<>`). RDoc requires the standard `<url>` syntax. | ||
|
|
||
| GFM recognizes these patterns as autolinks: | ||
|
|
||
| - `www.example.com` — text starting with `www.` followed by a valid domain | ||
| - `https://example.com` — URLs starting with `http://` or `https://` | ||
| - `[email protected]` — valid email addresses | ||
| - `mailto:[email protected]` — `mailto:` or `xmpp:` followed by an email | ||
|
|
||
| Example in GFM: | ||
|
|
||
| ```markdown | ||
| Visit www.example.com or contact [email protected] for help. | ||
| ``` | ||
|
|
||
| In GFM, both become clickable links. In RDoc, you must use: | ||
|
|
||
| ```markdown | ||
| Visit <https://www.example.com> or contact <[email protected]> for help. | ||
| ``` | ||
|
|
||
| ### RDoc-Specific Features (not in GFM) | ||
|
|
||
| - [Definition Lists](#definition-lists) | ||
| - [Footnotes](#footnotes) | ||
| - [Cross-references](#cross-references) | ||
| - [Anchor Links](#anchor-links) | ||
| - [Directives](#directives) | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
RDoc interprets
> foo baras
> foo bardue to howToHtmlhandles the newline.I'll try to fix the issue so it matches GFM.