Skip to content

Line wrapping does not work correctly when the text contains command-line options #407

@bingzhang00

Description

@bingzhang00

Describe the bug

Line wrapping does not work correctly when the text contains command-line options like --option-one, --option-two.

Setup

Please complete the following information along with version numbers, if applicable.

  • OS: macOS
  • Shell: zsh
  • Terminal Emulator: iterm2
  • Terminal Multiplexer: tmux

Source Code

package main

import (
	"fmt"
	"github.com/charmbracelet/glamour"
)

func main() {
	s := "This is a line with some command-line options like --option-one and --option-two and --option-three and many many many many many many many many many many many many many many many many many many many many words."
	out, _ := glamour.Render(s, "dark")
	fmt.Print(out)
}

Expected behavior

Lines should wrap correctly at around 80 characters, which is the default width.

Actual output

There were some extra line breaks. See the output below.


  This is a line with some command-line options like --option-one and --option-
  two
  and --option-three and many many many many many many many many many many
  many
  many many many many many many many many many words

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions