summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicolas Goaziou <mail@nicolasgoaziou.fr>2018-01-24 12:56:25 +0100
committerNicolas Goaziou <mail@nicolasgoaziou.fr>2018-01-24 12:56:25 +0100
commit13424336a6f30c50952d291e7a82906c1210daf0 (patch)
tree2a62000b3aab118e768c1ef9bd326adb7c43852f
parent8ecc4c436544c21c334ac70cc1556e3f12f15a86 (diff)
downloadorg-mode-13424336a6f30c50952d291e7a82906c1210daf0.tar.gz
org-element: Prefer lower case letters for blocks and keywords
* lisp/org-element.el (org-element-center-block-interpreter): (org-element-dynamic-block-interpreter): (org-element-inlinetask-interpreter): (org-element-quote-block-interpreter): (org-element-special-block-interpreter): (org-element-babel-call-interpreter): (org-element-comment-block-interpreter): (org-element-example-block-interpreter): (org-element-export-block-interpreter): (org-element-keyword-interpreter): (org-element-src-block-interpreter): (org-element-verse-block-interpreter): Use lower case letters when interpreting object. * testing/lisp/test-org-element.el (test-org-element/example-block-parser): (test-org-element/center-block-interpreter): (test-org-element/dynamic-block-interpreter): (test-org-element/inlinetask-interpreter): (test-org-element/quote-block-interpreter): (test-org-element/comment-block-interpreter): (test-org-element/example-block-interpreter): (test-org-element/keyword-interpreter): (test-org-element/src-block-interpreter): (test-org-element/verse-block-interpreter): * testing/lisp/test-ox.el (test-org-export/handle-options): (test-org-export/expand-macro): (test-org-export/before-processing-hook): Update tests.
-rw-r--r--lisp/org-element.el32
-rw-r--r--testing/lisp/test-org-element.el71
-rw-r--r--testing/lisp/test-ox.el12
3 files changed, 58 insertions, 57 deletions
diff --git a/lisp/org-element.el b/lisp/org-element.el
index ec00fbd..340f8c5 100644
--- a/lisp/org-element.el
+++ b/lisp/org-element.el
@@ -677,7 +677,7 @@ Assume point is at the beginning of the block."
(defun org-element-center-block-interpreter (_ contents)
"Interpret a center-block element as Org syntax.
CONTENTS is the contents of the element."
- (format "#+BEGIN_CENTER\n%s#+END_CENTER" contents))
+ (format "#+begin_center\n%s#+end_center" contents))
;;;; Drawer
@@ -787,7 +787,7 @@ Assume point is at beginning of dynamic block."
(defun org-element-dynamic-block-interpreter (dynamic-block contents)
"Interpret DYNAMIC-BLOCK element as Org syntax.
CONTENTS is the contents of the element."
- (format "#+BEGIN: %s%s\n%s#+END:"
+ (format "#+begin: %s%s\n%s#+end:"
(org-element-property :block-name dynamic-block)
(let ((args (org-element-property :arguments dynamic-block)))
(if args (concat " " args) ""))
@@ -1187,18 +1187,18 @@ CONTENTS is the contents of inlinetask."
(concat
(make-string
(max (- (+ org-tags-column (length task) (length tags))) 1)
- ? )
+ ?\s)
tags))
(t
(concat
- (make-string (max (- org-tags-column (length task)) 1) ? )
+ (make-string (max (- org-tags-column (length task)) 1) ?\s)
tags))))
;; Prefer degenerate inlinetasks when there are no
;; contents.
(when contents
(concat "\n"
contents
- (make-string level ?*) " END")))))
+ (make-string level ?*) " end")))))
;;;; Item
@@ -1541,7 +1541,7 @@ Assume point is at the beginning of the block."
(defun org-element-quote-block-interpreter (_ contents)
"Interpret quote-block element as Org syntax.
CONTENTS is the contents of the element."
- (format "#+BEGIN_QUOTE\n%s#+END_QUOTE" contents))
+ (format "#+begin_quote\n%s#+end_quote" contents))
;;;; Section
@@ -1627,7 +1627,7 @@ Assume point is at the beginning of the block."
"Interpret SPECIAL-BLOCK element as Org syntax.
CONTENTS is the contents of the element."
(let ((block-type (org-element-property :type special-block)))
- (format "#+BEGIN_%s\n%s#+END_%s" block-type contents block-type)))
+ (format "#+begin_%s\n%s#+end_%s" block-type contents block-type)))
@@ -1695,7 +1695,7 @@ containing `:call', `:inside-header', `:arguments',
(defun org-element-babel-call-interpreter (babel-call _)
"Interpret BABEL-CALL element as Org syntax."
- (concat "#+CALL: "
+ (concat "#+call: "
(org-element-property :call babel-call)
(let ((h (org-element-property :inside-header babel-call)))
(and h (format "[%s]" h)))
@@ -1849,7 +1849,7 @@ Assume point is at comment block beginning."
(defun org-element-comment-block-interpreter (comment-block _)
"Interpret COMMENT-BLOCK element as Org syntax."
- (format "#+BEGIN_COMMENT\n%s#+END_COMMENT"
+ (format "#+begin_comment\n%s#+end_comment"
(org-element-normalize-string
(org-remove-indentation
(org-element-property :value comment-block)))))
@@ -1977,14 +1977,14 @@ containing `:begin', `:end', `:number-lines', `:preserve-indent',
"Interpret EXAMPLE-BLOCK element as Org syntax."
(let ((switches (org-element-property :switches example-block))
(value (org-element-property :value example-block)))
- (concat "#+BEGIN_EXAMPLE" (and switches (concat " " switches)) "\n"
+ (concat "#+begin_example" (and switches (concat " " switches)) "\n"
(org-element-normalize-string
(org-escape-code-in-string
(if (or org-src-preserve-indentation
(org-element-property :preserve-indent example-block))
value
(org-remove-indentation value))))
- "#+END_EXAMPLE")))
+ "#+end_example")))
;;;; Export Block
@@ -2037,7 +2037,7 @@ Assume point is at export-block beginning."
(defun org-element-export-block-interpreter (export-block _)
"Interpret EXPORT-BLOCK element as Org syntax."
- (format "#+BEGIN_EXPORT %s\n%s#+END_EXPORT"
+ (format "#+begin_export %s\n%s#+end_export"
(org-element-property :type export-block)
(org-element-property :value export-block)))
@@ -2164,7 +2164,7 @@ containing `:key', `:value', `:begin', `:end', `:post-blank' and
(defun org-element-keyword-interpreter (keyword _)
"Interpret KEYWORD element as Org syntax."
(format "#+%s: %s"
- (org-element-property :key keyword)
+ (downcase (org-element-property :key keyword))
(org-element-property :value keyword)))
@@ -2507,12 +2507,12 @@ Assume point is at the beginning of the block."
(let ((ind (make-string org-edit-src-content-indentation ?\s)))
(replace-regexp-in-string
"^" ind (org-remove-indentation val))))))))
- (concat (format "#+BEGIN_SRC%s\n"
+ (concat (format "#+begin_src%s\n"
(concat (and lang (concat " " lang))
(and switches (concat " " switches))
(and params (concat " " params))))
(org-element-normalize-string (org-escape-code-in-string value))
- "#+END_SRC")))
+ "#+end_src")))
;;;; Table
@@ -2660,7 +2660,7 @@ Assume point is at beginning of the block."
(defun org-element-verse-block-interpreter (_ contents)
"Interpret verse-block element as Org syntax.
CONTENTS is verse block contents."
- (format "#+BEGIN_VERSE\n%s#+END_VERSE" contents))
+ (format "#+begin_verse\n%s#+end_verse" contents))
diff --git a/testing/lisp/test-org-element.el b/testing/lisp/test-org-element.el
index 533a317..b6b4dee 100644
--- a/testing/lisp/test-org-element.el
+++ b/testing/lisp/test-org-element.el
@@ -728,9 +728,9 @@ Some other text
(org-element-type (org-element-at-point)))))
;; Properly un-escape code.
(should
- (equal "* Headline\n #+keyword\nText\n"
+ (equal "* Headline\n #+keyword:\nText\n"
(org-test-with-temp-text
- "#+BEGIN_EXAMPLE\n,* Headline\n ,#+keyword\nText\n#+END_EXAMPLE"
+ "#+BEGIN_EXAMPLE\n,* Headline\n ,#+keyword:\nText\n#+END_EXAMPLE"
(org-element-property :value (org-element-at-point)))))
;; Handle non-empty blank line at the end of buffer.
(should
@@ -2570,7 +2570,7 @@ Outside list"
"Test center block interpreter."
(should
(equal (org-test-parse-and-interpret "#+BEGIN_CENTER\nTest\n#+END_CENTER")
- "#+BEGIN_CENTER\nTest\n#+END_CENTER\n")))
+ "#+begin_center\nTest\n#+end_center\n")))
(ert-deftest test-org-element/drawer-interpreter ()
"Test drawer interpreter."
@@ -2583,7 +2583,7 @@ Outside list"
(should
(equal (org-test-parse-and-interpret
"#+BEGIN: myblock :parameter value1\nTest\n#+END:")
- "#+BEGIN: myblock :parameter value1\nTest\n#+END:\n")))
+ "#+begin: myblock :parameter value1\nTest\n#+end:\n")))
(ert-deftest test-org-element/footnote-definition-interpreter ()
"Test footnote definition interpreter."
@@ -2649,13 +2649,13 @@ Outside list"
;; 1. Regular inlinetask.
(should (equal (org-test-parse-and-interpret
"*************** Task\nTest\n*************** END")
- "*************** Task\nTest\n*************** END\n"))
+ "*************** Task\nTest\n*************** end\n"))
;; 2. Degenerate inlinetask.
(should (equal (org-test-parse-and-interpret "*************** Task")
"*************** Task\n"))
;; 3. Prefer degenerate form when there are no contents.
(should (equal (org-test-parse-and-interpret
- "*************** Task\n*************** END")
+ "*************** Task\n*************** end")
"*************** Task\n"))
;; 4. With TODO keywords.
(should
@@ -2731,26 +2731,26 @@ Outside list"
"Test quote block interpreter."
(should (equal (org-test-parse-and-interpret
"#+BEGIN_QUOTE\nTest\n#+END_QUOTE")
- "#+BEGIN_QUOTE\nTest\n#+END_QUOTE\n")))
+ "#+begin_quote\nTest\n#+end_quote\n")))
(ert-deftest test-org-element/special-block-interpreter ()
"Test special block interpreter."
(should (equal (org-test-parse-and-interpret
"#+BEGIN_SPECIAL\nTest\n#+END_SPECIAL")
- "#+BEGIN_SPECIAL\nTest\n#+END_SPECIAL\n")))
+ "#+begin_SPECIAL\nTest\n#+end_SPECIAL\n")))
(ert-deftest test-org-element/babel-call-interpreter ()
"Test Babel call interpreter."
;; Without argument.
(should (equal (org-test-parse-and-interpret "#+CALL: test()")
- "#+CALL: test()\n"))
+ "#+call: test()\n"))
;; With argument.
(should (equal (org-test-parse-and-interpret "#+CALL: test(x=2)")
- "#+CALL: test(x=2)\n"))
+ "#+call: test(x=2)\n"))
;; With header arguments.
(should (equal (org-test-parse-and-interpret
"#+CALL: test[:results output]() :results html")
- "#+CALL: test[:results output]() :results html\n")))
+ "#+call: test[:results output]() :results html\n")))
(ert-deftest test-org-element/clock-interpreter ()
"Test clock interpreter."
@@ -2781,12 +2781,11 @@ CLOCK: [2012-01-01 sun. 00:01]--[2012-01-01 sun. 00:02] => 0:01"))))
"Test comment block interpreter."
(should (equal (org-test-parse-and-interpret
"#+BEGIN_COMMENT\nTest\n#+END_COMMENT")
- "#+BEGIN_COMMENT\nTest\n#+END_COMMENT\n"))
+ "#+begin_comment\nTest\n#+end_comment\n"))
;; Accept missing final newline in value.
(should
- (equal
- "#+BEGIN_COMMENT\nTest\n#+END_COMMENT\n"
- (org-element-interpret-data '(comment-block (:value "Test"))))))
+ (equal "#+begin_comment\nTest\n#+end_comment\n"
+ (org-element-interpret-data '(comment-block (:value "Test"))))))
(ert-deftest test-org-element/diary-sexp ()
"Test diary-sexp interpreter."
@@ -2801,28 +2800,29 @@ CLOCK: [2012-01-01 sun. 00:01]--[2012-01-01 sun. 00:02] => 0:01"))))
;; Without switches.
(should (equal (org-test-parse-and-interpret
"#+BEGIN_EXAMPLE\nTest\n#+END_EXAMPLE")
- "#+BEGIN_EXAMPLE\nTest\n#+END_EXAMPLE\n"))
+ "#+begin_example\nTest\n#+end_example\n"))
;; With switches.
(should
(equal (org-test-parse-and-interpret
"#+BEGIN_EXAMPLE -n -k\n(+ 1 1)\n#+END_EXAMPLE")
- "#+BEGIN_EXAMPLE -n -k\n(+ 1 1)\n#+END_EXAMPLE\n"))
+ "#+begin_example -n -k\n(+ 1 1)\n#+end_example\n"))
;; Preserve code escaping.
(should
- (equal (org-test-parse-and-interpret
- "#+BEGIN_EXAMPLE\n,* Headline\n ,#+keyword\nText #+END_EXAMPLE")
- "#+BEGIN_EXAMPLE\n,* Headline\n ,#+keyword\nText #+END_EXAMPLE\n"))
+ (equal
+ (org-test-parse-and-interpret
+ "#+BEGIN_EXAMPLE\n,* Headline\n,#+KEYWORD: value\nText\n#+END_EXAMPLE")
+ "#+begin_example\n,* Headline\n,#+KEYWORD: value\nText\n#+end_example\n"))
;; Accept missing final newline in value.
(should
(equal
- "#+BEGIN_EXAMPLE\nTest\n#+END_EXAMPLE\n"
+ "#+begin_example\nTest\n#+end_example\n"
(org-element-interpret-data '(example-block (:value "Test"))))))
(ert-deftest test-org-element/export-block-interpreter ()
"Test export block interpreter."
(should (equal (org-test-parse-and-interpret
- "#+BEGIN_EXPORT HTML\nTest\n#+END_EXPORT")
- "#+BEGIN_EXPORT HTML\nTest\n#+END_EXPORT\n")))
+ "#+begin_export HTML\nTest\n#+end_export")
+ "#+begin_export HTML\nTest\n#+end_export\n")))
(ert-deftest test-org-element/fixed-width-interpreter ()
"Test fixed width interpreter."
@@ -2857,7 +2857,7 @@ CLOCK: [2012-01-01 sun. 00:01]--[2012-01-01 sun. 00:02] => 0:01"))))
(ert-deftest test-org-element/keyword-interpreter ()
"Test keyword interpreter."
(should (equal (org-test-parse-and-interpret "#+KEYWORD: value")
- "#+KEYWORD: value\n")))
+ "#+keyword: value\n")))
(ert-deftest test-org-element/latex-environment-interpreter ()
"Test latex environment interpreter."
@@ -2893,21 +2893,22 @@ DEADLINE: <2012-03-29 thu.> SCHEDULED: <2012-03-29 thu.> CLOSED: [2012-03-29 thu
(org-src-preserve-indentation nil))
(org-test-parse-and-interpret
"#+BEGIN_SRC emacs-lisp :results silent\n(+ 1 1)\n#+END_SRC"))
- "#+BEGIN_SRC emacs-lisp :results silent\n (+ 1 1)\n#+END_SRC\n"))
+ "#+begin_src emacs-lisp :results silent\n (+ 1 1)\n#+end_src\n"))
;; With switches.
(should
(equal (let ((org-edit-src-content-indentation 2)
(org-src-preserve-indentation nil))
(org-test-parse-and-interpret
"#+BEGIN_SRC emacs-lisp -n -k\n(+ 1 1)\n#+END_SRC"))
- "#+BEGIN_SRC emacs-lisp -n -k\n (+ 1 1)\n#+END_SRC\n"))
+ "#+begin_src emacs-lisp -n -k\n (+ 1 1)\n#+end_src\n"))
;; Preserve code escaping.
(should
- (equal (let ((org-edit-src-content-indentation 2)
- (org-src-preserve-indentation nil))
- (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-src-preserve-indentation nil))
+ (org-test-parse-and-interpret
+ "#+BEGIN_SRC org\n,* Headline\n,#+KEYWORD: value\nText\n#+END_SRC"))
+ "#+begin_src org\n ,* Headline\n ,#+KEYWORD: value\n Text\n#+end_src\n"))
;; Do not apply `org-edit-src-content-indentation' when preserving
;; indentation.
(should
@@ -2915,17 +2916,17 @@ DEADLINE: <2012-03-29 thu.> SCHEDULED: <2012-03-29 thu.> CLOSED: [2012-03-29 thu
(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"))
+ "#+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"))
+ "#+begin_src emacs-lisp -i\n(+ 1 1)\n#+end_src\n"))
;; Accept missing final newline in value.
(should
(equal
- "#+BEGIN_SRC emacs-lisp\n Test\n#+END_SRC\n"
+ "#+begin_src emacs-lisp\n Test\n#+end_src\n"
(let ((org-edit-src-content-indentation 2)
(org-src-preserve-indentation nil))
(org-element-interpret-data
@@ -3054,7 +3055,7 @@ DEADLINE: <2012-03-29 thu.> SCHEDULED: <2012-03-29 thu.> CLOSED: [2012-03-29 thu
"Test verse block interpretation."
(should
(equal (org-test-parse-and-interpret "#+BEGIN_VERSE\nTest\n#+END_VERSE")
- "#+BEGIN_VERSE\nTest\n#+END_VERSE\n")))
+ "#+begin_verse\nTest\n#+end_verse\n")))
(ert-deftest test-org-element/bold-interpreter ()
"Test bold interpreter."
diff --git a/testing/lisp/test-ox.el b/testing/lisp/test-ox.el
index 3266a0c..24dbd86 100644
--- a/testing/lisp/test-ox.el
+++ b/testing/lisp/test-ox.el
@@ -439,7 +439,7 @@ Paragraph"
(org-export-as (org-test-default-backend)
nil nil nil '(:exclude-tags ("noexp")))))))
(should
- (equal "#+FILETAGS: noexp\n"
+ (equal "#+filetags: noexp\n"
(let (org-export-filter-body-functions
org-export-filter-final-output-functions)
(org-test-with-temp-text "#+FILETAGS: noexp\n* Head1"
@@ -1345,7 +1345,7 @@ Footnotes[fn:2], foot[fn:test] and [fn:inline:inline footnote]
(require 'ox-org)
;; Standard macro expansion.
(should
- (equal "#+MACRO: macro1 value\nvalue\n"
+ (equal "#+macro: macro1 value\nvalue\n"
(org-test-with-temp-text "#+MACRO: macro1 value\n{{{macro1}}}"
(org-export-as (org-test-default-backend)))))
;; Include global macros. However, local macros override them.
@@ -1365,7 +1365,7 @@ Footnotes[fn:2], foot[fn:test] and [fn:inline:inline footnote]
(let ((org-export-global-macros '(("M" . "(eval (+ 1 1))"))))
(org-export-as (org-test-default-backend))))))
(should
- (equal "#+MACRO: M local\nlocal\n"
+ (equal "#+macro: M local\nlocal\n"
(org-test-with-temp-text "#+macro: M local\n{{{M}}}"
(let ((org-export-global-macros '(("M" . "global"))))
(org-export-as (org-test-default-backend))))))
@@ -1373,7 +1373,7 @@ Footnotes[fn:2], foot[fn:test] and [fn:inline:inline footnote]
;; Standard macro expansion.
(should
(string-match
- "#\\+K: value"
+ "#\\+k: value"
(let ((backend (org-export-create-backend
:parent 'org
:options '((:k "K" nil nil parse)))))
@@ -1386,7 +1386,7 @@ Footnotes[fn:2], foot[fn:test] and [fn:inline:inline footnote]
:parent 'org
:options '((:k "K" nil nil parse)))))
(org-test-with-temp-text
- "#+MACRO: m v\n* H\n:PROPERTIES:\n:EXPORT_K: {{{m}}}\n:END:"
+ "#+macro: m v\n* H\n:PROPERTIES:\n:EXPORT_K: {{{m}}}\n:END:"
(org-export-as backend nil nil nil '(:with-properties t))))))
;; Expand specific macros.
(should
@@ -1445,7 +1445,7 @@ Footnotes[fn:2], foot[fn:test] and [fn:inline:inline footnote]
"Test `org-export-before-processing-hook'."
(should
(equal
- "#+MACRO: mac val\nTest\n"
+ "#+macro: mac val\nTest\n"
(org-test-with-temp-text "#+MACRO: mac val\n{{{mac}}} Test"
(let ((org-export-before-processing-hook
'((lambda (backend)