[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/yaml 276596561a 032/124: Fix explicit document end on n
From: |
ELPA Syncer |
Subject: |
[elpa] externals/yaml 276596561a 032/124: Fix explicit document end on ns-plain |
Date: |
Fri, 29 Nov 2024 15:59:56 -0500 (EST) |
branch: externals/yaml
commit 276596561ad7cb990dd941d11521a9cb8e5a5346
Author: Zachary Romero <zacromero@posteo.net>
Commit: Zachary Romero <zacromero@posteo.net>
Fix explicit document end on ns-plain
---
yaml-tests.el | 62 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-
yaml.el | 13 ++++++++++---
2 files changed, 71 insertions(+), 4 deletions(-)
diff --git a/yaml-tests.el b/yaml-tests.el
index d38a665b16..e409168d6f 100644
--- a/yaml-tests.el
+++ b/yaml-tests.el
@@ -181,7 +181,67 @@
- ? earth: blue
: moon: white
" :object-type 'alist)
- [(("sun" . "yellow")) (((("earth" . "blue")) . (("moon" .
"white"))))])))
+ [(("sun" . "yellow")) (((("earth" . "blue")) . (("moon" .
"white"))))]))
+
+ ;; Example 8.20. Block Node Types
+ (should (equal (yaml-parse-string "-
+ \"flow in block\"
+- >
+ Block scalar
+- !!map # Block collection
+ foo : bar
+" :object-type 'alist)
+ ["flow in block" "Block scalar\n" (("foo" . "bar"))]))
+
+ ;; Example 8.21. Block Scalar Nodes
+ ;; TODO: The document has no new line after the literal and folded
+ ;; but since it is using default chomp, I think there should be one new line.
+ ;; Which one is right?
+ (should (equal (yaml-parse-string "literal: |2
+ value
+folded:
+ !foo
+ >1
+ value" :object-type 'alist)
+ '(("literal" . "value\n") ("folded" . "value\n"))))
+
+ (should (equal (yaml-parse-string "sequence: !!seq
+- entry
+- !!seq
+ - nested
+mapping: !!map
+ foo: bar" :object-type 'alist)
+ '(("sequence" . ["entry" ["nested"]])
+ ("mapping" . (("foo" . "bar"))))))
+
+ ;; Example 9.2. Document Markers
+ (should (equal (yaml-parse-string "%YAML 1.2
+---
+Document
+...")
+ "Document"))
+
+ ;; Example 9.3 Bare Documents
+ ;; TODO: Allow first character of bare document to be %
+ ;; (should (equal (yaml-parse-string "%!PS-Adobe-2.0 # Not the first line
+ ;; ")))
+
+ (should (equal (yaml-parse-string "---
+{ matches
+% : 20 }
+...
+---
+# Empty
+...")
+ "" ;; TODO: Should this be :null instead?
+ ))
+
+ ;; Example 9.4. Explicit Documents
+ (should (equal (yaml-parse-string "---
+{ matches
+% : 20 }
+..." :object-type 'alist)
+ '(("matches %" . 20)))))
(ert-deftest yaml-parsing-completes ()
"Tests that the yaml parses."
diff --git a/yaml.el b/yaml.el
index 9f6e26c9c4..f1ddd24d26 100644
--- a/yaml.el
+++ b/yaml.el
@@ -482,17 +482,24 @@ This flag is intended for development purposes.")
("ns-flow-pair" . (lambda (text)
(yaml--add-event (yaml--mapping-end-event))))
("ns-plain" . (lambda (text)
- (let* ((replaced (replace-regexp-in-string
+ (let* ((replaced (if (and (zerop (length
yaml--state-stack))
+ (string-match "\\(^\\|\n\\)...$"
text))
+ ;; Hack to not send the document
parse end.
+ ;; Will only occur with bare ns-plain
at top level.
+ (string-trim-right (string-trim-right
text "...") "\n")
+ text))
+ (replaced (replace-regexp-in-string
"\\(?:[ \t]*\r?\n[ \t]*\\)"
"\n"
- text))
+ replaced))
(replaced (replace-regexp-in-string
"\\(\n\\)\\(\n*\\)"
(lambda (x)
(if (> (length x) 1)
(substring x 1)
" "))
- replaced)))
+ replaced))
+ )
(yaml--add-event (yaml--scalar-event "plain"
replaced)))))
("c-single-quoted" . (lambda (text)
(let* ((replaced (replace-regexp-in-string
- [elpa] externals/yaml 1304802f9f 069/124: Reduce the max line length to be under 80 characters., (continued)
- [elpa] externals/yaml 1304802f9f 069/124: Reduce the max line length to be under 80 characters., ELPA Syncer, 2024/11/29
- [elpa] externals/yaml f8803066ae 085/124: Merge pull request #33 from zkry/add-position-information-to-parse-tree, ELPA Syncer, 2024/11/29
- [elpa] externals/yaml 7ef2e8ce5b 100/124: fix unit tests, ELPA Syncer, 2024/11/29
- [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 <=
- [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, 2024/11/29
- [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