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

Option to map a subset of Mardown to terminal escape codes #103

Open
83noit opened this issue Nov 12, 2024 · 2 comments
Open

Option to map a subset of Mardown to terminal escape codes #103

83noit opened this issue Nov 12, 2024 · 2 comments

Comments

@83noit
Copy link

83noit commented Nov 12, 2024

The idea would be to add an option to support a subset of Markdown relevant to a single line and translate into terminal formatting escape codes for display purposes.

This could include:

  • bold
  • italic
  • bold and italic
  • link
  • formatted link

They straightforwardly translates into terminal escape sequences, including the hyperlink OCS8 with a growing terminal and app support.

For illustration, I interact with my todo.txt files either in the terminal or as file linked in my Markdown notes (e.g. with an app like Obsidian). I would love to be able to use hyperlink that can be functional both in a terminal and in a Markdown editor. This would enable me to log a task and functionally linked it to an external reference (e.g. another note; a website; an email address).

@VladimirMarkelov
Copy link
Owner

It means, it needs a simple markdown parser for a tiny subset of markdown tags. An an extra note for myself: http: should not be treated as tag. What is the difference between link and formatted link? The former is http://example.com/a and the latter is [Title](http://example.com/a)? If I am not mistaken, modern terminals highlight simple links automatically without any help from an application.

@83noit
Copy link
Author

83noit commented Nov 23, 2024

For links, the two use cases I am thinking about are:

  • standard URLs ("links"; http://example.com/a; mailto:[email protected]). Modern terminals tend to indeed make them clickable, but if they are parsed and print out with escape codes, this would allow manipulations down the road (e.g. only print out only the domain if the link is long, while following the original path when clicked).
  • Markdown "formatted" links ([Title](http://example.com/a)), which ideally would be rendered when print out as Title and clickable.

While it is possible not to parse the former, because of the widespread terminal support, the latter would need parsing and rendering. For this reason, it might make sense to parse and render both with OCS8 escape codes to offer further displays options down the line.

Another thing to think about is when to do the rendering/escaping: by default stdout and raw if redirected (pipes, etc.)? Only with an explicit command line argument (--foo-bar-markdown)?

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

No branches or pull requests

2 participants