浏览代码

Remove `export-block' syntax type

* lisp/org-element.el (org-element-all-elements): Remove
  `export-block' type.
(org-element-block-name-alist): Make it a defconst since it is not
meant to be changed anymore.
(org-element-export-block-parser,
org-element-export-block-interpreter): Remove functions.

* lisp/ox.el (org-export-filters-alist): Remove export block filter.
(org-export-register-backend): Do not alter
`org-export-block-name-alist' anymore.
(org-export-define-backend, org-export-define-derived-backend): Update
docstring.
(org-export-filter-export-block-functions): Remove variable.

* testing/lisp/test-org-element.el (test-org-element/export-block-parser,
  test-org-element/export-block-interpreter): Remove tests.

* testing/lisp/test-ox.el (test-org-export/define-backend): Update test.
Nicolas Goaziou 11 年之前
父节点
当前提交
bc43228e6d
共有 4 个文件被更改,包括 14 次插入126 次删除
  1. 11 65
      lisp/org-element.el
  2. 2 13
      lisp/ox.el
  3. 0 39
      testing/lisp/test-org-element.el
  4. 1 9
      testing/lisp/test-ox.el

+ 11 - 65
lisp/org-element.el

@@ -45,11 +45,11 @@
 ;; and `special-block'.
 ;; and `special-block'.
 ;;
 ;;
 ;; Other element types are: `babel-call', `clock', `comment',
 ;; Other element types are: `babel-call', `clock', `comment',
-;; `comment-block', `diary-sexp', `example-block', `export-block',
-;; `fixed-width', `horizontal-rule', `keyword', `latex-environment',
-;; `node-property', `paragraph', `planning', `src-block', `table',
-;; `table-row' and `verse-block'.  Among them, `paragraph' and
-;; `verse-block' types can contain Org objects and plain text.
+;; `comment-block', `diary-sexp', `example-block', `fixed-width',
+;; `horizontal-rule', `keyword', `latex-environment', `node-property',
+;; `paragraph', `planning', `src-block', `table', `table-row' and
+;; `verse-block'.  Among them, `paragraph' and `verse-block' types can
+;; contain Org objects and plain text.
 ;;
 ;;
 ;; Objects are related to document's contents.  Some of them are
 ;; Objects are related to document's contents.  Some of them are
 ;; recursive.  Associated types are of the following: `bold', `code',
 ;; recursive.  Associated types are of the following: `bold', `code',
@@ -173,11 +173,11 @@ is not sufficient to know if point is at a paragraph ending.  See
 
 
 (defconst org-element-all-elements
 (defconst org-element-all-elements
   '(babel-call center-block clock comment comment-block diary-sexp drawer
   '(babel-call center-block clock comment comment-block diary-sexp drawer
-	       dynamic-block example-block export-block fixed-width
-	       footnote-definition headline horizontal-rule inlinetask item
-	       keyword latex-environment node-property paragraph plain-list
-	       planning property-drawer quote-block section
-	       special-block src-block table table-row verse-block)
+	       dynamic-block example-block fixed-width footnote-definition
+	       headline horizontal-rule inlinetask item keyword
+	       latex-environment node-property paragraph plain-list
+	       planning property-drawer quote-block section special-block
+	       src-block table table-row verse-block)
   "Complete list of element types.")
   "Complete list of element types.")
 
 
 (defconst org-element-greater-elements
 (defconst org-element-greater-elements
@@ -198,7 +198,7 @@ is not sufficient to know if point is at a paragraph ending.  See
 	 superscript table-cell underline)
 	 superscript table-cell underline)
   "List of recursive object types.")
   "List of recursive object types.")
 
 
-(defvar org-element-block-name-alist
+(defconst org-element-block-name-alist
   '(("CENTER" . org-element-center-block-parser)
   '(("CENTER" . org-element-center-block-parser)
     ("COMMENT" . org-element-comment-block-parser)
     ("COMMENT" . org-element-comment-block-parser)
     ("EXAMPLE" . org-element-example-block-parser)
     ("EXAMPLE" . org-element-example-block-parser)
@@ -1899,60 +1899,6 @@ CONTENTS is nil."
 	    "#+END_EXAMPLE")))
 	    "#+END_EXAMPLE")))
 
 
 
 
-;;;; Export Block
-
-(defun org-element-export-block-parser (limit affiliated)
-  "Parse an export block.
-
-LIMIT bounds the search.  AFFILIATED is a list of which CAR is
-the buffer position at the beginning of the first affiliated
-keyword and CDR is a plist of affiliated keywords along with
-their value.
-
-Return a list whose CAR is `export-block' and CDR is a plist
-containing `:begin', `:end', `:type', `:value', `:post-blank' and
-`:post-affiliated' keywords.
-
-Assume point is at export-block beginning."
-  (let* ((case-fold-search t)
-	 (type (progn (looking-at "[ \t]*#\\+BEGIN_\\(\\S-+\\)")
-		      (upcase (org-match-string-no-properties 1)))))
-    (if (not (save-excursion
-	       (re-search-forward
-		(format "^[ \t]*#\\+END_%s[ \t]*$" type) limit t)))
-	;; Incomplete block: parse it as a paragraph.
-	(org-element-paragraph-parser limit affiliated)
-      (let ((contents-end (match-beginning 0)))
-	(save-excursion
-	  (let* ((begin (car affiliated))
-		 (post-affiliated (point))
-		 (contents-begin (progn (forward-line) (point)))
-		 (pos-before-blank (progn (goto-char contents-end)
-					  (forward-line)
-					  (point)))
-		 (end (progn (skip-chars-forward " \r\t\n" limit)
-			     (if (eobp) (point) (line-beginning-position))))
-		 (value (buffer-substring-no-properties contents-begin
-							contents-end)))
-	    (list 'export-block
-		  (nconc
-		   (list :begin begin
-			 :end end
-			 :type type
-			 :value value
-			 :post-blank (count-lines pos-before-blank end)
-			 :post-affiliated post-affiliated)
-		   (cdr affiliated)))))))))
-
-(defun org-element-export-block-interpreter (export-block contents)
-  "Interpret EXPORT-BLOCK element as Org syntax.
-CONTENTS is nil."
-  (let ((type (org-element-property :type export-block)))
-    (concat (format "#+BEGIN_%s\n" type)
-	    (org-element-property :value export-block)
-	    (format "#+END_%s" type))))
-
-
 ;;;; Fixed-width
 ;;;; Fixed-width
 
 
 (defun org-element-fixed-width-parser (limit affiliated)
 (defun org-element-fixed-width-parser (limit affiliated)

+ 2 - 13
lisp/ox.el

@@ -188,7 +188,6 @@ way they are handled must be hard-coded into
     (:filter-dynamic-block . org-export-filter-dynamic-block-functions)
     (:filter-dynamic-block . org-export-filter-dynamic-block-functions)
     (:filter-entity . org-export-filter-entity-functions)
     (:filter-entity . org-export-filter-entity-functions)
     (:filter-example-block . org-export-filter-example-block-functions)
     (:filter-example-block . org-export-filter-example-block-functions)
-    (:filter-export-block . org-export-filter-export-block-functions)
     (:filter-export-snippet . org-export-filter-export-snippet-functions)
     (:filter-export-snippet . org-export-filter-export-snippet-functions)
     (:filter-final-output . org-export-filter-final-output-functions)
     (:filter-final-output . org-export-filter-final-output-functions)
     (:filter-fixed-width . org-export-filter-fixed-width-functions)
     (:filter-fixed-width . org-export-filter-fixed-width-functions)
@@ -935,10 +934,6 @@ BACKEND is a structure with `org-export-backend' type."
   (let ((parent (org-export-backend-parent backend)))
   (let ((parent (org-export-backend-parent backend)))
     (when (and parent (not (org-export-get-backend parent)))
     (when (and parent (not (org-export-get-backend parent)))
       (error "Cannot use unknown \"%s\" back-end as a parent" parent)))
       (error "Cannot use unknown \"%s\" back-end as a parent" parent)))
-  ;; Register dedicated export blocks in the parser.
-  (dolist (name (org-export-backend-blocks backend))
-    (add-to-list 'org-element-block-name-alist
-		 (cons name 'org-element-export-block-parser)))
   ;; If a back-end with the same name as BACKEND is already
   ;; If a back-end with the same name as BACKEND is already
   ;; registered, replace it with BACKEND.  Otherwise, simply add
   ;; registered, replace it with BACKEND.  Otherwise, simply add
   ;; BACKEND to the list of registered back-ends.
   ;; BACKEND to the list of registered back-ends.
@@ -1070,7 +1065,7 @@ keywords are understood:
     String, or list of strings, representing block names that
     String, or list of strings, representing block names that
     will not be parsed.  This is used to specify blocks that will
     will not be parsed.  This is used to specify blocks that will
     contain raw code specific to the back-end.  These blocks
     contain raw code specific to the back-end.  These blocks
-    still have to be handled by the relative `export-block' type
+    still have to be handled by the `special-block' type
     translator.
     translator.
 
 
   :filters-alist
   :filters-alist
@@ -1174,7 +1169,7 @@ keywords are understood:
     String, or list of strings, representing block names that
     String, or list of strings, representing block names that
     will not be parsed.  This is used to specify blocks that will
     will not be parsed.  This is used to specify blocks that will
     contain raw code specific to the back-end.  These blocks
     contain raw code specific to the back-end.  These blocks
-    still have to be handled by the relative `export-block' type
+    still have to be handled by the `special-block' type
     translator.
     translator.
 
 
   :filters-alist
   :filters-alist
@@ -2593,12 +2588,6 @@ Each filter is called with three arguments: the transcoded data,
 as a string, the back-end, as a symbol, and the communication
 as a string, the back-end, as a symbol, and the communication
 channel, as a plist.  It must return a string or nil.")
 channel, as a plist.  It must return a string or nil.")
 
 
-(defvar org-export-filter-export-block-functions nil
-  "List of functions applied to a transcoded export-block.
-Each filter is called with three arguments: the transcoded data,
-as a string, the back-end, as a symbol, and the communication
-channel, as a plist.  It must return a string or nil.")
-
 (defvar org-export-filter-fixed-width-functions nil
 (defvar org-export-filter-fixed-width-functions nil
   "List of functions applied to a transcoded fixed-width.
   "List of functions applied to a transcoded fixed-width.
 Each filter is called with three arguments: the transcoded data,
 Each filter is called with three arguments: the transcoded data,

+ 0 - 39
testing/lisp/test-org-element.el

@@ -777,39 +777,6 @@ Some other text
 	(org-element-property :label-fmt (org-element-at-point)))))))
 	(org-element-property :label-fmt (org-element-at-point)))))))
 
 
 
 
