markitdown icon indicating copy to clipboard operation
markitdown copied to clipboard

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

Open ManoharPaturi opened this issue 2 months ago • 0 comments

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

ManoharPaturi avatar Sep 18 '26 11:09 ManoharPaturi