Skip to content

Escaping a pipe in markdown table returns different result since 0.17.3 #117

@kachick

Description

@kachick

Description

Since dprint-plugin-markdown-0.17.3, escaping a pipe in a markdown table returns a different result.
Additionally, it will also generate different reports between check and fmt.

Is this an intentional change?

Expected behavior

  1. fmt keeps same rendering result in GFM
  2. Even though changing the behaviors, I expect dprint fmt to return the same result as dprint check reports.

Logs

Tested with dprint 0.45.1 and 0.47.2. And markdown-0.17.2, markdown-0.17.3, markdown-0.17.4

> dprint --version
dprint 0.45.1

Target markdown file

| f\|oo  |
| ------ |
| b `\|` az |
| b **\|** im |
| `command \| filter` |

It interprets as below in GitHub

f|oo
b | az
b | im
command | filter

0.17.2 fmt result does not affect rendering result

f|oo
b | az
b | im
command | filter

0.17.3 fmt changes the rendering result

f|oo
b `
b | im
`command

Appendix

Reproduction Script for 0.17.2
cd "$(mktemp --directory)"

cat <<'JSON' > ./dprint.json
{
  "markdown": {},
  "plugins": [
    "https://plugins.dprint.dev/markdown-0.17.2.wasm"
  ]
}
JSON

mdtable="$(mktemp --suffix=.md --tmpdir="$PWD")"

cat <<'MARKDOWN' > "$mdtable"
| f\|oo  |
| ------ |
| b `\|` az |
| b **\|** im |
| `command \| filter` |
MARKDOWN

dprint check
dprint fmt
cat "$mdtable"

check result

> dprint check
from /tmp/tmp.sT0fsTwBE7/tmp.E2tDbfiEg5.md:
  1|-|·f\|oo··|
  2|-|·------·|
  3|-|·b·`\|`·az·|
  4|-|·b·**\|**·im·|
1  |+|·f\|oo···············|
2  |+|·-------------------·|
3  |+|·b·`\|`·az···········|
4  |+|·b·**\|**·im·········|
5 5| |·`command·\|·filter`·|
--
Found 1 not formatted file.

fmt result

> dprint fmt
Formatted 1 file.

> cat "$mdtable"
| f\|oo               |
| ------------------- |
| b `\|` az           |
| b **\|** im         |
| `command \| filter` |
Reproduction Script for 0.17.3
cd "$(mktemp --directory)"

cat <<'JSON' > ./dprint.json
{
  "markdown": {},
  "plugins": [
    "https://plugins.dprint.dev/markdown-0.17.3.wasm"
  ]
}
JSON

mdtable="$(mktemp --suffix=.md --tmpdir="$PWD")"

cat <<'MARKDOWN' > "$mdtable"
| f\|oo  |
| ------ |
| b `\|` az |
| b **\|** im |
| `command \| filter` |
MARKDOWN

dprint check
dprint fmt
cat "$mdtable"

check result

> dprint check
from /tmp/tmp.talxYkpfIp/tmp.zDeiKDP0rM.md:
  1|-|·f\|oo··|
  2|-|·------·|
  3|-|·b·`\|`·az·|
  4|-|·b·**\|**·im·|
  5|-|·`command·\|·filter`·|
1  |+|·f\|oo··············|
2  |+|·------------------·|
3  |+|·b·`|`·az···········|
4  |+|·b·**\|**·im········|
5  |+|·`command·|·filter`·|
--
Found 1 not formatted file.

fmt result

> dprint fmt
Formatted 1 file.

> cat tmp.zDeiKDP0rM.md
| f\|oo       |
| ----------- |
| b `         |
| b **\|** im |
| `command    |

Links

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions