Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/rdoc/markdown.kpeg
Original file line number Diff line number Diff line change
Expand Up @@ -1253,7 +1253,7 @@ TableRow = ( ( TableItem:item1 TableItem2*:items { [item1, *items] } ):row | Tab
{ row }
TableItem2 = "|" TableItem
TableItem = < /(?:\\.|[^|\n])+/ >
{ text.strip.gsub(/\\(.)/, '\1') }
{ text.strip.gsub(/\\([|])/, '\1') }

TableLine = ( ( TableAlign:align1 TableAlign2*:aligns {[align1, *aligns] } ):line | TableAlign2+:line ) "|"? @Newline
{ line }
Expand Down
30 changes: 30 additions & 0 deletions test/rdoc/rdoc_markdown_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1157,6 +1157,36 @@ def test_gfm_table_with_links_and_code
assert_equal expected, doc
end

def test_gfm_table_with_backslashes_in_code_spans
doc = parse <<~MD
Plain text: `$\\\\` and `$\\\\ ` should work.

| Context | Code | Expected |
|---------|------|----------|
| Plain | `$\\\\` | Should show backslash |
| Escaped | `$\\\\ ` | Should show backslash |
| Multiple| `\\\\n\\\\t` | Should show backslashes |
MD

head = %w[Context Code Expected]
align = [nil, nil, nil]

body = [
['Plain', '<code>$\\\\</code>', 'Should show backslash'],
['Escaped', '<code>$\\\\</code>', 'Should show backslash'],
['Multiple', '<code>\\\\n\\\\t</code>', 'Should show backslashes'],
]

expected_table = @RM::Table.new(head, align, body)

expected = doc(
para('Plain text: <code>$\\\\</code> and <code>$\\\\</code> should work.'),
expected_table
)

assert_equal expected, doc
end

def parse(text)
@parser.parse text
end
Expand Down
Loading