Skip to content

Commit

Permalink
Allow escaped pipes in cells
Browse files Browse the repository at this point in the history
  • Loading branch information
nobu committed Oct 6, 2022
1 parent 3b3a583 commit 333952a
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
4 changes: 2 additions & 2 deletions lib/rdoc/markdown.kpeg
Expand Up @@ -1207,8 +1207,8 @@ TableHead = TableItem2+:items "|"? @Newline
TableRow = ( ( TableItem:item1 TableItem2*:items { [item1, *items] } ):row | TableItem2+:row ) "|"? @Newline
{ row }
TableItem2 = "|" TableItem
TableItem = < (!"|" !@Newline .)+ >
{ text.strip }
TableItem = < /(?:\\.|[^|\n])+/ >
{ text.strip.gsub(/\\(.)/, '\1') }

TableLine = ( ( TableAlign:align1 TableAlign2*:aligns {[align1, *aligns] } ):line | TableAlign2+:line ) "|"? @Newline
{ line }
Expand Down
4 changes: 3 additions & 1 deletion test/rdoc/test_rdoc_markdown.rb
Expand Up @@ -1063,18 +1063,20 @@ def test_gfm_table
end

def test_gfm_table_2
doc = parse <<~MD
doc = parse <<~'MD'
| Cmd | Returns | Meaning
----- | ------- | -------
|"b" | boolean | True if file1 is a block device
"c" | boolean | True if file1 is a character device
|"\|" | boolean | escaped bar \| test
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'],
['"|"', 'boolean', 'escaped bar | test'],
]
expected = doc(@RM::Table.new(head, align, body))

Expand Down

0 comments on commit 333952a

Please sign in to comment.