azimuth
azimuth copied to clipboard
Leverage prettier for markdown files
Unfortunatly, prettier messes up admonitions:
!!! info "How to temporarily disable pre-commits?"
- For a specific commit, you can avoid running the pre-commits with the flag `--no-verify`. If you do this, make sure to run `pre-commit run --all-files` before opening a PR, which will run the pre-commit on all files.
-
+For a specific commit, you can avoid running the pre-commits with the flag `--no-verify`. If you do this, make sure to run `pre-commit run --all-files` before opening a PR, which will run the pre-commit on all files.
Issues opened:
- https://github.com/prettier/prettier/issues/12985
- https://github.com/prettier/prettier/issues/8640
The fix mentioned (adding a blank line between the !!! and the content) doesn't work on admonitions inside lists.
For future reference, this is the precommit hook I used:
- repo: local
hooks:
- id: prettier-docs
name: prettier-docs
language: system
entry: bash -c 'cd webapp && poetry run yarn prettier --write ../docs'
files: docs
Did you mention yesterday that you found a fix for that? Did you need to install something with yarn first?
I tried with another hook and got relatively close to it working, but it doesn't handle complex admonitions with code/bullets/multiple tables in them. I tabled this for now.
- repo: https://github.com/executablebooks/mdformat
rev: 0.7.16
hooks:
- id: mdformat
exclude: docs/includes
additional_dependencies:
- mdformat-mkdocs
- mdformat-admon
- mdformat-beautysh
- mdformat-footnote
- mdformat-black
- mdformat-simple-breaks
- mdformat-tables