handle line breaks in clues

This commit is contained in:
cjdenio committed 2026-09-29 13:47:29 -04:00
1 parent 21f9caec34
commit c139490dc2
5 files changed
+70 -12

No files matched your search

+8
View File
@@ -3,6 +3,7 @@ package puz
import (
"encoding/json"
"errors"
"slices"
"strconv"
"strings"
)
@@ -16,6 +17,7 @@ type iPuzClue struct {
Clue string `json:"clue"`
}
type iPuzFile struct {
Kind []string `json:"kind"`
Title string `json:"title"`
Author string `json:"author"`
Copyright string `json:"copyright"`
@@ -32,6 +34,12 @@ func ParseIPuz(file []byte) (*Puzzle, error) {
return nil, err
}
if len(parsed.Kind) == 0 || !slices.ContainsFunc(parsed.Kind, func(k string) bool {
return strings.HasPrefix(k, "http://ipuz.org/crossword")
}) {
return nil, errors.New("ipuz file is not a crossword")
}
puzzle := new(Puzzle)
puzzle.Title = parsed.Title