[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[O] [ANN] Export block syntax change
From: |
Nicolas Goaziou |
Subject: |
[O] [ANN] Export block syntax change |
Date: |
Sun, 20 Dec 2015 22:06:44 +0100 |
Hello,
I just finalized the syntax change for export blocks. As a reminder, the
new syntax is:
#+BEGIN_EXPORT backend
...
#+END_EXPORT
instead of
#+BEGIN_backend
...
#+END_backend
So, basically, "export" is a reserved block type, much like "src". As
a consequence, INCLUDE keywords syntax is modified, e.g.,
#+INCLUDE: "file.org" HTML
becomes
#+INCLUDE: "file.org" export html
The following function, included in ORG-NEWS, updates any Org document
to the new syntax. It is meant to be applied after applying the patch.
(defun org-repair-export-blocks ()
"Repair export blocks and INCLUDE keywords in current buffer."
(when (eq major-mode 'org-mode)
(let ((case-fold-search t)
(back-end-re (regexp-opt
'("HTML" "ASCII" "LATEX" "ODT" "MARKDOWN" "MD" "ORG"
"MAN" "BEAMER" "TEXINFO" "GROFF" "KOMA-LETTER")
t)))
(org-with-wide-buffer
(goto-char (point-min))
(let ((block-re (concat "^[ \t]*#\\+BEGIN_" back-end-re)))
(save-excursion
(while (re-search-forward block-re nil t)
(let ((element (save-match-data (org-element-at-point))))
(when (eq (org-element-type element) 'special-block)
(save-excursion
(goto-char (org-element-property :end element))
(save-match-data (search-backward "_"))
(forward-char)
(insert "EXPORT")
(delete-region (point) (line-end-position)))
(replace-match "EXPORT \\1" nil nil nil 1))))))
(let ((include-re
(format "^[ \t]*#\\+INCLUDE: .*?%s[ \t]*$" back-end-re)))
(while (re-search-forward include-re nil t)
(let ((element (save-match-data (org-element-at-point))))
(when (and (eq (org-element-type element) 'keyword)
(string= (org-element-property :key element)
"INCLUDE"))
(replace-match "EXPORT \\1" nil nil nil 1)))))))))
Regards,
--
Nicolas Goaziou 0x80A93738
- [O] [ANN] Export block syntax change,
Nicolas Goaziou <=