Description
Feature request
It would be very convenient
- to import only a few lines of a file
- to specify the begin and end of the region to be imported by regular expressions
- to specify the lines to be highlighted by a regular expression
What problem does this feature solve?
If a file is big and only a few lines are interesting to demonstrate an idea, you could extract those lines easily.
When using regular expressions, you don't need to count line numbers and change them when inserting lines into the file. You could write regular expressions which match certain code lines or comments, e.g. /* start-snip */
.
What does the proposed API look like?
<<< @/filepath{from=reFrom, to=reTo, inclusive=[yes|no], highlight=reHighlight}
where reXXX
are regular expressions. Then the region to be extracted would start at the first match of reFrom
and end at the first following match of reTo
. If inclusive=yes
then the matching lines are included, otherwise excluded. All the lines in the region which match reHighlight
will be highlighted.
All properties should be optional:
- If
from
andto
are missing the whole file will be included - If
from
is given andto
is missingto
will be the end of the file regardless ofinclusive
- If
from
is missing andto
is given,from
will be the start of the file regardless ofinclusive
- The default value for
inclusive
isyes
. - If
highlight
is missing, nothing is highlighted.
How should this be implemented in your opinion?
By extending the current Import Code Snippet
Markdown functionality.
Are you willing to work on this yourself?**
I'm not proficient in Markdown extensions.