-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Ordered list restart after a code block. #80
Comments
Maybe something like this. I did not test this. You can modify the markdownify function to add a custom renderer for code blocks inside ordered lists. Here's an example of how you can modify the markdownify function to achieve this:
In the above code, we first import the original markdownify function from markdownx.utils, as well as the Extension, BlockProcessor, and etree classes from the markdown module. Then, we define a new CodeBlockProcessor class that extends BlockProcessor. This class tests whether a block starts with ``` and the parent tag is ol. If so, it creates a new li element and a pre element inside it, and sets the text of the code block as the text of the pre element. Next, we define an OrderedCodeExtension class that extends Extension. This class registers our CodeBlockProcessor with the Markdown parser. Finally, we define a new markdownify function that calls the original markdownify function with our OrderedCodeExtension added as an extension. |
If I want to insert a code block with ``` inside an ordered list I cannot continue the list, it restarts. What can I do to fix this?
The following do not work:
<pre>
.Thanks a ton in advance.
The text was updated successfully, but these errors were encountered: