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

Extend terminal support #12

Closed
swsnr opened this issue Jan 25, 2018 · 8 comments
Closed

Extend terminal support #12

swsnr opened this issue Jan 25, 2018 · 8 comments
Labels
help wanted Extra attention is needed

Comments

@swsnr
Copy link
Owner

swsnr commented Jan 25, 2018

Figure out whether other terminal emulators support iTerm2 features and extend the list of supported terminals accordingly.

@swsnr swsnr added help wanted Extra attention is needed good first issue labels Jan 25, 2018
@vinipsmaker
Copy link

The terminal I use also supports images, but it uses its own escape sequences: https://github.com/billiob/terminology

Maybe it's simply enough that you guys could implement it.

@swsnr
Copy link
Owner Author

swsnr commented Jan 25, 2018

I'd appreciate a pull request, to be honest; I can't test that terminal myself.

vinipsmaker added a commit to vinipsmaker/mdcat that referenced this issue Jan 28, 2018
vinipsmaker added a commit to vinipsmaker/mdcat that referenced this issue Jan 28, 2018
vinipsmaker added a commit to vinipsmaker/mdcat that referenced this issue Jan 28, 2018
vinipsmaker added a commit to vinipsmaker/mdcat that referenced this issue Jan 28, 2018
vinipsmaker added a commit to vinipsmaker/mdcat that referenced this issue Jan 28, 2018
vinipsmaker added a commit to vinipsmaker/mdcat that referenced this issue Jan 28, 2018
vinipsmaker added a commit to vinipsmaker/mdcat that referenced this issue Jan 28, 2018
vinipsmaker added a commit to vinipsmaker/mdcat that referenced this issue Jan 28, 2018
vinipsmaker added a commit to vinipsmaker/mdcat that referenced this issue Jan 28, 2018
vinipsmaker added a commit to vinipsmaker/mdcat that referenced this issue Jan 28, 2018
vinipsmaker added a commit to vinipsmaker/mdcat that referenced this issue Jan 28, 2018
@PerBothner
Copy link

PerBothner commented Apr 24, 2018

DomTerm supports not only inline images and links but also inline html.
In fact following works pretty well as an mdcat substitute:

cmark -t html common-mark.md | domterm hcat

The main issue with the above pipeline is the relative URLs aren't handled well at this point (though I'm thinking of the best way to deal with it).

The domterm hcat command is basically trivial: In addition to terminal detection (a quick-and-dirty way to do that is to check for a DOMTERM environment variable) it just wraps the output in a simple escape sequence:

\033]72;HTML_DATA\007

I don't know Rust but it seems mdcat could easily add DomTerm support by wrapping the output of pulldown-cmark with the above-mentioned escape sequence. Preferably you'd want to convert URLs to data: URLs - at the very least relative URLs.

@swsnr
Copy link
Owner Author

swsnr commented Apr 24, 2018

@PerBothner I can add support for DomTerm to the inline HTML code—though I don't have much time and would prefer a pull request.

But I wonder whether I need to: If DomTerm supports HTML why not use one of the many Markdown-to-HTML converters instead? 🤔

These tools produce leverage the full syntax of HTML and normally produce much better output than mdcat with its limitation to ASCII formatting. In fact it seems to me that on DomTerm alias mdcat="pandoc | domterm hcat| would do a much better job than mdcat itself 🙂

@PerBothner
Copy link

Two reasons I can think of:

  1. If you intend mdcat as a general portable tool for "do as good a job as you can" to display MarkDown on the current terminal, it would be better if it would do the right thing without the user having to create a wrapper script to handle both DomTerm and "other terminals".

  2. There is the issue of how to handle relative URLs - especially for images - in the source. I'm working on a --base-url=URL option for domterm hcat to resolve these URLs. However, it would be more robust to translate images to data: URLs. One reason if you're ssh'd to a different computer than the one running the display - the file may not be available to the local browser. Another is if the image is modified or removed: A "refresh" could change previous output.

Perhaps domterm hcat could have an option to translate local (or all) image URLs to data: URLs but that would add quite of bit of complexity to domterm hcat. (That command does not current parse or scrub the HTML - that is done by the browser part of DomTerm.)

Now whether these reasons are strong enough to add DomTerm support to mdcat is a different issue. Ideally, yes, but given limited resources I understand if you don't make it top priority :-)

@swsnr
Copy link
Owner Author

swsnr commented Apr 24, 2018

@PerBothner I was just wondering, but I see your point now.

That said it's not my intention to make mdcat the one size fits all tool for markdown on TTYs; I just want a tool that I myself can use to quickly print markdown files on TTYs. So indeed, it's not my personal priority to add support for a proprietary feature of a terminal emulator I don't even use 😊

I'll look into this when I've got some spare time perhaps, but I'd really appreciate a pull request to be honest. It's not quite trivial: We must add HTML to mdcat which it currently does not understand, and we must add extra logic to convert all kinds of images (Markdown and inline HTML) to data URLs. That's quite a bit of extra logic.

@aeosynth
Copy link

to add another terminal, kitty created its own graphics protocol:

https://sw.kovidgoyal.net/kitty/index.html
https://sw.kovidgoyal.net/kitty/graphics-protocol.html

perhaps you could use the ranger tui file manager as a rosetta stone; it supports drawing images in iterm2, terminology, urxvt, and kitty

https://github.com/ranger/ranger
https://github.com/ranger/ranger/blob/master/ranger/ext/img_display.py

@swsnr
Copy link
Owner Author

swsnr commented Sep 22, 2018

Thanks but I won’t add that myself. I don’t have the time.

I’m closing this issue; I don’t intend to add further terminal emulators myself.

Please open a pull request to add support for this terminal emulator if you like.

@swsnr swsnr closed this as completed Sep 22, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

4 participants