Skip to content

Behavior with strip_pre=mdfy.STRIP_ONE seems incorrect with trailing newlines within the pre #255

@stevecj

Description

@stevecj
In [1]: import markdownify as mdfy

In [2]: converter = mdfy.MarkdownConverter(strip_pre=mdfy.STRIP_ONE)

In [3]: print(converter.convert('<pre>\n\nabc\n\n</pre>'))
```

abc
```

Only one trailing newline should be stripped, not both. right?

In [4]: print(converter.convert('<pre>\n\nabc\n\n\n</pre>'))
```

abc

```

In the above, 2 of the 3 newlines are trimmed instead of just 1.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions