@@ -1157,6 +1157,42 @@ def test_gfm_table_with_links_and_code
11571157 assert_equal expected , doc
11581158 end
11591159
1160+ def test_gfm_table_with_backslashes_in_code_spans
1161+ # Test case for GitHub issue #1395
1162+ # Backslashes in code spans should be rendered consistently
1163+ # between plain text and table cells
1164+ doc = parse <<~MD
1165+ Plain text: `$\\ \\ ` and `$\\ \\ ` should work.
1166+
1167+ | Context | Code | Expected |
1168+ |---------|------|----------|
1169+ | Plain | `$\\ \\ ` | Should show backslash |
1170+ | Escaped | `$\\ \\ ` | Should show backslash space |
1171+ | Multiple| `\\ \\ n\\ \\ t` | Should show backslashes |
1172+ MD
1173+
1174+ head = %w[ Context Code Expected ]
1175+ align = [ nil , nil , nil ]
1176+
1177+ # Expected behavior: backslashes in code spans should be preserved
1178+ # in table cells just like in plain text
1179+ body = [
1180+ [ 'Plain' , '<code>$\\\\</code>' , 'Should show backslash' ] ,
1181+ [ 'Escaped' , '<code>$\\\\</code>' , 'Should show backslash space' ] ,
1182+ [ 'Multiple' , '<code>\\\\n\\\\t</code>' , 'Should show backslashes' ] ,
1183+ ]
1184+
1185+ expected_table = @RM ::Table . new ( head , align , body )
1186+
1187+ # The document should contain a paragraph with inline code, then the table
1188+ expected = doc (
1189+ para ( 'Plain text: <code>$\\\\</code> and <code>$\\\\</code> should work.' ) ,
1190+ expected_table
1191+ )
1192+
1193+ assert_equal expected , doc
1194+ end
1195+
11601196 def parse ( text )
11611197 @parser . parse text
11621198 end
0 commit comments