big tings

This commit is contained in:
Max Richter
2025-08-17 15:16:17 +02:00
parent 40b9be887d
commit c687eff53d
958 changed files with 32279 additions and 704 deletions

31
parser/decoders/list.go Normal file
View File

@@ -0,0 +1,31 @@
package decoders
import (
"fmt"
"strings"
"git.max-richter.dev/max/marka/parser/matcher"
"git.max-richter.dev/max/marka/template"
)
func List(input string, block template.Block) (value any, error error) {
blocks, err := template.CompileTemplate(block.ListTemplate)
if err != nil {
return nil, fmt.Errorf("cannot extract blocks: %w", err)
}
var out []any
for line := range strings.SplitSeq(strings.TrimSuffix(input, "\n"), "\n") {
matches := matcher.MatchBlocksFuzzy(line, blocks, 0.3)
res, err := Parse(matches)
if err != nil {
return nil, fmt.Errorf("could not match blocks: %w", err)
}
out = append(out, res)
}
return out, nil
}