Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ rdoc --markup markdown
| Cross-references | Automatic | Automatic |
| Directives (`:nodoc:`, etc.) | Supported | Supported |
| Tables | Not supported | Supported |
| Strikethrough | Not supported | Supported |
| Strikethrough | `<del>text</del>` | `~~text~~` |
| Footnotes | Not supported | Supported |

For complete syntax documentation, see:
Expand Down
2 changes: 1 addition & 1 deletion doc/markup_reference/markdown.md
Original file line number Diff line number Diff line change
Expand Up @@ -540,7 +540,7 @@ See [rdoc.rdoc](rdoc.rdoc) for complete directive documentation.
| Code blocks | Indent beyond margin | Indent 4 spaces or fence |
| Block quotes | `>>>` | `>` |
| Tables | Not supported | Supported |
| Strikethrough | Not supported | `~~text~~` |
| Strikethrough | `<del>text</del>` | `~~text~~` |
| Footnotes | Not supported | `[^1]` |

## Notes and Limitations
Expand Down
24 changes: 21 additions & 3 deletions doc/markup_reference/rdoc.rdoc
Original file line number Diff line number Diff line change
Expand Up @@ -664,20 +664,21 @@ For C code, the directive may appear in a stand-alone comment.

Text markup is metatext that affects HTML rendering:

- {Typeface}[rdoc-ref:rdoc@Typeface+Markup]: italic, bold, monofont.
- {Typeface}[rdoc-ref:rdoc@Typeface+Markup]: italic, bold, monofont, strikethrough.
- {Character conversions}[rdoc-ref:rdoc@Character+Conversions]: copyright, trademark, certain punctuation.
- {Links}[rdoc-ref:rdoc@Links].
- {Escapes}[rdoc-ref:rdoc@Escaping+Text]: marking text as "not markup."

=== Typeface Markup

Typeface markup can specify that text is to be rendered
as italic, bold, or monofont.
as italic, bold, monofont, or strikethrough.

Typeface markup may contain only one type of nested block:

- More typeface markup:
{italic}[rdoc-ref:rdoc@Italic], {bold}[rdoc-ref:rdoc@Bold], {monofont}[rdoc-ref:rdoc@Monofont].
{italic}[rdoc-ref:rdoc@Italic], {bold}[rdoc-ref:rdoc@Bold], {monofont}[rdoc-ref:rdoc@Monofont],
{strikethrough}[rdoc-ref:rdoc@Strikethrough].

==== Italic

Expand Down Expand Up @@ -766,6 +767,23 @@ Rendered HTML:
>>>
+Monofont+ in a paragraph.

==== Strikethrough

Text may be marked as strikethrough via HTML tag <tt><del></tt> or <tt><s></tt>.

Example input:

<del>Strikethrough words</del> in a paragraph.

<del>Deleted passage containing _italics_ and *bold*.</del>

Rendered HTML:

>>>
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

question: Is this is a leftover from merge conflict?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's RDoc's way to declare quote blocks.

<del>Strikethrough words</del> in a paragraph.

<del>Deleted passage containing _italics_ and *bold*.</del>

=== Character Conversions

Certain combinations of characters may be converted to special characters;
Expand Down
6 changes: 1 addition & 5 deletions lib/rdoc/markdown.kpeg
Original file line number Diff line number Diff line change
Expand Up @@ -490,11 +490,7 @@
# Wraps `text` in strike markup for rdoc inline formatting

def strike text
if text =~ /\A[a-z\d.\/-]+\z/i then
"~#{text}~"
else
"<s>#{text}</s>"
end
"<del>#{text}</del>"
end

##
Expand Down
6 changes: 1 addition & 5 deletions lib/rdoc/markdown.rb
Original file line number Diff line number Diff line change
Expand Up @@ -875,11 +875,7 @@ def strong text
# Wraps `text` in strike markup for rdoc inline formatting

def strike text
if text =~ /\A[a-z\d.\/-]+\z/i then
"~#{text}~"
else
"<s>#{text}</s>"
end
"<del>#{text}</del>"
end

##
Expand Down
4 changes: 3 additions & 1 deletion lib/rdoc/markup/attribute_manager.rb
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,6 @@ def initialize
add_word_pair "*", "*", :BOLD, true
add_word_pair "_", "_", :EM, true
add_word_pair "+", "+", :TT, true
add_word_pair "~", "~", :STRIKE, true

add_html "em", :EM, true
add_html "i", :EM, true
Expand Down Expand Up @@ -263,7 +262,10 @@ def protect_code_markup
@str.gsub!(/<(code|tt)>(.*?)<\/\1>/im) do
tag = $1
content = $2
# Protect word pair delimiters (*, _, +) from being processed
escaped = content.gsub(@unprotected_word_pair_regexp, "\\1#{PROTECT_ATTR}")
# Protect HTML-like tags from being processed (e.g., <del> inside code)
escaped = escaped.gsub(/<(?!#{PROTECT_ATTR})/, "<#{PROTECT_ATTR}")
"<#{tag}>#{escaped}</#{tag}>"
end
end
Expand Down
33 changes: 13 additions & 20 deletions test/rdoc/markup/attribute_manager_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -167,17 +167,6 @@ def test_bold_html_escaped
assert_equal ['cat <b>dog</b>'], @am.flow('cat \<b>dog</b>')
end

def test_strike
assert_equal [@strike_on, 'strike', @strike_off],
@am.flow("~strike~")

assert_equal [@strike_on, 'Strike:', @strike_off],
@am.flow("~Strike:~")

assert_equal ["cat ", @strike_on, "and", @strike_off, " dog"],
@am.flow("cat ~and~ dog")
end

def test_strike_html_escaped
assert_equal ['cat <s>dog</s>'], @am.flow('cat \<s>dog</s>')
assert_equal ['cat <del>dog</del>'], @am.flow('cat \<del>dog</del>')
Expand All @@ -193,14 +182,6 @@ def test_html_like_strike_del
@am.flow("cat <del>dog</del>")
end

def test_convert_attrs_ignores_strike_inside_code
assert_equal 'foo <CODE>~strike~</CODE> bar', output('foo <code>~strike~</code> bar')
end

def test_convert_attrs_ignores_strike_inside_tt
assert_equal 'foo <CODE>~strike~</CODE> bar', output('foo <tt>~strike~</tt> bar')
end

def test_combined
assert_equal(["cat ", @em_on, "and", @em_off, " ", @bold_on, "dog", @bold_off],
@am.flow("cat _and_ *dog*"))
Expand Down Expand Up @@ -263,6 +244,18 @@ def test_convert_attrs_ignores_tt_inside_tt
assert_equal 'foo <CODE>+tt+</CODE> bar', output('foo <tt>+tt+</tt> bar')
end

def test_convert_attrs_ignores_del_inside_code
assert_equal 'foo <CODE><del>strike</del></CODE> bar', output('foo <code><del>strike</del></code> bar')
end

def test_convert_attrs_ignores_del_inside_tt
assert_equal 'foo <CODE><del>strike</del></CODE> bar', output('foo <tt><del>strike</del></tt> bar')
end

def test_convert_attrs_ignores_s_inside_code
assert_equal 'foo <CODE><s>strike</s></CODE> bar', output('foo <code><s>strike</s></code> bar')
end

def test_convert_attrs_ignores_tt
assert_equal 'foo <CODE>__send__</CODE> bar', output('foo <tt>__send__</tt> bar')
end
Expand Down Expand Up @@ -374,7 +367,7 @@ def test_initial_html
def test_initial_word_pairs
word_pairs = @am.matching_word_pairs
assert word_pairs.is_a?(Hash)
assert_equal(4, word_pairs.size)
assert_equal(3, word_pairs.size)
end

def test_mask_protected_sequence
Expand Down
4 changes: 2 additions & 2 deletions test/rdoc/rdoc_markdown_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1089,7 +1089,7 @@ def test_parse_strike_tilde
doc = parse "it ~~works~~\n"

expected = @RM::Document.new(
@RM::Paragraph.new("it ~works~"))
@RM::Paragraph.new("it <del>works</del>"))

assert_equal expected, doc
end
Expand All @@ -1098,7 +1098,7 @@ def test_parse_strike_words_tilde
doc = parse "it ~~works fine~~\n"

expected = @RM::Document.new(
@RM::Paragraph.new("it <s>works fine</s>"))
@RM::Paragraph.new("it <del>works fine</del>"))

assert_equal expected, doc
end
Expand Down
Loading