-
Hello, I'm writing a small Markdown extension that detects pycon code blocks without indentation or fences. Following is detected as pycon code block:
>>> 1 + 1
2 When it finds such blocks, it wraps them in fences for SuperFences to handle them. The above block becomes: ```pycon
>>> 1 + 1
2
``` Initially I tried writing the extension as a block processor (it was implemented in one line!) but it looks like SuperFences runs as a preprocessor, so I had to re-implement it as a preprocessor as well, to run before SuperFences. My preprocessing works, but only when the block is not indented (i.e. not in an admonition or tab), and only when the block is not already in a code block. This does not work:
```
>>> 1 + 1
2
```
This neither:
!!! note
>>> 1 + 1
2 This is very limited. How would you go about writing such an extension 🤔? Is there a way with a block processor instead of a preprocessor? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 3 replies
-
OK, once again I was able to use @oprypin's code 😅 |
Beta Was this translation helpful? Give feedback.
OK, once again I was able to use @oprypin's code 😅
I reused the highlighter from mkdocstrings in a block processor 🙂