1
0
Fork 0

- fixed parsing of gempub metadata.

This commit is contained in:
cage 2024-09-22 14:47:32 +02:00
parent 315b18a7d8
commit ec2f480b25
1 changed files with 10 additions and 3 deletions

View File

@ -57,8 +57,12 @@
gempub-version
gempub-cover))
(defrule gempub-entry (and gempub-key (? gempub-blanks) gempub-key-value-separator
(? gempub-blanks) gempub-value #\NewLine)
(defrule linebreak (or #\NewLine #\Return))
(defrule gempub-entry (or (and gempub-key (? gempub-blanks) gempub-key-value-separator
(? gempub-blanks) gempub-value (+ linebreak))
(and gempub-key (? gempub-blanks) gempub-key-value-separator
(? gempub-blanks) gempub-value))
(:function (lambda (a) (list (first a) (fifth a)))))
(defrule gempub-metadata (* gempub-entry)
@ -79,7 +83,10 @@
(when (find +metadata-entry-name+ entries :test #'String=)
(when-let ((metadata-raw (os-utils:unzip-single-file zip-file
+metadata-entry-name+)))
(parse 'gempub-metadata metadata-raw))))))
(handler-case
(parse 'gempub-metadata metadata-raw)
(error (e)
(error "Error parsing metadata from file ~s: ~a" zip-file e))))))))
(defun save-metadata (zip-file)
(when-let ((metadata (extract-metadata zip-file)))