markdown-magic icon indicating copy to clipboard operation
markdown-magic copied to clipboard

Feature Request: Comment range

Open nyan-left opened this issue 3 years ago • 2 comments

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.

nyan-left avatar Aug 11 '21 11:08 nyan-left

Hey @nyan-left

I like this idea! Happy to review this as PR

DavidWells avatar Sep 29 '21 18:09 DavidWells

Shall send it through early next week :)

nyan-left avatar Oct 01 '21 16:10 nyan-left