kevin940726 / remark-code-import

📝 Populate code blocks from files
https://npm.im/remark-code-import
MIT License
62 stars 11 forks source link

If the first imported line start with an indentation, the indentation is stripped #14

Closed MangelMaxime closed 2 years ago

MangelMaxime commented 2 years ago

Hello,

I am importing the file content via ./../demo/src/Demo.fs#L15-L16

Which correspond to these lines in my files:

    Tippy.create [
        Tippy.plugins [|

which generates:

image

As you can see, there is a "huge" indentation on the second line because the indentation on the first line has been stripped I believe.

If I use a first line without indentation, I get the expected result:

let Component () =
    Tippy.create [
        Tippy.plugins [|

gives:

image

kevin940726 commented 2 years ago

Good catch!

I just published v0.4.0 to fix this issue and include two additional options (preserveTrailingNewline and removeRedundantIndentations). Please see README for usages if you need them.

Thanks again!

MangelMaxime commented 2 years ago

Thank you for the quick fix.

I think removeRedundantIndentations is a really interesting option for some of my use cases.