aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTeddy Wing2023-04-21 21:08:01 +0200
committerTeddy Wing2023-04-21 21:08:58 +0200
commit85a325bb00831a5237b57f2851835655f7a7c5b1 (patch)
treef01886480c1fa25e3c6cd062f89b3fb37f0df355
parentc056748c337384aa6f3b9eb8879d82f28df798ed (diff)
downloadxfdf-85a325bb00831a5237b57f2851835655f7a7c5b1.tar.bz2
field-xfdf*: Extract nested field handling to function
Move this logic to a named function. Adjust the names of the other string building functions to be more consistent now that I have this one which does something similar but at a different level.
-rw-r--r--src/xfdf.lisp34
1 files changed, 19 insertions, 15 deletions
diff --git a/src/xfdf.lisp b/src/xfdf.lisp
index a3ada7b..59a032a 100644
--- a/src/xfdf.lisp
+++ b/src/xfdf.lisp
@@ -44,23 +44,27 @@ amount of indentation to use relative to the +field-base-indentation+."
(if (consp value)
;; TODO: We need to do something with value
;; TODO: How to concat results from dolist?
- (let ((inner-fields
- (loop for field in value
- collect
- (let ((subname (if (listp field)
- (first field)
- field))
- (subfield (if (listp field)
- (rest field)
- field)))
- (field-xfdf* subname subfield (1+ nesting-level))))))
- (build-xfdf-outer-field name inner-fields indent))
+ (build-xfdf-nested-field name value nesting-level indent)
;; TODO: Put checkbox stuff here.
(let ((value (pdf-checkbox-value value)))
- (build-xfdf-field name value indent)))))
+ (xfdf-field-string name value indent)))))
;; * (format t "~v{~A~:*~}<>~A" 5 '("Hello") "Next")
+(defun build-xfdf-nested-field (name value nesting-level indent)
+ "Build the XFDF XML for a field containing other fields."
+ (let ((inner-fields
+ (loop for field in value
+ collect
+ (let ((subname (if (listp field)
+ (first field)
+ field))
+ (subfield (if (listp field)
+ (rest field)
+ field)))
+ (field-xfdf* subname subfield (1+ nesting-level))))))
+ (xfdf-outer-field-string name inner-fields indent)))
+
(defun pdf-checkbox-value (value)
"If `value` is T or NIL, convert it to the default PDF checkbox values
'Yes' and 'Off' respectively.
@@ -71,8 +75,8 @@ If `value` is anything else, return its identity."
((eq value nil) "Off")
(t value)))
-(defun build-xfdf-outer-field (name inner-fields-string indent)
- "Build the XFDF XML for a field containing other fields."
+(defun xfdf-outer-field-string (name inner-fields-string indent)
+ "Build the XFDF XML string for a field containing other fields."
(format nil "~
~v{~A~:*~}<field name=\"~A\">
~{~A~}~v{~A~:*~}</field>
@@ -84,7 +88,7 @@ inner-fields-string
indent
'(" ")))
-(defun build-xfdf-field (name value indent)
+(defun xfdf-field-string (name value indent)
"Build the XFDF XML for a single field."
(format nil "~
~v{~A~:*~}<field name=\"~A\">