sharkdp / bat

A cat(1) clone with wings.
Apache License 2.0
49.73k stars 1.25k forks source link

hiding markup syntax in org mode #1790

Open vzaliva opened 3 years ago

vzaliva commented 3 years ago

Here is an example:

Org-mode test:
* Section
** Sub-section
*** Sub-sub-section
    normal
    /italic/
    *bold*
    ~verbatim~

In emacs it is rendered as follows:

2021-08-10_13-45

Bat shows it as follows:

2021-08-10_13-45_1

The obvious problems are:

  1. bold is not highlighted
  2. italic and verbatim are highlighted but enclosing syntax markers are visible
  3. italic is not rendered in italic
  4. Section handling could use color or some other style rendering in which case the markup (leading asterisks) could be hidden.
sharkdp commented 3 years ago

Thank you for your request

  • bold is not highlighted

  • italic is not rendered in italic

  • Section handling could use color or some other style rendering […]

That is something that could be fixed in the upstream syntax repository (https://github.com/jezcope/Org.tmbundle)

  • italic and verbatim are highlighted but enclosing syntax markers are visible

[…] in which case the markup (leading asterisks) could be hidden.

Yes. bat is a tool to display file contents. It's not a org mode renderer. We can talk about syntax highlighting improvements, but bat will never hide text that's actually there.

vzaliva commented 3 years ago

I understand your position about not transforming file content when displaying. How about a compromise, rendering '/' in /italic/ in background color, making them invisible but still there for copy-paste? Could be a special syntax highlight mode, like org-invisible...

vzaliva commented 3 years ago

Need a clarification on what belongs to upstream and what belongs to bat:

  1. Italic is detected as the syntax, as you can see by the different color used. It is just not rendered using italic font.
  2. Bold is not rendered any different from plain text. However, in the upstream repository, I can see regexp for bold detection which is very similar to one for italic. It should be working.

Are these bat or Org.tmbundle issues?

keith-hall commented 3 years ago

Most likely they are color scheme (aka theme) issues. You can try with a different one, or customize it / make a PR to the upstream color scheme repo with a fix

sharkdp commented 3 years ago

Also, note that italics are not enabled in bat by default. Check out this README section to see how you can enable it.

vzaliva commented 3 years ago

I confirm that I have --italic-text=always enabled in my config. Still no italic is shown. I've compared my example to markdown mode:

Markdown-mode test:
# Section
## Sub-section
### Sub-sub-section
* normal
* *italic*
* **bold**
* `verbatim`

2021-08-15_11-06

The difference is that bold is highlighted. However italic is still not rendered as italic.

I can also confirm that my terminal indeed supports italic:

2021-08-15_11-08

keith-hall commented 3 years ago

With the TwoDark color scheme, neither bold or italic markdown text is rendered as bold or italic, but with the default color scheme it is. So it seems like TwoDark needs some fixes/improvements.

vzaliva commented 3 years ago

Default theme also has problems in org mode:

  1. bold is not properly highlighted (see screenshot)
  2. verbatim is not highlighted

I guess I need to find right theme which renders or mode correctly.

2021-08-15_11-28

vzaliva commented 3 years ago

I narrowed down bold handling to syntax parsing problem in org syntax. I've tried all themes on example above and none of them highlights bold. However changing it a little by adding some symbols before "bold" makes it work. This is example which does show bold in org mode:

Org-mode test:
* Section
** Sub-section
*** Sub-sub-section
    normal
    /italic/
    This is *bold*
    ~verbatim~