fix: some bug

This commit is contained in:
Max Richter
2025-09-28 20:08:21 +02:00
parent 57ea1f6e3e
commit d35f3e5e2e
5 changed files with 24 additions and 15 deletions

View File

@@ -26,9 +26,6 @@ func DetectType(markdownContent string) (string, error) {
blocks := matcher.MatchBlocksFuzzy(markdownContent, defaultSchema, 0.3)
fmt.Printf("%+v\n", blocks[0])
fmt.Printf("Content: '%q'\n", blocks[0].GetContent())
result, err := decoders.Parse(blocks)
if err != nil {
return "", fmt.Errorf("failed to parse blocks -> %w", err)
@@ -84,6 +81,12 @@ func ParseFile(markdownContent string) (any, error) {
startMarkdown := time.Now()
blocks := matcher.MatchBlocksFuzzy(markdownContent, tpl, 0.3)
fmt.Println("Blocks: ", len(blocks))
for i, b := range blocks {
fmt.Printf("Block %d %+v\n", i, b)
fmt.Printf("Content %d: %q\n\n", i, b.GetContent())
}
result, err := decoders.Parse(blocks)
if err != nil {
return nil, fmt.Errorf("failed to parse blocks -> %w", err)

View File

@@ -18,12 +18,14 @@ func TestParseRecipe_Golden(t *testing.T) {
t.Fatalf("ParseFile: %v", err)
}
gotMap := got.(map[string]any)
var want map[string]any
if err := json.Unmarshal(output, &want); err != nil {
t.Fatalf("unmarshal expected.json: %v", err)
}
if diff := cmp.Diff(want, got); diff != "" {
if diff := cmp.Diff(want, gotMap["data"]); diff != "" {
t.Fatalf("JSON mismatch (-want +got):\n%s", diff)
}
}