[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/yaml c3988d10e2 098/124: store current indent level and
From: |
ELPA Syncer |
Subject: |
[elpa] externals/yaml c3988d10e2 098/124: store current indent level and use that for basis of block indent |
Date: |
Fri, 29 Nov 2024 16:00:06 -0500 (EST) |
branch: externals/yaml
commit c3988d10e24f21cd7a25e796c647599a14409a3d
Author: Zachary Romero <zacromero@posteo.net>
Commit: Zachary Romero <zacromero@posteo.net>
store current indent level and use that for basis of block indent
---
yaml-tests.el | 21 +++++++++++++++++++--
yaml.el | 44 +++++++++++++++++++++++++++-----------------
2 files changed, 46 insertions(+), 19 deletions(-)
diff --git a/yaml-tests.el b/yaml-tests.el
index d3d53182ab..1421a07aac 100644
--- a/yaml-tests.el
+++ b/yaml-tests.el
@@ -390,8 +390,25 @@ ship-to:
(should (equal (progn
(yaml-parse-string-with-pos "- # Empty\n- abc")
(yaml-parse-string "- # Empty\n- abc"))
- [:null "abc"])))
-
+ [:null "abc"]))
+ (should (equal (yaml-parse-string "deeply:\n nested:\n value: >-1\n
test string"
+ :object-type 'alist)
+ '((deeply (nested (value . " test string"))))))
+ (should (equal (yaml-parse-string "deeply:\n nested:\n value: >-\n
test string"
+ :object-type 'alist)
+ '((deeply (nested (value . "test string"))))))
+ (should (equal (yaml-parse-string "deeply:\n nested:\n value: >-2\n
test string"
+ :object-type 'alist)
+ '((deeply (nested (value . "test string"))))))
+ (should (equal (yaml-parse-string "deeply:\n nested:\n value: >-7\n
test string"
+ :object-type 'alist)
+ '((deeply (nested (value . "test string"))))))
+ (should (equal (yaml-parse-string "deeply:\n nested:\n value: |-6\n
test string"
+ :object-type 'alist)
+ '((deeply (nested (value . " test string"))))))
+ (should (equal (yaml-parse-string "deeply:\n nested:\n value: |-\n
test string"
+ :object-type 'alist)
+ '((deeply (nested (value . "test string")))))))
(ert-deftest yaml-parsing-completes ()
"Tests that the yaml parses."
diff --git a/yaml.el b/yaml.el
index 01e0545df7..18447416fb 100644
--- a/yaml.el
+++ b/yaml.el
@@ -3,7 +3,7 @@
;; Copyright © 2021 Zachary Romero <zkry@posteo.org>
;; Author: Zachary Romero <zkry@posteo.org>
-;; Version: 0.1.0
+;; Version: 0.5.0
;; Homepage: https://github.com/zkry/yaml.el
;; Package-Requires: ((emacs "25.1"))
;; Keywords: tools
@@ -45,6 +45,8 @@
(require 'seq)
(require 'cl-lib)
+(defconst yaml-parser-version "0.5.0")
+
(defvar yaml--parse-debug nil
"Turn on debugging messages when parsing YAML when non-nil.
@@ -258,22 +260,24 @@ This flag is intended for development purposes.")
(defun yaml--process-literal-text (text)
"Remove the header line for a folded match and return TEXT body formatted."
- (let* ((header-line (substring text 0 (string-match "\n" text)))
- (text-body (substring text (1+ (string-match "\n" text))))
- (parsed-header (yaml--parse-block-header header-line))
- (chomp (car parsed-header))
- (starting-spaces-ct
- (or (cadr parsed-header)
- (let ((_ (string-match "^\n*\\( *\\)" text-body)))
- (length (match-string 1 text-body)))))
- (lines (split-string text-body "\n"))
- (striped-lines
- (seq-map (lambda (l)
- (replace-regexp-in-string
- (format "\\` \\{0,%d\\}" starting-spaces-ct) "" l))
- lines))
- (text-body (string-join striped-lines "\n")))
- (yaml--chomp-text text-body chomp)))
+ (let ((n (get-text-property 0 'yaml-n text)))
+ (setq text (substring-no-properties text 0 (length text)))
+ (let* ((header-line (substring text 0 (string-match "\n" text)))
+ (text-body (substring text (1+ (string-match "\n" text))))
+ (parsed-header (yaml--parse-block-header header-line))
+ (chomp (car parsed-header))
+ (starting-spaces-ct
+ (or (and (cadr parsed-header) (+ n (cadr parsed-header)))
+ (let ((_ (string-match "^\n*\\( *\\)" text-body)))
+ (length (match-string 1 text-body)))))
+ (lines (split-string text-body "\n"))
+ (striped-lines
+ (seq-map (lambda (l)
+ (replace-regexp-in-string
+ (format "\\` \\{0,%d\\}" starting-spaces-ct) "" l))
+ lines))
+ (text-body (string-join striped-lines "\n")))
+ (yaml--chomp-text text-body chomp))))
;; TODO: Process tags and use them in this function.
(defun yaml--resolve-scalar-tag (scalar)
@@ -759,6 +763,12 @@ repeat for each character in a text.")
((or (assoc ,name yaml--grammar-events-in)
(assoc ,name yaml--grammar-events-out))
(let ((str (substring yaml--parsing-input beg
yaml--parsing-position)))
+ (when yaml--parsing-store-position
+ (setq str (propertize str 'yaml-position
+ (cons (1+ beg)
+ (1+ yaml--parsing-position)))))
+ (when (member ,name '("c-l+folded" "c-l+literal"))
+ (setq str (propertize str 'yaml-n n)))
(list ,name
(if yaml--parsing-store-position
(propertize str 'yaml-position (cons (1+ beg)
- [elpa] externals/yaml c215bf7a33 083/124: add function for generating parse with metadata strings, (continued)
- [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
- [elpa] externals/yaml c3988d10e2 098/124: store current indent level and use that for basis of block indent,
ELPA Syncer <=
- [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
- [elpa] externals/yaml 12655d58ef 113/124: Fix typos, ELPA Syncer, 2024/11/29
- [elpa] externals/yaml b72c188381 111/124: Fix character escape code, ELPA Syncer, 2024/11/29
- [elpa] externals/yaml 20202d7c39 123/124: Merge pull request #56 from zkry/fix-octal-hex-parsing, ELPA Syncer, 2024/11/29
- [elpa] externals/yaml 3506009f94 031/124: Fix yaml-process-literal-text-test, ELPA Syncer, 2024/11/29