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

Proof of concept for issue #416 - adds Markdown rendering in TUI #417

Closed
wants to merge 7 commits into from

Conversation

danschwarz
Copy link
Collaborator

@danschwarz danschwarz commented Nov 21, 2023

Here's a PR against master that uses html2text to render statuses in Markdown. (per issue #416) It does this all the time for console output (toot timeline etc.) and copy-to-clipboard. In the TUI, it renders Markdown as a fallback if the urwidgets library is unavailable.

It works OK, but has some rendering challenges due to quirks and limitations of html2text. I think I'll try substituting markdown-it-py to see if it does a better job. Turns out, markdown-it-py goes the opposite direction, from markdown to HTML.

I tested markdownify instead; it's less flexible than html2text and has its own quirks, so it's a question of which library's quirks we can put up with. Or find another. The only other solution I've found is pandoc, which relies on a Haskell library. So that's not ideal.

For the moment, I'm sticking with html2text.

image

Another issue is that urwid Text widgets wrap text as needed, and html2text depends on fixed width lines in order to render things like blockquotes and lists correctly. If the TUI status window is too narrow, blockquotes and lists won't look right. Not much we can do about this other than detect the status window width and re-render the Markdown on any window resize 🤮 . Or ignore the problem (my preferred solution.) You can see an example of this line wrapping problem in the image below:
image

@danschwarz
Copy link
Collaborator Author

Opening a new PR that uses Pandoc instead (turns out, it's better)

@danschwarz danschwarz closed this Nov 23, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant