Skip to content

For code blocks inside a custom tag, an extra indent is added to the final output. #499

Description

@Norlandz

For code blocks inside a custom tag, an extra indent is added to the final output.

eg:

html = `
<ms-code-block><pre>      <code><span class="hljs-comment"># Our data from the previous step</span>
target_token_id = <span class="hljs-number">12</span>
y[target_token_id] = <span class="hljs-number">1</span>
</code></pre>
</ms-code-block>
`;

Expect:

```
foo = bar
```

Actual:

    ```
foo = bar
```

This leads to an invalid code block in markdown.

  • Note:
    I tried to tweak the replacement function, but a lot of times it doesnt produce the output strictly.
    It seems its later reformatted again.
    The later reformat is somehow dependent on having leading space or not.
    eg:

    replacement: function (content, node, options) {
      // adding NN or not here changes the later reformat ...
      return 'NN\n\n' + fence + language + '\n' + code.replace(/\n$/, '') + '\n' + fence + '\n\n';
    },
    
  • Note:
    This is also related to the space gap I mention in
    Fail to detect coding block when there is a space gap between <pre> <code>. #498

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