Skip to content

fenced code blocks lose blank-line runs and trailing spaces during conversion #2528

Description

what happens

converting markdown through MarkItDown corrupts fenced code blocks:

  • two or more consecutive blank lines inside a fence collapse to one
  • trailing spaces on lines inside a fence get stripped
def a():
    pass


def b():
    pass

comes back with the double blank line gone, and line with trailing spaces loses its spaces.

why

the result normalization (rstrip each line, collapse 3+ newline runs) runs over the whole document with no awareness of code fences, so it mangles content where whitespace is significant.

expected

whitespace inside fenced code blocks (``` or ~~~) survives exactly; normalization still applies to prose outside fences.

env: main 945314a

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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