diff options
| author | Arun Isaac | 2026-07-23 16:19:45 +0100 |
|---|---|---|
| committer | Arun Isaac | 2026-07-23 16:19:45 +0100 |
| commit | 0178c9c2a052578dc7bbebfba3588f54846b0e05 (patch) | |
| tree | 973341d737b979104902764ec669bd6dca26d60f | |
| parent | 2d1144131b43f6bb1977587d59ca90cc2a7b3f10 (diff) | |
| download | ccwl-0178c9c2a052578dc7bbebfba3588f54846b0e05.tar.gz ccwl-0178c9c2a052578dc7bbebfba3588f54846b0e05.tar.lz ccwl-0178c9c2a052578dc7bbebfba3588f54846b0e05.zip | |
| -rw-r--r-- | ccwl/yaml.scm | 7 | ||||
| -rw-r--r-- | tests/yaml.scm | 8 |
2 files changed, 12 insertions, 3 deletions
diff --git a/ccwl/yaml.scm b/ccwl/yaml.scm index cc27be4..9ccd946 100644 --- a/ccwl/yaml.scm +++ b/ccwl/yaml.scm @@ -1,5 +1,5 @@ ;;; ccwl --- Concise Common Workflow Language -;;; Copyright © 2021, 2023 Arun Isaac <arunisaac@systemreboot.net> +;;; Copyright © 2021, 2023, 2026 Arun Isaac <arunisaac@systemreboot.net> ;;; ;;; This file is part of ccwl. ;;; @@ -57,10 +57,13 @@ serialized to YAML. Else, return @code{#f}." ;; string can therefore be misinterpreted as a number ;; - string contains indicator characters as mentioned in the YAML ;; spec https://yaml.org/spec/1.2.2/#53-indicator-characters + ;; - string contains whitespace characters other than space (if (or (string-every (char-set-union char-set:digit (char-set #\.)) atom) (string-any (char-set #\- #\? #\: #\, #\[ #\] #\{ #\} #\# #\& #\* #\! #\| #\> #\' #\" #\% #\@ #\`) - atom)) + atom) + (and (string-any char-set:whitespace atom) + (not (string-any #\space atom)))) (write atom port) (display atom port))) ((boolean? atom) diff --git a/tests/yaml.scm b/tests/yaml.scm index f9df12d..c475dd9 100644 --- a/tests/yaml.scm +++ b/tests/yaml.scm @@ -1,5 +1,5 @@ ;;; ccwl --- Concise Common Workflow Language -;;; Copyright © 2021, 2023 Arun Isaac <arunisaac@systemreboot.net> +;;; Copyright © 2021, 2023, 2026 Arun Isaac <arunisaac@systemreboot.net> ;;; ;;; This file is part of ccwl. ;;; @@ -41,6 +41,12 @@ bar: {} " (scm->yaml-string #("*foo" "*bar"))) +(test-equal "strings with whitespace characters other than space must be escaped" + "- \"foo\\nbar\" +- \"foo\\tbar\" +" + (scm->yaml-string #("foo\nbar" "foo\tbar"))) + (test-equal "single element vectors must be serialized on the same line" "[foo] " |
