slides icon indicating copy to clipboard operation
slides copied to clipboard

Line breaks (new line) are not working

Open electriquo opened this issue 2 years ago • 8 comments

Describe the bug 2 consecutive lines are being displayed in the same line, rather then in a separate lines In some cases Slides does not honor new line as one expects, e.g. on lists.

To Reproduce Steps to reproduce the behavior:

$ echo '
line 1
line 2
' | slides

outputs

line 1 line 2

and

echo '
- list 1

- list 2
' | slides

outputs

• list 1
• list 2

Expected behavior A new line needs to be displayed in a new line, e.g. giving the inputs above, the outputs should look like (respectively)

line 1
line 2

and

• list 1

• list 2

Desktop (please complete the following information):

  • OS: MacOS
  • Version: 13.3.1

electriquo avatar May 04 '23 07:05 electriquo

With regular text, the behavior you expect appears to be consistent with hard line breaks, but I found that slides does not seem to respect the two extra whitespaces or backslash methods mentioned in the GFM spec. I found an open issue for the lack of line breaks on whitespace on an upstream repo: https://github.com/charmbracelet/glamour/issues/84. I found that inserting an "extra" line of whitespace worked got the desired result.

I can confirm the odd list behavior on slides 0.9.0 (Ubuntu 22.04.02). The list rendering behavior does not appear consistent with GFM - any number of empty lines between list items does not result in a line break between the two lists.

There are several issues in glamour that mention broken lists (https://github.com/charmbracelet/glamour/issues/239, https://github.com/charmbracelet/glamour/issues/167) but they do not seem to describe our issue here exactly. Perhaps another issue upstream is warranted?

hugginsio avatar Jul 27 '23 01:07 hugginsio

@hugginsio i do not know go and don't know how to transform this issue to a glamour issue. since you know all the details, maybe you could assist doing that :)

electriquo avatar Jul 27 '23 05:07 electriquo

@hugginsio friendly ping

electriquo avatar Oct 13 '23 16:10 electriquo

Quick context note and a workaround: Be advised the reason for your initial example to not render a linebreak is that markdown is designed to allow for Semantic Line Breaks, which is why the other syntaxes for explicitly requesting hard breaks exist.

It's unfortunate that Glamour doesn't support hard break syntax yet even after a 4+ year old issue. I wanted to render a few short lines with hard breaks, so as a workaround I just wrapped the lines in triple-backticks to treat them as a code block.

NReilingh avatar Apr 30 '24 21:04 NReilingh

as a workaround I just wrapped the lines in triple-backticks to treat them as a code block.

@NReilingh could you share an example?

electriquo avatar May 01 '24 07:05 electriquo

@electriquo Try this:

```
Line one
Line two
Line three
```

It won't render anything special like bold or emphasis, but if you just want text (like an address block for example) it looks fine.

NReilingh avatar May 01 '24 15:05 NReilingh

Thanks. That's basically just a code block, which loses most of the Markdown power. I wish this issue will be fixed since new line so fundamental in writings.

electriquo avatar May 01 '24 16:05 electriquo

@electriquo Same. I find it very disappointing that Glamour, a library whose only job is to render markdown in the terminal, falls so short so quickly (in my first use of Slides, I started running into glamour issues basically on line 2 of my markdown file).

Makes me wonder if a better approach would be a spec-compliant markdown to HTML converter pipelined to a terminal HTML renderer.

Don't want my disappointment to reflect badly on @maaslalani -- I'm loving every part of this project that you've put together!

NReilingh avatar May 01 '24 17:05 NReilingh