Skip to content

Commit 333952a

Browse files
committed
Allow escaped pipes in cells
1 parent 3b3a583 commit 333952a

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

lib/rdoc/markdown.kpeg

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1207,8 +1207,8 @@ TableHead = TableItem2+:items "|"? @Newline
12071207
TableRow = ( ( TableItem:item1 TableItem2*:items { [item1, *items] } ):row | TableItem2+:row ) "|"? @Newline
12081208
{ row }
12091209
TableItem2 = "|" TableItem
1210-
TableItem = < (!"|" !@Newline .)+ >
1211-
{ text.strip }
1210+
TableItem = < /(?:\\.|[^|\n])+/ >
1211+
{ text.strip.gsub(/\\(.)/, '\1') }
12121212

12131213
TableLine = ( ( TableAlign:align1 TableAlign2*:aligns {[align1, *aligns] } ):line | TableAlign2+:line ) "|"? @Newline
12141214
{ line }

test/rdoc/test_rdoc_markdown.rb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1063,18 +1063,20 @@ def test_gfm_table
10631063
end
10641064

10651065
def test_gfm_table_2
1066-
doc = parse <<~MD
1066+
doc = parse <<~'MD'
10671067
| Cmd | Returns | Meaning
10681068
----- | ------- | -------
10691069
|"b" | boolean | True if file1 is a block device
10701070
"c" | boolean | True if file1 is a character device
1071+
|"\|" | boolean | escaped bar \| test
10711072
MD
10721073

10731074
head = %w[Cmd Returns Meaning]
10741075
align = [nil, nil, nil]
10751076
body = [
10761077
['"b"', 'boolean', 'True if file1 is a block device'],
10771078
['"c"', 'boolean', 'True if file1 is a character device'],
1079+
['"|"', 'boolean', 'escaped bar | test'],
10781080
]
10791081
expected = doc(@RM::Table.new(head, align, body))
10801082

0 commit comments

Comments
 (0)