From f40ea60f4d767c2ce84a41ca6989750534dee3f7 Mon Sep 17 00:00:00 2001 From: Teddy Wing Date: Sun, 16 Apr 2023 20:30:36 +0200 Subject: Output XFDF fields into XML Write `` elements to the XFDF XML based on the cons cells in the `fields` input list. Change true and nil values to the FDF/XFDF checkbox value format of "Yes" and "Off". Also decided to use lowercase `t` to match the case of `nil`. Not sure if that makes sense. --- src/xfdf.lisp | 21 ++++++++++----------- test/xfdf.lisp | 2 +- 2 files changed, 11 insertions(+), 12 deletions(-) diff --git a/src/xfdf.lisp b/src/xfdf.lisp index a61fcdd..fd8c8b7 100644 --- a/src/xfdf.lisp +++ b/src/xfdf.lisp @@ -7,18 +7,17 @@ ") - ;; TODO - ; (loop do) - (format output-stream " - Yes + (loop for (name . value) in fields + do + (let ((value (cond ((eq value t) "Yes") + ((eq value nil) "Off") + (t value)))) + (format output-stream " + ~A - - Off - - - 123 Fake Street, Springfield - -") +" +name +value))) (format output-stream " ") diff --git a/test/xfdf.lisp b/test/xfdf.lisp index 87accaf..31af6a3 100644 --- a/test/xfdf.lisp +++ b/test/xfdf.lisp @@ -16,7 +16,7 @@ (with-output-to-string (xfdf-stream) (xfdf:write-xfdf xfdf-stream - '(("checkbox-on" . T) + '(("checkbox-on" . t) ("checkbox-off" . nil) ("text" . "123 Fake Street, Springfield")))))) (is (string= -- cgit v1.2.3