[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/yaml d8ac09e8ca 053/124: Merge pull request #11 from zk
From: |
ELPA Syncer |
Subject: |
[elpa] externals/yaml d8ac09e8ca 053/124: Merge pull request #11 from zkry/fix-encoding-nil-false-arrays |
Date: |
Fri, 29 Nov 2024 16:00:00 -0500 (EST) |
branch: externals/yaml
commit d8ac09e8cad7f67339e19c53e77da1cd0ff98d36
Merge: a45f60c999 64c117d084
Author: Zachary Romero <zacromero@posteo.net>
Commit: GitHub <noreply@github.com>
Merge pull request #11 from zkry/fix-encoding-nil-false-arrays
Fix encoding issues for nil, false, and arrays
---
yaml-tests.el | 22 +++++++++++++++++++++-
yaml.el | 18 ++++++++++++++++--
2 files changed, 37 insertions(+), 3 deletions(-)
diff --git a/yaml-tests.el b/yaml-tests.el
index 67e0805b90..aee8f78246 100644
--- a/yaml-tests.el
+++ b/yaml-tests.el
@@ -512,11 +512,31 @@ keep: |+
("nested-map" . ((1 . 2) (3 . 4) (5 . 6)))
("nested-list" . (1 2 3 4 5)))
("nested" "list" 1 2 3))))
+ (should (yaml-test-round-trip
+ '("one" t nil :false)))
(should (yaml-test-round-trip
'(t nil)))
+ (should (yaml-test-round-trip
+ [1 2 3 4]))
(should (yaml-encode
'((("aaaa" "bbbb" "cccc") ("dddd" "eeee" "ffff") ("gggg" "hhhh"
"iiii"))
- ("jjjj" "kkkk" "llll") ("mmmm" "nnnn" "oooo") ("pppp" "qqqq"
"rrrr")))))
+ ("jjjj" "kkkk" "llll") ("mmmm" "nnnn" "oooo") ("pppp" "qqqq"
"rrrr"))))
+ (should (yaml-encode
+ '(("aaaa" "bbbb" "cccc" ("dddd" "eeee" "ffff") ("gggg" "hhhh"
"iiii"))
+ ("jjjj" "kkkk" "llll") ("mmmm" "nnnn" "oooo") ("pppp" "qqqq"
"rrrr"))))
+
+ (should (equal
+ (yaml-encode :null)
+ "null"))
+ (should (equal
+ (yaml-encode :false)
+ "false"))
+ (should (equal
+ (yaml-encode nil)
+ "null"))
+ (should (equal
+ (yaml-encode [1 2 3])
+ "[1, 2, 3]")))
(provide 'yaml-tests)
diff --git a/yaml.el b/yaml.el
index aa9c812f75..a858a82d76 100644
--- a/yaml.el
+++ b/yaml.el
@@ -2371,6 +2371,7 @@ without first inserting a newline."
((yaml--scalarp object) (yaml--encode-scalar object))
((hash-table-p object) (yaml--encode-hash-table object indent auto-indent))
((listp object) (yaml--encode-list object indent auto-indent))
+ ((arrayp object) (yaml--encode-array object indent auto-indent))
(t (error "Unknown object %s" object))))
(defun yaml--scalarp (object)
@@ -2389,14 +2390,27 @@ without first inserting a newline."
(s (replace-regexp-in-string "\"" "\\\\\"" s)))
s))
+(defun yaml--encode-array (a indent &optional auto-indent)
+ "Encode array A to a string in the context of being INDENT deep.
+
+If AUTO-INDENT is non-nil, start the list on the current line,
+auto-detecting the indentation. Functionality defers to
+`yaml--encode-list'."
+ (yaml--encode-list (seq-map #'identity a)
+ indent
+ auto-indent))
(defun yaml--encode-scalar (s)
"Encode scalar S to buffer."
(cond
- ((not s) (insert "nil"))
+ ((not s) (insert "null"))
((eql t s) (insert "true"))
- ((symbolp s) (insert (symbol-name s)))
+ ((symbolp s)
+ (cond
+ ((eql s :null) (insert "null"))
+ ((eql s :false) (insert "false"))
+ (t (insert t))))
((numberp s) (insert (number-to-string s)))
((stringp s)
(if (string-match "\\`[-_a-zA-Z0-9]+\\'" s)
- [elpa] externals/yaml 368452c534 064/124: Add test case for issue, (continued)
- [elpa] externals/yaml 368452c534 064/124: Add test case for issue, ELPA Syncer, 2024/11/29
- [elpa] externals/yaml d82bfb523e 059/124: fix testcases, ELPA Syncer, 2024/11/29
- [elpa] externals/yaml af49540f53 107/124: Use cl-defun &key to allow eldoc argument hints to work better, ELPA Syncer, 2024/11/29
- [elpa] externals/yaml 01a12f2345 118/124: Merge pull request #50 from rdrg109/master, ELPA Syncer, 2024/11/29
- [elpa] externals/yaml fe08b8f530 120/124: Merge pull request #52 from zkry/51-fix-failing-test, ELPA Syncer, 2024/11/29
- [elpa] externals/yaml a19fbf948a 112/124: Merge pull request #46 from zkry/45-fix-char-escape, ELPA Syncer, 2024/11/29
- [elpa] externals/yaml 7f09102db0 115/124: Remove leading new-lines for yaml-encode, ELPA Syncer, 2024/11/29
- [elpa] externals/yaml 276596561a 032/124: Fix explicit document end on ns-plain, ELPA Syncer, 2024/11/29
- [elpa] externals/yaml c215bf7a33 083/124: add function for generating parse with metadata strings, ELPA Syncer, 2024/11/29
- [elpa] externals/yaml f374a7f17e 013/124: indentation indicator bug fix, ELPA Syncer, 2024/11/29
- [elpa] externals/yaml d8ac09e8ca 053/124: Merge pull request #11 from zkry/fix-encoding-nil-false-arrays,
ELPA Syncer <=
- [elpa] externals/yaml bdfaa8ce55 101/124: Merge pull request #40 from zkry/fix-block-indent-detection, ELPA Syncer, 2024/11/29
- [elpa] externals/yaml 69654c291f 090/124: Fix string values state bug, ELPA Syncer, 2024/11/29
- [elpa] externals/yaml 01ab8d1910 078/124: Merge pull request #30 from zkry/29-fix-list-encoding-indentation, ELPA Syncer, 2024/11/29
- [elpa] externals/yaml 9382bf5a3b 070/124: Merge pull request #25 from zkry/fix-lines-longer-than-80, ELPA Syncer, 2024/11/29
- [elpa] externals/yaml 34c300b085 075/124: Merge pull request #28 from tarsiiformes/nil, ELPA Syncer, 2024/11/29
- [elpa] externals/yaml 7f055d207c 057/124: Merge pull request #17 from conao3/plist-keyword, ELPA Syncer, 2024/11/29
- [elpa] externals/yaml b0d95e7e81 066/124: Use `alist-get` to converting alist to hash table, ELPA Syncer, 2024/11/29
- [elpa] externals/yaml c3988d10e2 098/124: store current indent level and use that for basis of block indent, ELPA Syncer, 2024/11/29
- [elpa] externals/yaml 94ea32ecb7 103/124: version bump, ELPA Syncer, 2024/11/29
- [elpa] externals/yaml ee34639c96 105/124: Update docstring and README to match current behavior, ELPA Syncer, 2024/11/29