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

example improvements #184

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

JeromeSchmied
Copy link

  • fix(examples/html2term): more (vim-alike) keybinds
  • fix(examples/html2text): use yansi instead of termion for colouring
    • adds support for hyperlinks
    • more intuitive IMO
    • less dependencies

Copy link
Owner

@jugglerchris jugglerchris left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And here I thought Termion was low-dependency...
Thanks for the changes! I've made a few comments.

@@ -41,6 +41,7 @@ path = "examples/html2text.rs"
env_logger = "0.10.1"
argparse = "0.2.2"
log = "0.4.20"
yansi = { version = "1.0.1", features = ["hyperlink"] }
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should remove the termion dependency if it's no longer used.

Image(_) => {
styled = match annotation {
Default => styled,
Link(url) => styled.link(url).blue().underline().to_string(),
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think the hyperlinks should be on by default, but fine with an opt in option (--hyperlinks or similar).

start.push(format!("{}", Fg(Blue)));
finish.push(format!("{}", Fg(Reset)));
format!(
"{} {}",
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can't add extra visible text here - the colour map function is not expected to change the size of any text, or it would mess up the formatting. As above, the hyperlink should only be done with an option to enable it.

}
}
Strikeout => {
if !have_explicit_colour {
start.push(format!("{}", Fg(LightBlack)));
finish.push(format!("{}", Fg(Reset)));
styled.strike().to_string()
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The text should already be struck out already by this point (using U+336).

@JeromeSchmied
Copy link
Author

Note

one test doesn't pass, as I've removed the unicode character strikethrough thing

image

should I revert it and use the old method, or use the new one (yansi .strike()) which IMO looks better, but only applies in the html2text example, not elsewhere, and delete the test?

@JeromeSchmied
Copy link
Author

I've got the following question: is there a fairly easy way of turning markdown-like decorations in the scope of examples/html2text? I find it quite annoying, that *bold text looks like this* and would prefer bold text to look like this without the *-s

@jugglerchris
Copy link
Owner

Hi. About the strikeout, I think it should at least be an option, since terminal escape sequences aren't always available.

I've got the following question: is there a fairly easy way of turning markdown-like decorations in the scope of examples/html2text? I find it quite annoying, that bold text looks like this and would prefer bold text to look like this without the *-s

There are a couple of options:

  1. Use --literal (under the hood uses TrivialDecorator)
  2. Use --colour (possibly with --css and the css feature enabled), which uses internally uses the "Rich" output which adds metadata annotations instead of textual decoration, and adds some terminal colouring.

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.

2 participants