-
Notifications
You must be signed in to change notification settings - Fork 64
Description
I would like to be able to write some substitutions / transformations for the outputted text produced by embedmd.
Use case: Include example_test.go in readme, but replace package my_test with package main and func Example with func main.
This could be expressed as s/find/replace/, and when used in practice:
[embedmd]:# (example_test.go s/^package .*_test$/package main/)Due to the s-prefix we can differentiate this from start / end and allow multiple occurances:
OK: [embedmd]:# (pathOrURL language s/find/replace/ /start regexp/ /end regexp/)
OK: [embedmd]:# (pathOrURL language s/find/replace/ s/find2/replace2/ /start regexp/ /end regexp/)
OK: [embedmd]:# (pathOrURL language /start regexp/ /end regexp/ s/find/replace/)
ERROR: [embedmd]:# (pathOrURL language /start regexp/ s/find/replace/ /end regexp/)
Thoughts?
EDIT: I don't mind implementing if this is accepted.
EDIT 2: For reference, an alternative (with go:generate and sed) can be seen here, but it's far from ideal.