kevin940726 / remark-code-import

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

Add ability to specify specific line or line blocks #7

Closed ostollmann closed 3 years ago

ostollmann commented 3 years ago

Close #3

This adds the possibility to specify specific lines to be imported:

```js file=./__fixtures__/say-hi.js#L2


Note: couldn't get yarn to work, but tests passed using npm.
ostollmann commented 3 years ago

Thank you for creating this PR!

Np. I want to use it :)

What do you think if we also support #L3: pattern to slice the file from line 3 to the very end? I think it could be a very common use case when all the user wants is to strip out the import statements.

That's a good idea. I added the ability to do both:

Just being curious, where do you know of this pattern #Ls:Ln? I feel like we can try to follow what GitHub does and use - to replace :. #L3- is also slightly more readable to me too.

I wanted to do what Github does and thought they used ?:?. Should have checked. Changed to ?-? now.

ostollmann commented 3 years ago

I also added this to the readme.

kevin940726 commented 3 years ago

I just want to let you know that I've been a little bit busy lately, and I'll get back to it as soon as I have some time. Thank you for all the good work and your patience :)