DavidWells / markdown-magic

💫  Automatically format markdown files via comment blocks using source code, external data & custom transforms.
817 stars 227 forks source link

Feature Request: Comment range #54

Open nyan-left opened 3 years ago

nyan-left commented 3 years ago

Currently the code injection allows you to specify lines of code from a file:

 <!-- AUTO-GENERATED-CONTENT:START (CODE:src=./relative/path/to/code.js&lines=22-44) -->
 This content will be dynamically replaced with code from the file lines 22 through 44
 <!-- AUTO-GENERATED-CONTENT:END -->

This can be dificult to maintain as line numbers are subject to change with API changes. An easier way to do this would be to select between specified comment blocks. Here's a simple example:

 <!-- AUTO-GENERATED-CONTENT:START (CODE:src=./relative/path/to/code.js&block=BLOCK1) -->
 This content will be dynamically replaced with code (from the file) found between comments containing "BLOCK1".
 <!-- AUTO-GENERATED-CONTENT:END -->

code.js :

// ...

// <BLOCK1>
console.log("This will get selected");
// </BLOCK1>

Happy to help out with a PR.

DavidWells commented 3 years ago

Hey @nyan-left

I like this idea! Happy to review this as PR

nyan-left commented 3 years ago

Shall send it through early next week :)