org-element-fixed-width-parser: Fix when :value is empty

* lisp/org-element.el (org-element-fixed-width-interpreter): Interpret
fixed-width element with :value "" as ":\n", not as empty string.
* testing/lisp/test-org-element.el (test-org-element/fixed-width-interpreter):
Fixed the test.

The previous test, albeit intentionally asserting "" result, breaks
reversibility of parse-interpret sequence.
This commit is contained in:
Ihor Radchenko 2023-01-12 12:18:34 +03:00
parent 630f86dfc4
commit 89d13998bd
No known key found for this signature in database
GPG Key ID: 6470762A7DA11D8B
2 changed files with 4 additions and 2 deletions

View File

@ -2382,7 +2382,9 @@ Assume point is at the beginning of the fixed-width area."
(defun org-element-fixed-width-interpreter (fixed-width _)
"Interpret FIXED-WIDTH element as Org syntax."
(let ((value (org-element-property :value fixed-width)))
(and value (replace-regexp-in-string "^" ": " value))))
(and value
(if (string-empty-p value) ":\n"
(replace-regexp-in-string "^" ": " value)))))
;;;; Horizontal Rule

View File

@ -3099,7 +3099,7 @@ CLOCK: [2012-01-01 sun. 00:01]--[2012-01-01 sun. 00:02] => 0:01"))))
(should
(equal (org-element-fixed-width-interpreter
'(fixed-width (:value "")) nil)
""))
":\n"))
;; Handle nil value.
(should-not
(org-element-fixed-width-interpreter