Skip to content

Commit d263a2c

Browse files
committed
Allow leading pipes to be ommitted
1 parent 1318048 commit d263a2c

File tree

2 files changed

+15
-10
lines changed

2 files changed

+15
-10
lines changed

lib/rdoc/markdown.kpeg

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1198,17 +1198,22 @@ CodeFence = &{ github? }
11981198
}
11991199

12001200
Table = &{ github? }
1201-
TableRow:header TableLine:line TableRow+:body
1201+
TableHead:header TableLine:line TableRow+:body
12021202
{ table = RDoc::Markup::Table.new(header, line, body) }
12031203

1204-
TableRow = TableItem+:row "|"? @Newline
1205-
{ row }
1206-
TableItem = "|" < (!"|" !@Newline .)+ >
1204+
TableHead = TableItem2+:items "|"? @Newline
1205+
{ items }
1206+
1207+
TableRow = ( ( TableItem:item1 TableItem2*:items { [item1, *items] } ):row | TableItem2+:row ) "|"? @Newline
1208+
{ row }
1209+
TableItem2 = "|" TableItem
1210+
TableItem = < (!"|" !@Newline .)+ >
12071211
{ text.strip }
12081212

1209-
TableLine = TableColumn+:line "|"? @Newline
1210-
{ line }
1211-
TableColumn = "|" < ( "-"+ ":"? | ":" "-"* ) >
1213+
TableLine = ( ( TableAlign:align1 TableAlign2*:aligns {[align1, *aligns] } ):line | TableAlign2+:line ) "|"? @Newline
1214+
{ line }
1215+
TableAlign2 = "|" TableAlign
1216+
TableAlign = < /:?-+:?/ >
12121217
{ text.start_with?(":") ? :left :
12131218
text.end_with?(":") ? :right : nil
12141219
}

test/rdoc/test_rdoc_markdown.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1065,9 +1065,9 @@ def test_gfm_table
10651065
def test_gfm_table_2
10661066
doc = parse <<~MD
10671067
| Cmd | Returns | Meaning
1068-
|-----|---------|--------
1069-
| "b" | boolean | True if file1 is a block device
1070-
| "c" | boolean | True if file1 is a character device
1068+
------|---------|--------
1069+
|"b" | boolean | True if file1 is a block device
1070+
"c" | boolean | True if file1 is a character device
10711071
MD
10721072

10731073
head = %w[Cmd Returns Meaning]

0 commit comments

Comments
 (0)