PipeTable: NewLine > Code Delimiter > Column Delimiter Precedence #357

Open
opened 2026-01-29 14:34:50 +00:00 by claunia · 2 comments
Owner

Originally created by @SebastianRaffel on GitHub (Apr 14, 2020).

Rule #7
A backtick/code delimiter has a higher precedence than a column delimiter |:

A new line inside of pipe tables should have a higher precedence than a code delimiter. Pipe tables are not designed for multi line cells, therefore code inside pipe tables may not be multiline.
Currently backticks that are not in the same cell break the complete pipe table. Example:

Col1 | Col2
---|---
first`|row`
second|row

Result:

<p>Col1 | Col2
---|---
first<code>|row</code>
second|row</p>

Desired:

<table>
	<thead>
		<tr>
			<th>Col1</th>
			<th>Col2</th>
		</tr>
	</thead>
	<tbody>
		<tr>
			<td>first<code>|row</code></td>
			<td></td>
		</tr>
		<tr>
			<td>second</td>
			<td>row</td>
		</tr>
	</tbody>
</table>

It is safer to recognize code blocks in one line only, as it only breaks that particular line, not the whole table. Example:
markdown-it demo

Originally created by @SebastianRaffel on GitHub (Apr 14, 2020). > Rule #7 > A backtick/code delimiter has a higher precedence than a column delimiter |: A new line inside of pipe tables should have a higher precedence than a code delimiter. Pipe tables are not designed for multi line cells, therefore code inside pipe tables may not be multiline. Currently backticks that are not in the same cell break the complete pipe table. Example: ``` markdown Col1 | Col2 ---|--- first`|row` second|row ``` Result: ``` html <p>Col1 | Col2 ---|--- first<code>|row</code> second|row</p> ``` Desired: ``` html <table> <thead> <tr> <th>Col1</th> <th>Col2</th> </tr> </thead> <tbody> <tr> <td>first<code>|row</code></td> <td></td> </tr> <tr> <td>second</td> <td>row</td> </tr> </tbody> </table> ``` It is safer to **recognize code blocks in one line only**, as it only breaks that particular line, not the whole table. **Example**: [**markdown-it demo**](https://markdown-it.github.io/#md3=%7B%22source%22%3A%22Col1%20%7C%20Col2%5Cn---%7C---%5Cnbroken%60%7Crow%60%5Cnlast%7Crow%22%2C%22defaults%22%3A%7B%22html%22%3Afalse%2C%22xhtmlOut%22%3Afalse%2C%22breaks%22%3Afalse%2C%22langPrefix%22%3A%22language-%22%2C%22linkify%22%3Atrue%2C%22typographer%22%3Atrue%2C%22_highlight%22%3Atrue%2C%22_strict%22%3Afalse%2C%22_view%22%3A%22html%22%7D%7D)
Author
Owner

@xoofx commented on GitHub (Apr 14, 2020):

Hm, not sure I want to change that behavior for this, as markdown-it is not a ground truth either here (it is even incorrect, but it parse something as table while it should not)

It is currently a known differences with other markdown engines but there is no real consensus.

Ideally, I would like to introduce a mode that match GitHub Markdown behavior (as it is the most common usage of Markdown these days).

@xoofx commented on GitHub (Apr 14, 2020): Hm, not sure I want to change that behavior for this, as markdown-it is not a ground truth either here (it is even incorrect, but it parse something as table while it should not) It is currently a known differences with [other markdown engines](https://babelmark.github.io/?text=Col1+%7C+Col2%0A---%7C---%0Afirst%60%7Crow%60%0Asecond%7Crow) but there is no real consensus. Ideally, I would like to introduce a mode that match GitHub Markdown behavior (as it is the most common usage of Markdown these days).
Author
Owner

@SebastianRaffel commented on GitHub (Apr 14, 2020):

Hey, thanks for the reply!
I agree, a GFM option would be best.
I'll use Babelmark for comparisons in the future :)

@SebastianRaffel commented on GitHub (Apr 14, 2020): Hey, thanks for the reply! I agree, a GFM option would be best. I'll use Babelmark for comparisons in the future :)
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/markdig#357