branch: externals/yaml commit ada133f0b1519afe2da12f5707eeabdbba3efb29 Author: Zachary Romero <zacrom...@posteo.net> Commit: Zachary Romero <zacrom...@posteo.net>
Fix regexp to match end of string --- yaml.el | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/yaml.el b/yaml.el index 4f1c642f29..74ae8fd1f6 100644 --- a/yaml.el +++ b/yaml.el @@ -214,8 +214,8 @@ This flag is intended for development purposes.") (defun yaml--chomp-text (text-body chomp) "Change the ending newline of TEXT-BODY based on CHOMP." - (cond ((eq :clip chomp) (concat (replace-regexp-in-string "\n*$" "" text-body) "\n")) - ((eq :strip chomp) (replace-regexp-in-string "\n*$" "" text-body)) + (cond ((eq :clip chomp) (concat (replace-regexp-in-string "\n*\\'" "" text-body) "\n")) + ((eq :strip chomp) (replace-regexp-in-string "\n*\\'" "" text-body)) ((eq :keep chomp) text-body))) (defun yaml--process-folded-text (text) @@ -398,7 +398,7 @@ This flag is intended for development purposes.") (let ((comment-text (pop yaml--object-stack))) (unless (stringp value) (error "Trail-comments can't be nested under non-string")) - (yaml--scalar-event style (replace-regexp-in-string (concat (regexp-quote comment-text) "\n*$") "" value ))) + (yaml--scalar-event style (replace-regexp-in-string (concat (regexp-quote comment-text) "\n*\\'") "" value ))) (pop yaml--state-stack)) ((equal top-state nil)))) '(:scalar)) @@ -482,10 +482,10 @@ This flag is intended for development purposes.") (yaml--mapping-end-event))) ("ns-plain" . (lambda (text) (let* ((replaced (if (and (zerop (length yaml--state-stack)) - (string-match "\\(^\\|\n\\)...$" text)) + (string-match "\\(^\\|\n\\)\\.\\.\\.\\'" text)) ;; Hack to not send the document parse end. ;; Will only occur with bare ns-plain at top level. - (replace-regexp-in-string "\\(^\\|\n\\)...$" "" text) + (replace-regexp-in-string "\\(^\\|\n\\)\\.\\.\\.\\'" "" text) text)) (replaced (replace-regexp-in-string "\\(?:[ \t]*\r?\n[ \t]*\\)" @@ -577,7 +577,7 @@ This flag is intended for development purposes.") (when (equal (car yaml--state-stack) :trail-comments) (pop yaml--state-stack) (let ((comment-text (pop yaml--object-stack))) - (setq text (replace-regexp-in-string (concat (regexp-quote comment-text) "\n*$") "" text)))) + (setq text (replace-regexp-in-string (concat (regexp-quote comment-text) "\n*\\'") "" text)))) (let* ((processed-text (yaml--process-folded-text text))) (yaml--scalar-event "folded" processed-text)))) ("e-scalar" . (lambda (text)