Closed jba closed 7 years ago
I think this would be an interesting feature to be added, but I'd personally would make it a flag of the embedmd
comment rather than the program itself.
Maybe something like:
[embedmd]:# (pathOrURL /start regexp/ /end regexp/ OMIT_MATCHING_LINES)
In your case this would look like:
[embedmd]:# (main.go /START AUTH/ /END AUTH/ OMIT_MATCHING_LINES)
Does that seem good?
Actually, I'm thinking it could be two different flags:
OMIT_MATCH
: the text matching the regexp is omitted
MATCH_LINES
: the match is expanded to include the whole line (basically adds .*
and the beginning of the start regexp and at the end of the end regexp)
So, given:
// START AUTH
client, err := storage.NewClient(ctx)
// END AUTH
[embedmd]:# (main.go /START AUTH/ /END AUTH/)
gives
START AUTH
client, err := storage.NewClient(err)
// END AUTH
[embedmd]:# (main.go /START AUTH/ /END AUTH/ MATCH_LINES)
gives
// START AUTH
client, err := storage.NewClient(err)
// END AUTH
[embedmd]:# (main.go /START AUTH/ /END AUTH/ OMIT_MATCH)
gives
client, err := storage.NewClient(err)
//
[embedmd]:# (main.go /START AUTH/ /END AUTH/ OMIT_MATCH MATCH_LINES)
gives
client, err := storage.NewClient(err)
MATCH_LINES
is not needed, since the equivalent behavior can be accomplished by transforming /start/ /end/
into /.*start/ /end.*/
. So I'd recommend implementing OMIT_MATCH
first, then reassess if MATCH_LINES
is needed.
We decided to go a different way, so we no longer need this feature. Sorry for the noise.
@campoy this feature idea seems good, and it would be useful for me and for others as well. Do you plan to make it?
I would like to use a single file containing many nondescript snippets like
Currently the regexps used to match will appear in the output, forcing me to use regexps that are fragile (may match multiple snippets, may fail to match if I change the snippet).
I'd rather write
So I can match the markers but not have them in the output.
I propose a
-x
flag that provides this behavior.