Markdown filter drop spaces in code block

Issue #704 new
Kuro Kurosaka created an issue

When a Markdown file contains a fenced code block of multiple lines in a list item as in:

4. Start blockquote

   ```
   Fenced code line 1
   Fenced code line 2
   Fenced code line 3
   ```

the second and following lines loses the leading spaces when it is merged.

It turned out the code block does not need to be part of a list item. The fence can have up to 3 lead spaces even when it is not part of a list item. Those spaces and spaces in the code lines are lost when merged. See fenced-code-block.md.

And finally, there are similar problem with indented code block. The situation is more serious here because the lead spaces that are part of the code are missing. For example:

    There is no space on this line as content of the code.
      There should be two lead spaces here.
        And four spaces here.

This becomes:

    There is no space on this line as content of the code.
    There should be two lead spaces here.
    And four spaces here.

and it will be rendered differently than the original markdown file. See indented-code-block.md.

Comments (4)

  1. Kuro Kurosaka reporter

    All newlines in the code block are replaced by a placeholder in XLIF without real newline.

        Indented code line 1
        Indented code line 2
    

    becomes:

    <x id="1"/>Indented code line 1<x id="2"/><x id="3"/>Indented code line 2<x id="4"/>
    

    in the source and target elements. This is very difficult for the translator to translate as it has lose the visual cue. This would have been better:

    <x id="1"/>Indented code line 1
    <x id="3"/>Indented code line 2
    

    This would be the best, of course, but this probably requires a custom Skeleton and a SkeletonWriter:

    Indented code line 1
    Indented code line 2
    
  2. Log in to comment