Skip to content

Commit 1318048

Browse files
committed
Allow trailing pipes to be ommitted
1 parent 993f253 commit 1318048

File tree

2 files changed

+21
-2
lines changed

2 files changed

+21
-2
lines changed

lib/rdoc/markdown.kpeg

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1201,12 +1201,12 @@ Table = &{ github? }
12011201
TableRow:header TableLine:line TableRow+:body
12021202
{ table = RDoc::Markup::Table.new(header, line, body) }
12031203

1204-
TableRow = TableItem+:row "|" @Newline
1204+
TableRow = TableItem+:row "|"? @Newline
12051205
{ row }
12061206
TableItem = "|" < (!"|" !@Newline .)+ >
12071207
{ text.strip }
12081208

1209-
TableLine = TableColumn+:line "|" @Newline
1209+
TableLine = TableColumn+:line "|"? @Newline
12101210
{ line }
12111211
TableColumn = "|" < ( "-"+ ":"? | ":" "-"* ) >
12121212
{ text.start_with?(":") ? :left :

test/rdoc/test_rdoc_markdown.rb

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1062,6 +1062,25 @@ def test_gfm_table
10621062
assert_equal expected, doc
10631063
end
10641064

1065+
def test_gfm_table_2
1066+
doc = parse <<~MD
1067+
| Cmd | Returns | Meaning
1068+
|-----|---------|--------
1069+
| "b" | boolean | True if file1 is a block device
1070+
| "c" | boolean | True if file1 is a character device
1071+
MD
1072+
1073+
head = %w[Cmd Returns Meaning]
1074+
align = [nil, nil, nil]
1075+
body = [
1076+
['"b"', 'boolean', 'True if file1 is a block device'],
1077+
['"c"', 'boolean', 'True if file1 is a character device'],
1078+
]
1079+
expected = doc(@RM::Table.new(head, align, body))
1080+
1081+
assert_equal expected, doc
1082+
end
1083+
10651084
def parse text
10661085
@parser.parse text
10671086
end

0 commit comments

Comments
 (0)