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

Add support for Markdown in TUI, console, clipboard output #427

Open
wants to merge 10 commits into
base: master
Choose a base branch
from

Conversation

danschwarz
Copy link
Collaborator

@danschwarz danschwarz commented Nov 26, 2023

As it turns out, the pandoc utility, with pypandoc Python bindings, do a better job converting HTML to markdown than html2text or markdownify libraries. Pandoc is widely used and maintained, in contrast to the other libraries.

In the TUI, statuses are rendered in HTML by urwidgets if available, fallback is markdown (via pandoc if available), and finally plaintext if neither urwidgets nor pandoc are available.

In the console and clipboard, status rendering is in markdown via pandoc, fallback to plaintext if pandoc is not available.

TODO:

  • Command line option or config file option to choose tui status rendering: HTML, markdown, or plaintext.
  • Command line option or config file option to choose console status rendering: markdown or plaintext.
  • Test cases to exercise all rendering options correctly. At present, we are testing only the plaintext rendering in console.

Here's an example of markdown rendering in the TUI. This is using github-flavored-markdown, FWIW.

This addresses issue #416 .

image

@danschwarz danschwarz requested a review from ihabunek November 26, 2023 21:04
Now we default to markdown when displaying
status messages; the --plaintext option reverts
to previous behavior. This switch is used in
test_console.py so existing tests will pass;
we can add tests in future without --plaintext
to test the markdown rendering.
Markdown is specified by using the -md or --markdown option
@danschwarz
Copy link
Collaborator Author

Switched it to default to plaintext (as it was originally) and use the -md / --markdown option to render as markdown. Makes more sense this way.

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