-
-
Notifications
You must be signed in to change notification settings - Fork 46
Description
Description
When I'm writing docs, I frequently add code blocks like this:
def func(var1):
"""
My docstrings
```py
...
```
"""
return var1Or like this:
def func(var1):
"""
My docstrings
```python
...
```
"""
return var1I can see that both of these code blocks are supported in your package, as defined in this line:
blacken-docs/src/blacken_docs/__init__.py
Line 16 in 3199508
| PYGMENTS_PY_LANGS = frozenset(("python", "py", "sage", "python3", "py3", "numpy")) |
However, I'd like to extend this functionality to include two other identifiers for the Pygment langs:
".py"".python"
The reason why is because in the pymdown-extensions package, it has some functionality called Super Fences: SuperFences. Here, it enables you to define some code blocks which allow you to inject some special syntax to generate html code with additional classes, id's, titles, line nums, etc.
Here's an example:
def func(var1):
"""
My docstring
```{.python .extra-html-class linenums="1"}
...
```
"""
return var1Or like this:
def func(var1):
"""
My docstring
```{.py .extra-html-class linenums="1"}
...
```
"""
return var1You'll notice, also, that in order to use the functionality from the PyMdown-Extensions package, we also need to use curly brackets { and }.
When I use the syntax like this, then my docs are not automatically 'blackened' thanks to your excellent package.
Can you please extend your package to handle this functionality also?
I would recommend adjusting this line:
blacken-docs/src/blacken_docs/__init__.py
Line 16 in 3199508
| PYGMENTS_PY_LANGS = frozenset(("python", "py", "sage", "python3", "py3", "numpy")) |
To be like this:
PYGMENTS_PY_LANGS = frozenset(("python", "py", "sage", "python3", "py3", "numpy", ".py", ".python"))And also adjusting this line:
blacken-docs/src/blacken_docs/__init__.py
Line 19 in 3199508
| r"(?P<before>^(?P<indent> *)```\s*" + PYGMENTS_PY_LANGS_RE_FRAGMENT + r"( .*?)?\n)" |
To be like this:
r"(?P<before>^(?P<indent> *)```\s*\{?" + PYGMENTS_PY_LANGS_RE_FRAGMENT + r"( .*?)?\}?\n)"I hope that helps?
Thanks 👍