-;;;; Export Block
-
-(ert-deftest test-org-element/export-block-parser ()
-  "Test `export-block' parser."
-  ;; Standard test.
-  (should
-   (org-test-with-temp-text "#+BEGIN_LATEX\nText\n#+END_LATEX"
-     (org-element-map
-      (let ((org-element-block-name-alist
-	     '(("LATEX" . org-element-export-block-parser))))
-	(org-element-parse-buffer))
-      'export-block 'identity)))
-  ;; Ignore case.
-  (should
-   (let ((org-element-block-name-alist
-	  '(("LATEX" . org-element-export-block-parser))))
-     (org-test-with-temp-text "#+begin_latex\nText\n#+end_latex"
-       (org-element-map (org-element-parse-buffer) 'export-block 'identity))))
-  ;; Ignore incomplete block.
-  (should-not
-   (let ((org-element-block-name-alist
-	  '(("LATEX" . org-element-export-block-parser))))
-     (org-test-with-temp-text "#+BEGIN_LATEX"
-       (org-element-map (org-element-parse-buffer) 'export-block
-	 'identity nil t))))
-  ;; Handle non-empty blank line at the end of buffer.
-  (should
-   (let ((org-element-block-name-alist
-	  '(("LATEX" . org-element-export-block-parser))))
-     (org-test-with-temp-text "#+BEGIN_LATEX\nC\n#+END_LATEX\n "
-       (= (org-element-property :end (org-element-at-point)) (point-max))))))
-
-
 ;;;; Export Snippet
 ;;;; Export Snippet
 
 
 (ert-deftest test-org-element/export-snippet-parser ()
 (ert-deftest test-org-element/export-snippet-parser ()
@@ -2432,12 +2399,6 @@ CLOCK: [2012-01-01 sun. 00:01]--[2012-01-01 sun. 00:02] =>  0:01"))))
 	   "#+BEGIN_EXAMPLE\n,* Headline\n ,#+keyword\nText #+END_EXAMPLE")
 	   "#+BEGIN_EXAMPLE\n,* Headline\n ,#+keyword\nText #+END_EXAMPLE")
 	  "#+BEGIN_EXAMPLE\n,* Headline\n ,#+keyword\nText #+END_EXAMPLE\n")))
 	  "#+BEGIN_EXAMPLE\n,* Headline\n ,#+keyword\nText #+END_EXAMPLE\n")))
 
 
-(ert-deftest test-org-element/export-block-interpreter ()
-  "Test export block interpreter."
-  (should (equal (org-test-parse-and-interpret
-		  "#+BEGIN_HTML\nTest\n#+END_HTML")
-		 "#+BEGIN_HTML\nTest\n#+END_HTML\n")))
-
 (ert-deftest test-org-element/fixed-width-interpreter ()
 (ert-deftest test-org-element/fixed-width-interpreter ()
   "Test fixed width interpreter."
   "Test fixed width interpreter."
   ;; Standard test.
   ;; Standard test.

+ 1 - 9
testing/lisp/test-ox.el

@@ -1118,15 +1118,7 @@ Footnotes[fn:1], [fn:test] and [fn:inline:anonymous footnote].
 	    (org-export-define-backend 'test
 	    (org-export-define-backend 'test
 	      '((headline . my-headline-test))
 	      '((headline . my-headline-test))
 	      :menu-entry '(?k "Test Export" test))
 	      :menu-entry '(?k "Test Export" test))
-	    (org-export-backend-menu (org-export-get-backend 'test)))))
-  ;; Export Blocks.
-  (should
-   (equal '(("TEST" . org-element-export-block-parser))
-	  (let (org-export--registered-backends org-element-block-name-alist)
-	    (org-export-define-backend 'test
-	      '((headline . my-headline-test))
-	      :export-block '("test"))
-	    org-element-block-name-alist))))
+	    (org-export-backend-menu (org-export-get-backend 'test))))))
 
 
 (ert-deftest test-org-export/define-derived-backend ()
 (ert-deftest test-org-export/define-derived-backend ()
   "Test `org-export-define-derived-backend' specifications."
   "Test `org-export-define-derived-backend' specifications."