mirror of
https://github.com/cjdenio/crossword.git
synced 2026-10-03 11:06:19 +00:00
handle line breaks in clues
This commit is contained in:
5 files changed
+70
-12
No files matched your search
@@ -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
|
||||
|
||||
Reference in new issue
Block a user