Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Overly escaping brackets - tickboxes #23

Closed
mdeweerd opened this issue Mar 2, 2022 · 12 comments
Closed

Overly escaping brackets - tickboxes #23

mdeweerd opened this issue Mar 2, 2022 · 12 comments

Comments

@mdeweerd
Copy link

mdeweerd commented Mar 2, 2022

Tickboxes are not part of CommonMark but part of GFM, so I'ld prefer to kee the brackets of tickboxes unchanged:

- [x] Task 1
- [ ] Task 2

- \[x\] Task 1
- \[ \] Task 2

This is somewhat related to executablebooks/mdformat#112 .

@hukkin
Copy link
Owner

hukkin commented Mar 2, 2022

Do you have mdformat-gfm installed? You can see installed plugins and their versions with mdformat --version.

@mdeweerd
Copy link
Author

mdeweerd commented Mar 2, 2022

I added it to pre-commit:

      - id: mdformat
        name: Format Markdown
        entry: mdformat  # Executable to run, with fixed options
        language: python
        types: [markdown]
        args: [--wrap, '75', --number]
        additional_dependencies:
          - mdformat-toc
          - mdformat-gfm

@hukkin
Copy link
Owner

hukkin commented Mar 2, 2022

I suspect you didn't have the plugin on the first run, so the backslashes were added. Can you try manually removing them and then running mdformat again?

@mdeweerd
Copy link
Author

mdeweerd commented Mar 2, 2022

I did that prior to reporting by doing a "git reset --hard".

@mdeweerd
Copy link
Author

mdeweerd commented Mar 2, 2022

I got the versions:

$ pre-commit run -v -a
Format Markdown..........................................................Passed
- hook id: mdformat
- duration: 0.72s

mdformat 0.7.13 (mdformat_gfm: 0.3.5, mdformat_tables: 0.4.1, mdformat_toc:
0.3.0)

@mdeweerd
Copy link
Author

mdeweerd commented Mar 2, 2022

It's not systematic:

# Before:
* [ ] Vérifier que les dates de sauvegarde sont récentes (au plus tard le jour précédent pour la plupart des sauvegarde, sauf exceptionnellement les sauvegardes mensuelles ou hebdomadaires).

# After:
- [ ] Vérifier que les dates de sauvegarde sont récentes (au plus tard le
  jour précédent pour la plupart des sauvegarde, sauf exceptionnellement
  les sauvegardes mensuelles ou hebdomadaires).

@hukkin
Copy link
Owner

hukkin commented Mar 2, 2022

I'm not able to reproduce:

foo@bar:~$ python3 -m venv venv
foo@bar:~$ source venv/bin/activate
(venv) foo@bar:~$ pip install mdformat-gfm
Collecting mdformat-gfm
  Using cached mdformat_gfm-0.3.5-py3-none-any.whl (4.9 kB)
Collecting markdown-it-py[linkify]
  Using cached markdown_it_py-2.0.1-py3-none-any.whl (84 kB)
Collecting mdformat<0.8.0,>=0.7.5
  Using cached mdformat-0.7.13-py3-none-any.whl (27 kB)
Collecting mdit-py-plugins<0.4.0,>=0.2.0
  Using cached mdit_py_plugins-0.3.0-py3-none-any.whl (43 kB)
Collecting mdformat-tables>=0.4.0
  Using cached mdformat_tables-0.4.1-py3-none-any.whl (4.6 kB)
Collecting attrs<22,>=19
  Using cached attrs-21.4.0-py2.py3-none-any.whl (60 kB)
Collecting mdurl~=0.1
  Using cached mdurl-0.1.0-py3-none-any.whl (11 kB)
Collecting linkify-it-py~=1.0; extra == "linkify"
  Using cached linkify_it_py-1.0.3-py3-none-any.whl (19 kB)
Collecting tomli>=1.1.0
  Using cached tomli-2.0.1-py3-none-any.whl (12 kB)
Collecting importlib-metadata>=3.6.0; python_version < "3.10"
  Using cached importlib_metadata-4.11.2-py3-none-any.whl (17 kB)
Collecting uc-micro-py
  Using cached uc_micro_py-1.0.1-py3-none-any.whl (6.2 kB)
Collecting zipp>=0.5
  Using cached zipp-3.7.0-py3-none-any.whl (5.3 kB)
Installing collected packages: attrs, mdurl, uc-micro-py, linkify-it-py, markdown-it-py, tomli, zipp, importlib-metadata, mdformat, mdit-py-plugins, mdformat-tables, mdformat-gfm
Successfully installed attrs-21.4.0 importlib-metadata-4.11.2 linkify-it-py-1.0.3 markdown-it-py-2.0.1 mdformat-0.7.13 mdformat-gfm-0.3.5 mdformat-tables-0.4.1 mdit-py-plugins-0.3.0 mdurl-0.1.0 tomli-2.0.1 uc-micro-py-1.0.1 zipp-3.7.0
(venv) foo@bar:~$ mdformat --version
mdformat 0.7.13 (mdformat_tables: 0.4.1, mdformat_gfm: 0.3.5)
(venv) foo@bar:~$ printf -- '- [x] Task 1\n- [ ] Task 2\n' > t.md
(venv) foo@bar:~$ cat t.md 
- [x] Task 1
- [ ] Task 2
(venv) foo@bar:~$ mdformat t.md 
(venv) foo@bar:~$ cat t.md 
- [x] Task 1
- [ ] Task 2
(venv) foo@bar:~$

@mdeweerd
Copy link
Author

mdeweerd commented Mar 2, 2022

I got the culprit: tabs!

They can't be pasted in the issue, but you have to replace the spaces between the closing bracket and the text with tabs. Hard to see 👀!

* [x]   ABC
* [x]   DEF

@hukkin
Copy link
Owner

hukkin commented Mar 2, 2022

Thanks!

Have you checked whether that tab is allowed in the GFM spec? If it isn't, then I'm not worried at all. If it is allowed, then this should be an issue in the Markdown parser used, and reported and fixed in https://github.com/executablebooks/mdit-py-plugins

@mdeweerd
Copy link
Author

mdeweerd commented Mar 2, 2022

The renderer does not complain.
https://gist.github.com/mdeweerd/177a260cc0deb83566ce85847e0bab71

The specification requires a whitespace character:
https://github.github.com/gfm/#task-list-items-extension-

Tabs are whitespace characters:
https://github.github.com/gfm/#whitespace-character

They are also whitespace characters in CommonMark:
https://spec.commonmark.org/0.29/#whitespace-character

@mdeweerd
Copy link
Author

mdeweerd commented Mar 2, 2022

I added:

  - repo: https://github.com/Lucas-C/pre-commit-hooks
    rev: v1.1.13
    hooks:
      - id: remove-tabs

To pre-commit before the mdformat hook to fix the issue.

@hukkin
Copy link
Owner

hukkin commented May 9, 2022

Thanks for reporting this. I'm closing this issue in favor of the upstream issue executablebooks/mdit-py-plugins#41 which will be fixed by executablebooks/mdit-py-plugins#42

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants