adamchainz / blacken-docs

Run `black` on python code blocks in documentation files
MIT License
640 stars 42 forks source link

Blacken to also pick up `{.python}` code-blocks #357

Closed maxschulz-COL closed 1 month ago

maxschulz-COL commented 1 month ago

Python Version

No response

Package Version

1.18.0

Description

First of all really useful package, thanks!

So here is the issue: We discovered that while the tool can pick up a block like:

```python
def foo():
  return "poo"
\```

it does not pick up on the equivalent {.python} syntax (which allows to specify further options: https://python-markdown.github.io/extensions/fenced_code_blocks/).

We are trying to use this in mkdocs documentation, where the codeblocks carry further options, so cannot be specified as ```python.

Would this be something that could be supported?

Tagging also @maartenbreddels for visibility.

adamchainz commented 1 month ago

Dupe of #274 / #281.

Since you’re another report, I think we could consider adding support. The next step would be to rebase and finish up the work for #274 (docs, changelog note, more tests).