diff --git a/README.md b/README.md index 1e70b76..f288534 100644 --- a/README.md +++ b/README.md @@ -120,6 +120,9 @@ be replaced with specified template: --> ``` +**NOTE**: Make sure to define your macros after your metadata (Title/Space), +mark will stop processing metadata if it hits a Macro. + Capture groups can be defined in the macro's which can be later referenced in the `` using `${}` syntax, where `` is number of a capture group in regexp (`${0}` is used for entire regexp match), diff --git a/pkg/mark/markdown.go b/pkg/mark/markdown.go index 98576c0..ddea59f 100644 --- a/pkg/mark/markdown.go +++ b/pkg/mark/markdown.go @@ -345,7 +345,7 @@ func DropDocumentLeadingH1( // ExtractDocumentLeadingH1 will extract leading H1 heading func ExtractDocumentLeadingH1(markdown []byte) string { - h1 := regexp.MustCompile(`^#[^#]\s*(.*)\s*\n`) + h1 := regexp.MustCompile(`#[^#]\s*(.*)\s*\n`) groups := h1.FindSubmatch(markdown) if groups == nil { return "" diff --git a/pkg/mark/meta.go b/pkg/mark/meta.go index 2f1a301..416182b 100644 --- a/pkg/mark/meta.go +++ b/pkg/mark/meta.go @@ -34,8 +34,9 @@ type Meta struct { } var ( - reHeaderPatternV1 = regexp.MustCompile(`\[\]:\s*#\s*\(([^:]+):\s*(.*)\)`) - reHeaderPatternV2 = regexp.MustCompile(``) + reHeaderPatternV1 = regexp.MustCompile(`\[\]:\s*#\s*\(([^:]+):\s*(.*)\)`) + reHeaderPatternV2 = regexp.MustCompile(``) + reHeaderPatternMacro = regexp.MustCompile(`