Skip to content
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 improvements #2803

Merged
merged 14 commits into from
Jun 20, 2023
Merged

Conversation

davep
Copy link
Contributor

@davep davep commented Jun 19, 2023

A small selection of Markdown QoL changes and fixes, including:

  1. Adds an unhandled_token method, which in Markdown itself is a no-op (giving the effect of what happened before this was added), but also lets anyone inherit from Markdown and handle other MarkdownIT tokens -- possibly those added via extensions that aren't included in core Textual. This is also useful for testing purposes too as the method can be overridden to raise an error rather than ignore unknown tokens.
  2. Exports MarkdownBlock from textual.widgets.markdown; pretty necessary for anyone wanting to use the above1.
  3. Starts some Markdown-specific unit testing. Just the basics for now, but this at least provides some baseline tests and also a framework for further testing.
  4. Adds a fix for Markdown: Sections missing in the rendering #2781 (code blocks not appearing; not to be confused with fenced blocks).
  5. By extension adds a fix for half of Markdown widget: Code blocks in lists are incorrectly ordered, sometimes don't appear #2676.
  6. Adds a fix for the main half of Markdown widget: Code blocks in lists are incorrectly ordered, sometimes don't appear #2676 -- ensuring that code blocks in lists are rendered inline.
  7. Adds a fix for List items in a Markdown can receive focus #2380

Footnotes

  1. I am thinking it might be a good idea to export all the major Markdown widgets in this way.

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.
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.
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 Textualize#2781.
@davep davep added bug Something isn't working enhancement New feature or request Task labels Jun 19, 2023
@davep davep self-assigned this Jun 19, 2023
@davep davep linked an issue Jun 19, 2023 that may be closed by this pull request
@davep davep linked an issue Jun 19, 2023 that may be closed by this pull request
@davep davep marked this pull request as ready for review June 19, 2023 15:27
@davep davep requested a review from willmcgugan June 19, 2023 15:27
@davep davep requested a review from willmcgugan June 19, 2023 20:44
@willmcgugan willmcgugan merged commit 038cdb2 into Textualize:main Jun 20, 2023
17 checks passed
@davep davep deleted the markdown-improvements branch June 20, 2023 08:30
@davep davep linked an issue Jun 21, 2023 that may be closed by this pull request
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working enhancement New feature or request Task
Projects
None yet
2 participants