Drop legacy pattern check

This commit is contained in:
Manuel Rüger 2024-07-25 23:48:48 +02:00
parent f727c860b4
commit 7991fe4c10

View File

@ -3,7 +3,6 @@ package mark
import ( import (
"bufio" "bufio"
"bytes" "bytes"
"fmt"
"regexp" "regexp"
"strings" "strings"
@ -41,7 +40,6 @@ const (
) )
var ( var (
reHeaderPatternV1 = regexp.MustCompile(`\[\]:\s*#\s*\(([^:]+):\s*(.*)\)`)
reHeaderPatternV2 = regexp.MustCompile(`<!--\s*([^:]+):\s*(.*)\s*-->`) reHeaderPatternV2 = regexp.MustCompile(`<!--\s*([^:]+):\s*(.*)\s*-->`)
reHeaderPatternMacro = regexp.MustCompile(`<!-- Macro: .*`) reHeaderPatternMacro = regexp.MustCompile(`<!-- Macro: .*`)
) )
@ -64,23 +62,13 @@ func ExtractMeta(data []byte, spaceFromCli string, titleFromH1 bool, parents []s
matches := reHeaderPatternV2.FindStringSubmatch(line) matches := reHeaderPatternV2.FindStringSubmatch(line)
if matches == nil { if matches == nil {
matches = reHeaderPatternV1.FindStringSubmatch(line) matches = reHeaderPatternMacro.FindStringSubmatch(line)
if matches == nil { // If we have a match, then we started reading a macro.
matches = reHeaderPatternMacro.FindStringSubmatch(line) // We want to keep it in the document for it to be read by ExtractMacros
// If we have a match, then we started reading a macro. if matches != nil {
// We want to keep it in the document for it to be read by ExtractMacros offset -= len(line) + 1
if matches != nil {
offset -= len(line) + 1
}
break
} }
break
log.Warningf(
fmt.Errorf(`legacy header usage found: %s`, line),
"please use new header format: <!-- %s: %s -->",
matches[1],
matches[2],
)
} }
if meta == nil { if meta == nil {