Skip to content

Cannot remove newlines between tags even with options #310

@TrofinSorin

Description

@TrofinSorin

Minimal HTML example

<h1>1</h1>
<h1>2</h1>
<h1>3</h1>

Options

{
        wordwrap: false,
        preserveNewlines: false,
        selectors: [
          { selector: 'p', options: { leadingLineBreaks: 0, trailingLineBreaks: 0 } },
          { selector: 'h1', options: { leadingLineBreaks: 0, trailingLineBreaks: 0 } },
          { selector: 'h2', options: { leadingLineBreaks: 0, trailingLineBreaks: 0 } },
          { selector: 'h3', options: { leadingLineBreaks: 0, trailingLineBreaks: 0 } },
        ]
      }

Observed output
Before the selector options there were 2 newlines. But with those options it's reduced to one newline.

1
(newline here)
2
(newline here)
3

Expected output

I want this output without newlines

1
2
3

The same as inside wysiwig, without newlines but H1

Version information

  • html-to-text: 9.0.5
  • node: 18.19.0

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