ruby/lib/rdoc/markup
Hartley McGuire 4756eaf5aa [ruby/rdoc] Fix ToMarkdown missing newlines for label-lists
Previously, using ToMarkdown on a label-list would generate output that
could not be reparsed by the RDoc::Markdown parser:

```
md = <<~MD
apple
: a red fruit

banana
: a yellow fruit
MD

doc = RDoc::Markdown.parse(md)
doc # => [doc: [list: NOTE [item: ["apple"]; [para: "a red fruit"]], [item: ["banana"]; [para: "a yellow fruit"]]]]

new_md = doc.accept(RDoc::Markup::ToMarkdown.new)
new_md # => "apple\n:   a red fruit\nbanana\n:   a yellow fruit\n\n"

new_doc = RDoc::Markdown.parse(new_md)
new_doc # => [doc: [list: NOTE [item: ["apple"]; [para: "a red fruit\nbanana\n: a yellow fruit"]]]]
```

The issue is that the [PHP Markdown Extra spec][1] requires a newline
after each definition list item, but ToMarkdown was not putting newlines
between label-list items.

This commit fixes the issue by properly appending a newline after each
label-list item so that the output of ToMarkdown can be reparsed by
RDoc::Markdown:

```
md = <<~MD
apple
: a red fruit

banana
: a yellow fruit
MD

doc = RDoc::Markdown.parse(mdoc)
doc # => [doc: [list: NOTE [item: ["apple"]; [para: "a red fruit"]], [item: ["banana"]; [para: "a yellow fruit"]]]]

new_md = doc.accept(RDoc::Markup::ToMarkdown.new)
new_md # => "apple\n:   a red fruit\n\nbanana\n:   a yellow fruit\n\n"

new_doc = RDoc::Markdown.parse(new_md)
new_doc # => [doc: [list: NOTE [item: ["apple"]; [para: "a red fruit"]], [item: ["banana"]; [para: "a yellow fruit"]]]]
```

[1]: https://michelf.ca/projects/php-markdown/extra/#def-list

c65266437c
2024-03-08 10:13:04 +00:00
..
attr_changer.rb
attr_span.rb
attribute_manager.rb [ruby/rdoc] [DOC] nodoc for probably internal methods 2023-12-16 00:26:39 +09:00
attributes.rb
blank_line.rb
block_quote.rb
document.rb
formatter.rb [ruby/rdoc] Fix TIDYLINK after braces 2023-11-14 07:59:56 +00:00
hard_break.rb
heading.rb
include.rb
indented_paragraph.rb
list.rb
list_item.rb
paragraph.rb
parser.rb [ruby/rdoc] [DOC] nodoc for probably internal methods 2023-12-16 00:26:39 +09:00
pre_process.rb
raw.rb
regexp_handling.rb
rule.rb
table.rb [ruby/rdoc] [DOC] nodoc for probably internal methods 2023-12-16 00:26:39 +09:00
to_ansi.rb
to_bs.rb
to_html.rb [ruby/rdoc] [DOC] nodoc for probably internal methods 2023-12-16 00:26:39 +09:00
to_html_crossref.rb [ruby/rdoc] Allow empty name rdoc-ref as a local link 2023-12-31 15:19:50 +00:00
to_html_snippet.rb [ruby/rdoc] [DOC] Add missing documents 2023-12-16 00:26:37 +09:00
to_joined_paragraph.rb [ruby/rdoc] Use flat_map for better performance 2023-06-14 23:47:25 +00:00
to_label.rb
to_markdown.rb [ruby/rdoc] Fix ToMarkdown missing newlines for label-lists 2024-03-08 10:13:04 +00:00
to_rdoc.rb
to_table_of_contents.rb
to_test.rb
to_tt_only.rb
verbatim.rb