Skip to content

Commit

Permalink
Allow trailing pipes to be ommitted
Browse files Browse the repository at this point in the history
  • Loading branch information
nobu committed Oct 6, 2022
1 parent 993f253 commit 1318048
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/rdoc/markdown.kpeg
Original file line number Diff line number Diff line change
Expand Up @@ -1201,12 +1201,12 @@ Table = &{ github? }
TableRow:header TableLine:line TableRow+:body
{ table = RDoc::Markup::Table.new(header, line, body) }

TableRow = TableItem+:row "|" @Newline
TableRow = TableItem+:row "|"? @Newline
{ row }
TableItem = "|" < (!"|" !@Newline .)+ >
{ text.strip }

TableLine = TableColumn+:line "|" @Newline
TableLine = TableColumn+:line "|"? @Newline
{ line }
TableColumn = "|" < ( "-"+ ":"? | ":" "-"* ) >
{ text.start_with?(":") ? :left :
Expand Down
19 changes: 19 additions & 0 deletions test/rdoc/test_rdoc_markdown.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1062,6 +1062,25 @@ def test_gfm_table
assert_equal expected, doc
end

def test_gfm_table_2
doc = parse <<~MD
| Cmd | Returns | Meaning
|-----|---------|--------
| "b" | boolean | True if file1 is a block device
| "c" | boolean | True if file1 is a character device
MD

head = %w[Cmd Returns Meaning]
align = [nil, nil, nil]
body = [
['"b"', 'boolean', 'True if file1 is a block device'],
['"c"', 'boolean', 'True if file1 is a character device'],
]
expected = doc(@RM::Table.new(head, align, body))

assert_equal expected, doc
end

def parse text
@parser.parse text
end
Expand Down

0 comments on commit 1318048

Please sign in to comment.