Skip to content

fix(ansi): don't emit a blank line per nesting level after nested lists - #587

Open
larrasket wants to merge 1 commit into
charmbracelet:mainfrom
larrasket:fix-nested-list-trailing-blank
Open

fix(ansi): don't emit a blank line per nesting level after nested lists#587
larrasket wants to merge 1 commit into
charmbracelet:mainfrom
larrasket:fix-nested-list-trailing-blank

Conversation

@larrasket

Copy link
Copy Markdown

A nested list rendered as a BlockElement with Newline set, when a list ended in a nested sub-list, each stacked level added its own blank line, so the number of blank lines after the last item grew with the nesting depth. this suppress the trailing newline for a nested list that is the last item of its parent list item.

Fixes #102

  • I have read CONTRIBUTING.md.
  • I have created a discussion that was approved by a maintainer (for new features).

A nested list rendered as a BlockElement with Newline set, so it emitted
a trailing blank line on finish. When a list ended in a nested sub-list,
each stacked level added its own blank line, so the number of blank lines
after the last item grew with the nesting depth.

Suppress the trailing newline for a nested list that is the last item of
its parent list item, so exactly one blank line follows the list
regardless of nesting depth.

Fixes charmbracelet#102
@meowgorithm

Copy link
Copy Markdown
Member

Hi! Thanks for the contribution. Mind illustrating the problem you're having and how this PR fixes it? A short, human-authored explanation will go a long way.

@larrasket

Copy link
Copy Markdown
Author

when a list is in a nested sublist, one extra blank line is added per level of nesting before the content. for example two levels of nesting looks like this;

  - one
  - two
      - a
      - b

              [blank here]

it is not really annoying with a single sublist but it becomes much worse if you have more deep nested levels. This happens because a nested list is emitted as a block with a trailing newline. When a nested list is the last thing inside its parent list item, each of the rest of the levels adds its trailing newline. my fix suppresses that trailing newline when the list is the last item of its parent item..

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.

Extra space after nested list items

2 participants