-
Notifications
You must be signed in to change notification settings - Fork 815
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
Markdown
widget: Code blocks in lists are incorrectly ordered, sometimes don't appear
#2676
Comments
This looks very much to be in the realm of the Textual, with this being handled by the |
Markdown
widget: Code blocks in lists are incorrectly ordered, sometimes don't appear
Thanks for moving the issue from Frogmouth @davep I've confirmed the behaviour is in the Textual
|
I'm sure that @davep is already way ahead of me on this, but posting anyway just in case it helps! I experimented with a blockquote inside a list item and it looks like Textual renders this as expected: I'm still trying to get to grips with the Markdown update method, but it looks like a blockquote token type is appended to the I hoped it might be as simple as changing this to the stack, but this breaks the docs |
Half of the above will be fixed by #2803 (the part above indented code blocks). I'm about to take a look at the problem of the code block appearing out of order when part of a list. The general problem can be seen here: I've not dived into the code yet, but I wanted to get an overview of what the widget tree looks like. Right off it seems clear that a list is an "atomic" or "leaf" widget, rendering its content and not containing other widgets (in other words the items in the list aren't widgets). Meanwhile the code is a This fits perfectly with what @TomJGooding finds above. |
See Textualize#2676 Co-authored-by: TomJGooding <[email protected]>
@TomJGooding You hoped right, like 99% of the way there right anyway:
Came down to e2dd711 |
Ah, that makes sense. I don't think that co-author was really deserved, but thank you! |
You found the right spot and mostly found the fix, I just copied your homework and tweaked it. ;-) |
* Initial set of Markdown widget unit tests Noting too crazy or clever to start with, initially something to just test the basics and to ensure that the resulting Textual node list is what we'd expect. Really just the start of a testing framework for Markdown. * Allow handling of an unknown token This allow for a couple of things: 1. First and foremost this will let me test for unhandled tokens in testing. 2. This will also let applications support other token types. * Update the Markdown testing to get upset about unknown token types * Treat a code_block markdown token the same as a fence I believe this should be a fine way to solve this. I don't see anything that means that a `code_block` is in any way different than a fenced block that has no syntax specified. See #2781. * Add a test for a code_block within Markdown * Allow for inline fenced code and code blocks See #2676 Co-authored-by: TomJGooding <[email protected]> * Update the ChangeLog * Improve the external Markdown elements are added to the document * Improve the testing of Markdown Also add a test for the list inline code block * Remove the unnecessary pause * Stop list items in Markdown being added to the focus chain See #2380 * Remove hint to pyright/pylance/pylint that it's okay to ignore the arg --------- Co-authored-by: TomJGooding <[email protected]>
Don't forget to star the repository! Follow @textualizeio for Textual updates. |
Current behaviour
Very similar to this old issue in Rich: Textualize/rich#1036
When we use the same content (a list with a code block):
cat > order.md
And then render it with Frogmouth:
Then the code block does not appear:
If we tweak the code block to use triple backticks, then the block appears, but out of order:
cat > order2.md
Expected behaviour
Render code block as part of the second item consistently.
Rich appears to render both markdown excerpts OK (and they appear the same). Tested with
rich==13.3.5
The text was updated successfully, but these errors were encountered: