branch: externals/yaml commit 7c4b2ec9a551c0d2ce0094b030f2ab596f3c32ee Merge: ee86566af1 7f09102db0 Author: Zachary Romero <zacrom...@posteo.net> Commit: GitHub <nore...@github.com>
Merge pull request #49 from zkry/48-encode-remove-leading-newlines Remove leading new-lines for yaml-encode --- yaml-tests.el | 4 ++-- yaml.el | 3 +++ 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/yaml-tests.el b/yaml-tests.el index 9498a337db..b8af0a1c32 100644 --- a/yaml-tests.el +++ b/yaml-tests.el @@ -615,10 +615,10 @@ keep: |+ "[1, 2, 3]")) (should (equal (yaml-encode `[((foo . bar) (baz . bax))]) - "\n- foo: bar\n baz: bax")) + "- foo: bar\n baz: bax")) (should (equal (yaml-encode `((deeper . [((foo . bar) (baz . bax))]))) - "\ndeeper: \n- foo: bar\n baz: bax")) + "deeper: \n- foo: bar\n baz: bax")) (should (equal (yaml-parse-string (yaml-encode [1 [2 [3] 2] 1]) :object-type 'alist diff --git a/yaml.el b/yaml.el index 6c61ffcd1a..86e8a21ef9 100644 --- a/yaml.el +++ b/yaml.el @@ -2765,6 +2765,9 @@ Rules for this function are defined by the yaml-spec JSON file." "Encode OBJECT to a YAML string." (with-temp-buffer (yaml--encode-object object 0) + (goto-char (point-min)) + (while (looking-at-p "\n") + (delete-char 1)) (buffer-string))) (defun yaml--encode-object (object indent &optional auto-indent)