Skip to content

Commit b8f87d1

Browse files
committed
Merge pull request #441 from mitya57/master
Fix #440 (Tables extension drops characters after code spans)
2 parents 5deee37 + b966709 commit b8f87d1

File tree

3 files changed

+23
-2
lines changed

3 files changed

+23
-2
lines changed

markdown/extensions/tables.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ def _split(self, row, marker):
119119
groups = match.groups()
120120
delim = groups[1] # the code block delimeter (ie 1 or more backticks)
121121
row_contents = groups[2] # the text contained inside the code block
122-
i += match.start(4) # jump pointer to the beginning of the rest of the text (group #4)
122+
i += match.start(4) - 1 # jump pointer to the beginning of the rest of the text (group #4)
123123
element = delim + row_contents + delim # reinstert backticks
124124
current += element
125125
i += 1

tests/extensions/extra/tables.html

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -235,4 +235,19 @@ <h2>Table Tests</h2>
235235
<td>more words</td>
236236
</tr>
237237
</tbody>
238+
</table>
239+
<p>A test for issue #440:</p>
240+
<table>
241+
<thead>
242+
<tr>
243+
<th>foo</th>
244+
<th>bar</th>
245+
</tr>
246+
</thead>
247+
<tbody>
248+
<tr>
249+
<td>foo</td>
250+
<td>(<code>bar</code>) and <code>baz</code>.</td>
251+
</tr>
252+
</tbody>
238253
</table>

tests/extensions/extra/tables.txt

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,4 +68,10 @@ words |``` some | code ``` | more words
6868
words |```` some | code ```` | more words
6969
words |`` some ` | ` code `` | more words
7070
words |``` some ` | ` code ``` | more words
71-
words |```` some ` | ` code ```` | more words
71+
words |```` some ` | ` code ```` | more words
72+
73+
A test for issue #440:
74+
75+
foo | bar
76+
--- | ---
77+
foo | (`bar`) and `baz`.

0 commit comments

Comments
 (0)