Merge branch 'maint'

This commit is contained in:
Nicolas Goaziou 2013-05-25 14:37:01 +02:00
commit d3eaa6abb6
4 changed files with 275 additions and 161 deletions

View File

@ -1648,6 +1648,35 @@ CONTENTS is nil."
;;;; Example Block
(defun org-element--remove-indentation (s &optional n)
"Remove maximum common indentation in string S and return it.
When N is a positive integer, remove exactly that indentation,
possible, or return S as-is otherwise. Unlike to
`org-remove-indentation', this function doesn't call `untabify'
on S first."
(catch 'exit
(with-temp-buffer
(insert s)
(goto-char (point-min))
;; Find maximum common indentation, if not specified.
(setq n (or n
(catch 'min-ind
(let ((min-ind (point-max)))
(save-excursion
(while (re-search-forward "^[ \t]*\\S-" nil t)
(let ((ind (1- (current-column))))
(if (zerop ind) (throw 'min-ind 0)
(setq min-ind (min min-ind ind))))))
min-ind))))
;; Remove exactly N indentation, but give up if not possible.
(while (not (eobp))
(let ((ind (progn (skip-chars-forward " \t") (current-column))))
(cond ((eolp) (delete-region (line-beginning-position) (point)))
((< ind n) (throw 'exit s))
(t (org-indent-line-to (- ind n))))
(forward-line)))
(buffer-string))))
(defun org-element-example-block-parser (limit affiliated)
"Parse an example block.
@ -1669,13 +1698,17 @@ keywords."
(let ((contents-end (match-beginning 0)))
(save-excursion
(let* ((switches
(progn (looking-at "^[ \t]*#\\+BEGIN_EXAMPLE\\(?: +\\(.*\\)\\)?")
(org-match-string-no-properties 1)))
(progn
(looking-at "^[ \t]*#\\+BEGIN_EXAMPLE\\(?: +\\(.*\\)\\)?")
(org-match-string-no-properties 1)))
;; Switches analysis
(number-lines (cond ((not switches) nil)
((string-match "-n\\>" switches) 'new)
((string-match "+n\\>" switches) 'continued)))
(preserve-indent (and switches (string-match "-i\\>" switches)))
(number-lines
(cond ((not switches) nil)
((string-match "-n\\>" switches) 'new)
((string-match "+n\\>" switches) 'continued)))
(preserve-indent
(or org-src-preserve-indentation
(and switches (string-match "-i\\>" switches))))
;; Should labels be retained in (or stripped from) example
;; blocks?
(retain-labels
@ -1686,18 +1719,23 @@ keywords."
;; line-numbers?
(use-labels
(or (not switches)
(and retain-labels (not (string-match "-k\\>" switches)))))
(label-fmt (and switches
(string-match "-l +\"\\([^\"\n]+\\)\"" switches)
(match-string 1 switches)))
(and retain-labels
(not (string-match "-k\\>" switches)))))
(label-fmt
(and switches
(string-match "-l +\"\\([^\"\n]+\\)\"" switches)
(match-string 1 switches)))
;; Standard block parsing.
(begin (car affiliated))
(post-affiliated (point))
(block-ind (progn (skip-chars-forward " \t") (current-column)))
(contents-begin (progn (forward-line) (point)))
(hidden (org-invisible-p2))
(value (org-unescape-code-in-string
(buffer-substring-no-properties
contents-begin contents-end)))
(value (org-element--remove-indentation
(org-unescape-code-in-string
(buffer-substring-no-properties
contents-begin contents-end))
(and preserve-indent block-ind)))
(pos-before-blank (progn (goto-char contents-end)
(forward-line)
(point)))
@ -1725,9 +1763,8 @@ keywords."
CONTENTS is nil."
(let ((switches (org-element-property :switches example-block)))
(concat "#+BEGIN_EXAMPLE" (and switches (concat " " switches)) "\n"
(org-remove-indentation
(org-escape-code-in-string
(org-element-property :value example-block)))
(org-escape-code-in-string
(org-element-property :value example-block))
"#+END_EXAMPLE")))
@ -2224,13 +2261,17 @@ Assume point is at the beginning of the block."
;; Get parameters.
(parameters (org-match-string-no-properties 3))
;; Switches analysis
(number-lines (cond ((not switches) nil)
((string-match "-n\\>" switches) 'new)
((string-match "+n\\>" switches) 'continued)))
(preserve-indent (and switches (string-match "-i\\>" switches)))
(label-fmt (and switches
(string-match "-l +\"\\([^\"\n]+\\)\"" switches)
(match-string 1 switches)))
(number-lines
(cond ((not switches) nil)
((string-match "-n\\>" switches) 'new)
((string-match "+n\\>" switches) 'continued)))
(preserve-indent (or org-src-preserve-indentation
(and switches
(string-match "-i\\>" switches))))
(label-fmt
(and switches
(string-match "-l +\"\\([^\"\n]+\\)\"" switches)
(match-string 1 switches)))
;; Should labels be retained in (or stripped from)
;; src blocks?
(retain-labels
@ -2241,12 +2282,18 @@ Assume point is at the beginning of the block."
;; line-numbers?
(use-labels
(or (not switches)
(and retain-labels (not (string-match "-k\\>" switches)))))
(and retain-labels
(not (string-match "-k\\>" switches)))))
;; Indentation.
(block-ind (progn (skip-chars-forward " \t") (current-column)))
;; Get visibility status.
(hidden (progn (forward-line) (org-invisible-p2)))
;; Retrieve code.
(value (org-unescape-code-in-string
(buffer-substring-no-properties (point) contents-end)))
(value (org-element--remove-indentation
(org-unescape-code-in-string
(buffer-substring-no-properties
(point) contents-end))
(and preserve-indent block-ind)))
(pos-before-blank (progn (goto-char contents-end)
(forward-line)
(point)))
@ -2282,15 +2329,13 @@ CONTENTS is nil."
(params (org-element-property :parameters src-block))
(value (let ((val (org-element-property :value src-block)))
(cond
(org-src-preserve-indentation val)
((zerop org-edit-src-content-indentation)
(org-remove-indentation val))
((org-element-property :preserve-indent src-block) val)
((zerop org-edit-src-content-indentation) val)
(t
(let ((ind (make-string
org-edit-src-content-indentation 32)))
(replace-regexp-in-string
"\\(^\\)[ \t]*\\S-" ind
(org-remove-indentation val) nil nil 1)))))))
"\\(^\\)[ \t]*\\S-" ind val nil nil 1)))))))
(concat (format "#+BEGIN_SRC%s\n"
(concat (and lang (concat " " lang))
(and switches (concat " " switches))

View File

@ -4218,16 +4218,11 @@ line (string)."
(let* ((line 0) refs
;; Get code and clean it. Remove blank lines at its
;; beginning and end.
(code (let ((c (replace-regexp-in-string
"\\`\\([ \t]*\n\\)+" ""
(replace-regexp-in-string
"\\([ \t]*\n\\)*[ \t]*\\'" "\n"
(org-element-property :value element)))))
;; If appropriate, remove global indentation.
(if (or org-src-preserve-indentation
(org-element-property :preserve-indent element))
c
(org-remove-indentation c))))
(code (replace-regexp-in-string
"\\`\\([ \t]*\n\\)+" ""
(replace-regexp-in-string
"\\([ \t]*\n\\)*[ \t]*\\'" "\n"
(org-element-property :value element))))
;; Get format used for references.
(label-fmt (regexp-quote
(or (org-element-property :label-fmt element)

View File

@ -513,121 +513,155 @@ Some other text
(org-test-with-temp-text "#+BEGIN_EXAMPLE\nText\n#+END_EXAMPLE"
(org-element-map (org-element-parse-buffer) 'example-block 'identity)))
;; Test folded block.
(org-test-with-temp-text "#+BEGIN_EXAMPLE\nText\n#+END_EXAMPLE"
(org-cycle)
(should
(org-element-property
:hiddenp
(org-element-map
(org-element-parse-buffer) 'example-block 'identity nil t))))
(should
(org-test-with-temp-text "#+BEGIN_EXAMPLE\nText\n#+END_EXAMPLE"
(org-cycle)
(org-element-property :hiddenp (org-element-at-point))))
;; Ignore incomplete block.
(should-not
(org-test-with-temp-text "#+BEGIN_EXAMPLE"
(org-element-map
(org-element-parse-buffer) 'example-block 'identity nil t)))
(eq 'example-block
(org-test-with-temp-text "#+BEGIN_EXAMPLE"
(org-element-type (org-element-at-point)))))
;; Properly un-escape code.
(should
(equal "* Headline\n #+keyword\nText\n"
(org-test-with-temp-text
"#+BEGIN_EXAMPLE\n,* Headline\n ,#+keyword\nText\n#+END_EXAMPLE"
(org-element-property :value (org-element-at-point))))))
(org-element-property :value (org-element-at-point)))))
;; Nil `org-src-preserve-indentation': Remove maximum common
;; indentation.
(should
(equal " L1\nL2\n"
(org-test-with-temp-text "#+BEGIN_EXAMPLE\n L1\n L2\n#+END_EXAMPLE"
(let ((org-src-preserve-indentation nil))
(org-element-property :value (org-element-at-point))))))
;; Non-nil `org-src-preserve-indentation': Remove block indentation
;; only, unless block contents are less indented than block
;; boundaries.
(should
(equal " L1\nL2\n"
(org-test-with-temp-text " #+BEGIN_EXAMPLE\n L1\n L2\n #+END_EXAMPLE"
(let ((org-src-preserve-indentation t))
(org-element-property :value (org-element-at-point))))))
(should
(equal
" L1\n L2\n"
(org-test-with-temp-text " #+BEGIN_EXAMPLE\n L1\n L2\n #+END_EXAMPLE"
(let ((org-src-preserve-indentation t))
(org-element-property :value (org-element-at-point)))))))
(ert-deftest test-org-element/block-switches ()
"Test `example-block' and `src-block' switches parsing."
(let ((org-coderef-label-format "(ref:%s)"))
;; 1. Test "-i" switch.
(org-test-with-temp-text "#+BEGIN_SRC emacs-lisp\n(+ 1 1)\n#+END_SRC"
(should-not
(should-not
(org-test-with-temp-text "#+BEGIN_SRC emacs-lisp\n(+ 1 1)\n#+END_SRC"
(org-element-property :preserve-indent (org-element-at-point))))
(org-test-with-temp-text "#+BEGIN_SRC emacs-lisp -i\n(+ 1 1)\n#+END_SRC"
(should (org-element-property :preserve-indent (org-element-at-point))))
(org-test-with-temp-text "#+BEGIN_EXAMPLE\nText.\n#+END_EXAMPLE"
(should-not
(should
(org-test-with-temp-text "#+BEGIN_SRC emacs-lisp -i\n(+ 1 1)\n#+END_SRC"
(org-element-property :preserve-indent (org-element-at-point))))
(should-not
(org-test-with-temp-text "#+BEGIN_EXAMPLE\nText.\n#+END_EXAMPLE"
(org-element-property :preserve-indent (org-element-at-point))))
(should
(org-test-with-temp-text "#+BEGIN_EXAMPLE -i\nText.\n#+END_EXAMPLE"
(org-element-property :preserve-indent (org-element-at-point))))
(org-test-with-temp-text "#+BEGIN_EXAMPLE -i\nText.\n#+END_EXAMPLE"
(should (org-element-property :preserve-indent (org-element-at-point))))
;; 2. "-n -r -k" combination should number lines, retain labels but
;; not use them in coderefs.
(org-test-with-temp-text "#+BEGIN_EXAMPLE -n -r -k\nText.\n#+END_EXAMPLE"
(let ((element (org-element-at-point)))
(should (and (org-element-property :number-lines element)
(org-element-property :retain-labels element)
(not (org-element-property :use-labels element))))))
(org-test-with-temp-text
"#+BEGIN_SRC emacs-lisp -n -r -k\n(+ 1 1)\n#+END_SRC"
(let ((element (org-element-at-point)))
(should (and (org-element-property :number-lines element)
(org-element-property :retain-labels element)
(not (org-element-property :use-labels element))))))
(should
(org-test-with-temp-text "#+BEGIN_EXAMPLE -n -r -k\nText.\n#+END_EXAMPLE"
(let ((element (org-element-at-point)))
(and (org-element-property :number-lines element)
(org-element-property :retain-labels element)
(not (org-element-property :use-labels element))))))
(should
(org-test-with-temp-text
"#+BEGIN_SRC emacs-lisp -n -r -k\n(+ 1 1)\n#+END_SRC"
(let ((element (org-element-at-point)))
(and (org-element-property :number-lines element)
(org-element-property :retain-labels element)
(not (org-element-property :use-labels element))))))
;; 3. "-n -r" combination should number-lines remove labels and not
;; use them in coderefs.
(org-test-with-temp-text "#+BEGIN_EXAMPLE -n -r\nText.\n#+END_EXAMPLE"
(let ((element (org-element-at-point)))
(should (and (org-element-property :number-lines element)
(not (org-element-property :retain-labels element))
(not (org-element-property :use-labels element))))))
(org-test-with-temp-text "#+BEGIN_SRC emacs-lisp -n -r\n(+ 1 1)\n#+END_SRC"
(let ((element (org-element-at-point)))
(should (and (org-element-property :number-lines element)
(not (org-element-property :retain-labels element))
(not (org-element-property :use-labels element))))))
(should
(org-test-with-temp-text "#+BEGIN_EXAMPLE -n -r\nText.\n#+END_EXAMPLE"
(let ((element (org-element-at-point)))
(and (org-element-property :number-lines element)
(not (org-element-property :retain-labels element))
(not (org-element-property :use-labels element))))))
(should
(org-test-with-temp-text "#+BEGIN_SRC emacs-lisp -n -r\n(+ 1 1)\n#+END_SRC"
(let ((element (org-element-at-point)))
(and (org-element-property :number-lines element)
(not (org-element-property :retain-labels element))
(not (org-element-property :use-labels element))))))
;; 4. "-n" or "+n" should number lines, retain labels and use them
;; in coderefs.
(org-test-with-temp-text "#+BEGIN_EXAMPLE -n\nText.\n#+END_EXAMPLE"
(let ((element (org-element-at-point)))
(should (and (org-element-property :number-lines element)
(org-element-property :retain-labels element)
(org-element-property :use-labels element)))))
(org-test-with-temp-text "#+BEGIN_SRC emacs-lisp -n\n(+ 1 1)\n#+END_SRC"
(let ((element (org-element-at-point)))
(should (and (org-element-property :number-lines element)
(org-element-property :retain-labels element)
(org-element-property :use-labels element)))))
(org-test-with-temp-text "#+BEGIN_EXAMPLE +n\nText.\n#+END_EXAMPLE"
(let ((element (org-element-at-point)))
(should (and (org-element-property :number-lines element)
(org-element-property :retain-labels element)
(org-element-property :use-labels element)))))
(org-test-with-temp-text "#+BEGIN_SRC emacs-lisp +n\n(+ 1 1)\n#+END_SRC"
(let ((element (org-element-at-point)))
(should (and (org-element-property :number-lines element)
(org-element-property :retain-labels element)
(org-element-property :use-labels element)))))
(should
(org-test-with-temp-text "#+BEGIN_EXAMPLE -n\nText.\n#+END_EXAMPLE"
(let ((element (org-element-at-point)))
(and (org-element-property :number-lines element)
(org-element-property :retain-labels element)
(org-element-property :use-labels element)))))
(should
(org-test-with-temp-text "#+BEGIN_SRC emacs-lisp -n\n(+ 1 1)\n#+END_SRC"
(let ((element (org-element-at-point)))
(and (org-element-property :number-lines element)
(org-element-property :retain-labels element)
(org-element-property :use-labels element)))))
(should
(org-test-with-temp-text "#+BEGIN_EXAMPLE +n\nText.\n#+END_EXAMPLE"
(let ((element (org-element-at-point)))
(and (org-element-property :number-lines element)
(org-element-property :retain-labels element)
(org-element-property :use-labels element)))))
(should
(org-test-with-temp-text "#+BEGIN_SRC emacs-lisp +n\n(+ 1 1)\n#+END_SRC"
(let ((element (org-element-at-point)))
(and (org-element-property :number-lines element)
(org-element-property :retain-labels element)
(org-element-property :use-labels element)))))
;; 5. No switch should not number lines, but retain labels and use
;; them in coderefs.
(org-test-with-temp-text "#+BEGIN_EXAMPLE\nText.\n#+END_EXAMPLE"
(let ((element (org-element-at-point)))
(should (and (not (org-element-property :number-lines element))
(org-element-property :retain-labels element)
(org-element-property :use-labels element)))))
(org-test-with-temp-text "#+BEGIN_SRC emacs-lisp\n(+ 1 1)\n#+END_SRC"
(let ((element (org-element-at-point)))
(should (and (not (org-element-property :number-lines element))
(org-element-property :retain-labels element)
(org-element-property :use-labels element)))))
(should
(org-test-with-temp-text "#+BEGIN_EXAMPLE\nText.\n#+END_EXAMPLE"
(let ((element (org-element-at-point)))
(and (not (org-element-property :number-lines element))
(org-element-property :retain-labels element)
(org-element-property :use-labels element)))))
(should
(org-test-with-temp-text "#+BEGIN_SRC emacs-lisp\n(+ 1 1)\n#+END_SRC"
(let ((element (org-element-at-point)))
(and (not (org-element-property :number-lines element))
(org-element-property :retain-labels element)
(org-element-property :use-labels element)))))
;; 6. "-r" switch only: do not number lines, remove labels, and
;; don't use labels in coderefs.
(org-test-with-temp-text "#+BEGIN_EXAMPLE -r\nText.\n#+END_EXAMPLE"
(let ((element (org-element-at-point)))
(should (and (not (org-element-property :number-lines element))
(not (org-element-property :retain-labels element))
(not (org-element-property :use-labels element))))))
(org-test-with-temp-text "#+BEGIN_SRC emacs-lisp -r\n(+ 1 1)\n#+END_SRC"
(let ((element (org-element-at-point)))
(should (and (not (org-element-property :number-lines element))
(not (org-element-property :retain-labels element))
(not (org-element-property :use-labels element))))))
(should
(org-test-with-temp-text "#+BEGIN_EXAMPLE -r\nText.\n#+END_EXAMPLE"
(let ((element (org-element-at-point)))
(and (not (org-element-property :number-lines element))
(not (org-element-property :retain-labels element))
(not (org-element-property :use-labels element))))))
(should
(org-test-with-temp-text "#+BEGIN_SRC emacs-lisp -r\n(+ 1 1)\n#+END_SRC"
(let ((element (org-element-at-point)))
(and (not (org-element-property :number-lines element))
(not (org-element-property :retain-labels element))
(not (org-element-property :use-labels element))))))
;; 7. Recognize coderefs with user-defined syntax.
(org-test-with-temp-text
"#+BEGIN_EXAMPLE -l \"[ref:%s]\"\nText [ref:text]\n#+END_EXAMPLE"
(let ((element (org-element-at-point)))
(should
(equal (org-element-property :label-fmt element) "[ref:%s]"))))
(org-test-with-temp-text
"#+BEGIN_SRC emacs-lisp -l \"[ref:%s]\"\n(+ 1 1) [ref:text]\n#+END_SRC"
(let ((element (org-element-at-point)))
(should
(equal (org-element-property :label-fmt element) "[ref:%s]"))))))
(should
(equal
"[ref:%s]"
(org-test-with-temp-text
"#+BEGIN_EXAMPLE -l \"[ref:%s]\"\nText [ref:text]\n#+END_EXAMPLE"
(org-element-property :label-fmt (org-element-at-point)))))
(should
(equal
"[ref:%s]"
(org-test-with-temp-text
"#+BEGIN_SRC emacs-lisp -l \"[ref:%s]\"\n(+ 1 1) [ref:text]\n#+END_SRC"
(org-element-property :label-fmt (org-element-at-point)))))))
;;;; Export Block
@ -1641,16 +1675,13 @@ Outside list"
"Test `src-block' parser."
;; Regular tests.
(should
(org-test-with-temp-text "#+BEGIN_SRC\nText\n#+END_SRC"
(org-test-with-temp-text "#+BEGIN_SRC org\nText\n#+END_SRC"
(org-element-map (org-element-parse-buffer) 'src-block 'identity)))
;; Test folded block.
(org-test-with-temp-text "#+BEGIN_SRC\nText\n#+END_SRC"
(org-cycle)
(should
(org-element-property
:hiddenp
(org-element-map
(org-element-parse-buffer) 'src-block 'identity nil t))))
(should
(org-test-with-temp-text "#+BEGIN_SRC org\nText\n#+END_SRC"
(org-cycle)
(org-element-property :hiddenp (org-element-at-point))))
;; Ignore incomplete block.
(should-not
(org-test-with-temp-text "#+BEGIN_SRC"
@ -1660,7 +1691,28 @@ Outside list"
(equal "* Headline\n #+keyword\nText\n"
(org-test-with-temp-text
"#+BEGIN_SRC org\n,* Headline\n ,#+keyword\nText\n#+END_SRC"
(org-element-property :value (org-element-at-point))))))
(org-element-property :value (org-element-at-point)))))
;; Nil `org-src-preserve-indentation': Remove maximum common
;; indentation.
(should
(equal " L1\nL2\n"
(org-test-with-temp-text "#+BEGIN_SRC org\n L1\n L2\n#+END_SRC"
(let ((org-src-preserve-indentation nil))
(org-element-property :value (org-element-at-point))))))
;; Non-nil `org-src-preserve-indentation': Remove block indentation
;; only, unless block contents are less indented than block
;; boundaries.
(should
(equal " L1\nL2\n"
(org-test-with-temp-text " #+BEGIN_SRC org\n L1\n L2\n #+END_SRC"
(let ((org-src-preserve-indentation t))
(org-element-property :value (org-element-at-point))))))
(should
(equal
" L1\n L2\n"
(org-test-with-temp-text " #+BEGIN_SRC org\n L1\n L2\n #+END_SRC"
(let ((org-src-preserve-indentation t))
(org-element-property :value (org-element-at-point)))))))
;;;; Statistics Cookie
@ -2272,9 +2324,24 @@ DEADLINE: <2012-01-01> SCHEDULED: <2012-01-01> CLOSED: [2012-01-01]\n"))))
"#+BEGIN_SRC emacs-lisp -n -k\n (+ 1 1)\n#+END_SRC\n"))
;; Preserve code escaping.
(should
(equal (org-test-parse-and-interpret
"#+BEGIN_SRC org\n,* Headline\n ,#+keyword\nText #+END_SRC")
"#+BEGIN_SRC org\n,* Headline\n ,#+keyword\nText #+END_SRC\n")))
(equal (let ((org-edit-src-content-indentation 2))
(org-test-parse-and-interpret
"#+BEGIN_SRC org\n,* Headline\n ,#+keyword\nText #+END_SRC"))
"#+BEGIN_SRC org\n,* Headline\n ,#+keyword\nText #+END_SRC\n"))
;; Do not apply `org-edit-src-content-indentation' when preserving
;; indentation.
(should
(equal (let ((org-edit-src-content-indentation 2)
(org-src-preserve-indentation t))
(org-test-parse-and-interpret
"#+BEGIN_SRC emacs-lisp\n(+ 1 1)\n#+END_SRC"))
"#+BEGIN_SRC emacs-lisp\n(+ 1 1)\n#+END_SRC\n"))
(should
(equal (let ((org-edit-src-content-indentation 2)
(org-src-preserve-indentation nil))
(org-test-parse-and-interpret
"#+BEGIN_SRC emacs-lisp -i\n(+ 1 1)\n#+END_SRC"))
"#+BEGIN_SRC emacs-lisp -i\n(+ 1 1)\n#+END_SRC\n")))
(ert-deftest test-org-element/table-interpreter ()
"Test table, table-row and table-cell interpreters."

View File

@ -1739,23 +1739,30 @@ Another text. (ref:text)
(ert-deftest test-org-export/unravel-code ()
"Test `org-export-unravel-code' function."
(let ((org-coderef-label-format "(ref:%s)"))
;; 1. Code without reference.
(org-test-with-temp-text "#+BEGIN_EXAMPLE\n(+ 1 1)\n#+END_EXAMPLE"
(should (equal (org-export-unravel-code (org-element-at-point))
'("(+ 1 1)\n"))))
;; 2. Code with reference.
(org-test-with-temp-text
"#+BEGIN_EXAMPLE\n(+ 1 1) (ref:test)\n#+END_EXAMPLE"
(should (equal (org-export-unravel-code (org-element-at-point))
'("(+ 1 1)\n" (1 . "test")))))
;; 3. Code with user-defined reference.
;; Code without reference.
(should
(equal '("(+ 1 1)\n")
(org-test-with-temp-text "#+BEGIN_EXAMPLE\n(+ 1 1)\n#+END_EXAMPLE"
(org-export-unravel-code (org-element-at-point)))))
;; Code with reference.
(should
(equal '("(+ 1 1)\n" (1 . "test"))
(org-test-with-temp-text
"#+BEGIN_EXAMPLE\n(+ 1 1) (ref:test)\n#+END_EXAMPLE"
(let ((org-coderef-label-format "(ref:%s)"))
(org-export-unravel-code (org-element-at-point))))))
;; Code with user-defined reference.
(should
(equal
'("(+ 1 1)\n" (1 . "test"))
(org-test-with-temp-text
"#+BEGIN_EXAMPLE -l \"[ref:%s]\"\n(+ 1 1) [ref:test]\n#+END_EXAMPLE"
(should (equal (org-export-unravel-code (org-element-at-point))
'("(+ 1 1)\n" (1 . "test")))))
;; 4. Code references keys are relative to the current block.
(org-test-with-temp-text "
(let ((org-coderef-label-format "(ref:%s)"))
(org-export-unravel-code (org-element-at-point))))))
;; Code references keys are relative to the current block.
(should
(equal '("(+ 2 2)\n(+ 3 3)\n" (2 . "one"))
(org-test-with-temp-text "
#+BEGIN_EXAMPLE -n
\(+ 1 1)
#+END_EXAMPLE
@ -1763,9 +1770,9 @@ Another text. (ref:text)
\(+ 2 2)
\(+ 3 3) (ref:one)
#+END_EXAMPLE"
(goto-line 5)
(should (equal (org-export-unravel-code (org-element-at-point))
'("(+ 2 2)\n(+ 3 3)\n" (2 . "one")))))))
(goto-line 5)
(let ((org-coderef-label-format "(ref:%s)"))
(org-export-unravel-code (org-element-at-point)))))))
(ert-deftest test-org-export/format-code-default ()
"Test `org-export-format-code-default' specifications."