Consistently allow null character in block and drawer bodies
Also, do not use [^\000] as a poor-man's replacement for (rx (or any newline)). * lisp/ob-core.el (org-babel-src-block-regexp): * lisp/ob-haskell.el (org-babel-haskell-export-to-lhs): * lisp/org-compat.el (org-hide-block-toggle-all): * lisp/org-element.el: * lisp/org-feed.el (org-feed-read-previous-status): (org-feed-parse-rss-feed): (org-feed-parse-rss-entry): * lisp/ox-org.el (org-org-publish-to-org): * testing/lisp/test-ob-tangle.el: * lisp/org.el (org-block-regexp): (org-clock-drawer-re): Use \(.\|\n\) regexp instead of [^\000]. (org-latex-regexps): Do not try to match \000 inside latex fragments - we now use parser for this purpose. Reported-by: Tommy Kelly <tommy.kelly@verilab.com> Link: https://orgmode.org/list/875yfk9vlv.fsf@localhost
This commit is contained in:
parent
d97ba5ba52
commit
eaf274909f
|
@ -212,7 +212,7 @@ When matching, reference is stored in match group 1."
|
|||
;; (4) header arguments
|
||||
"\\([^\n]*\\)\n"
|
||||
;; (5) body
|
||||
"\\([^\000]*?\n\\)??[ \t]*#\\+end_src")
|
||||
"\\(\\(?:.\\|\n\\)*?\n\\)??[ \t]*#\\+end_src")
|
||||
"Regexp used to identify code blocks.")
|
||||
|
||||
(defun org-babel--get-vars (params)
|
||||
|
|
|
@ -226,7 +226,7 @@ constructs (header arguments, no-web syntax etc...) are ignored."
|
|||
(let* ((contents (buffer-string))
|
||||
(haskell-regexp
|
||||
(concat "^\\([ \t]*\\)#\\+begin_src[ \t]haskell*\\(.*\\)[\r\n]"
|
||||
"\\([^\000]*?\\)[\r\n][ \t]*#\\+end_src.*"))
|
||||
"\\(\\(?:.\\|\n\\)*?\\)[\r\n][ \t]*#\\+end_src.*"))
|
||||
(base-name (file-name-sans-extension (buffer-file-name)))
|
||||
(tmp-file (org-babel-temp-file "haskell-"))
|
||||
(tmp-org-file (concat tmp-file ".org"))
|
||||
|
@ -270,7 +270,7 @@ constructs (header arguments, no-web syntax etc...) are ignored."
|
|||
(goto-char (point-min)) (forward-line 2)
|
||||
(insert "%include polycode.fmt\n")
|
||||
;; ensure all \begin/end{code} statements start at the first column
|
||||
(while (re-search-forward "^[ \t]+\\\\begin{code}[^\000]+\\\\end{code}" nil t)
|
||||
(while (re-search-forward "^[ \t]+\\\\begin{code}\\(?:.\\|\n\\)+\\\\end{code}" nil t)
|
||||
(replace-match (save-match-data (org-remove-indentation (match-string 0)))
|
||||
t t))
|
||||
;; save org exported latex to a .lhs file
|
||||
|
|
|
@ -925,7 +925,7 @@ an error. Return a non-nil value when toggling is successful."
|
|||
(goto-char start)
|
||||
(while (and (< (point) end)
|
||||
(re-search-forward "^[ \t]*#\\+begin_?\
|
||||
\\([^ \n]+\\)\\(\\([^\n]+\\)\\)?\n\\([^\000]+?\\)#\\+end_?\\1[ \t]*$" end t))
|
||||
\\([^ \n]+\\)\\(\\([^\n]+\\)\\)?\n\\(\\(?:.\\|\n\\)+?\\)#\\+end_?\\1[ \t]*$" end t))
|
||||
(save-excursion
|
||||
(save-match-data
|
||||
(goto-char (match-beginning 0))
|
||||
|
|
|
@ -3671,7 +3671,7 @@ a plist with `:key', `:args', `:begin', `:end', `:value' and
|
|||
|
||||
Assume point is at the macro."
|
||||
(save-excursion
|
||||
(when (looking-at "{{{\\([a-zA-Z][-a-zA-Z0-9_]*\\)\\((\\([^\000]*?\\))\\)?}}}")
|
||||
(when (looking-at "{{{\\([a-zA-Z][-a-zA-Z0-9_]*\\)\\((\\(\\(?:.\\|\n\\)*?\\))\\)?}}}")
|
||||
(let ((begin (point))
|
||||
(key (downcase (match-string-no-properties 1)))
|
||||
(value (match-string-no-properties 0))
|
||||
|
|
|
@ -475,7 +475,7 @@ This will find DRAWER and extract the alist."
|
|||
(goto-char pos)
|
||||
(let ((end (save-excursion (org-end-of-subtree t t))))
|
||||
(if (re-search-forward
|
||||
(concat "^[ \t]*:" drawer ":[ \t]*\n\\([^\000]*?\\)\n[ \t]*:END:")
|
||||
(concat "^[ \t]*:" drawer ":[ \t]*\n\\(\\(?:.\\|\n\\)*?\\)\n[ \t]*:END:")
|
||||
end t)
|
||||
(read (match-string 1))
|
||||
nil))))
|
||||
|
@ -633,7 +633,7 @@ containing the properties `:guid' and `:item-full-text'."
|
|||
end (and (re-search-forward "</item>" nil t)
|
||||
(match-beginning 0)))
|
||||
(setq item (buffer-substring beg end)
|
||||
guid (if (string-match "<guid\\>.*?>\\([^\000]*?\\)</guid>" item)
|
||||
guid (if (string-match "<guid\\>.*?>\\(\\(?:.\\|\n\\)*?\\)</guid>" item)
|
||||
(xml-substitute-special (match-string-no-properties 1 item))))
|
||||
(setq entry (list :guid guid :item-full-text item))
|
||||
(push entry entries)
|
||||
|
@ -647,7 +647,7 @@ containing the properties `:guid' and `:item-full-text'."
|
|||
(with-temp-buffer
|
||||
(insert (plist-get entry :item-full-text))
|
||||
(goto-char (point-min))
|
||||
(while (re-search-forward "<\\([a-zA-Z]+\\>\\).*?>\\([^\000]*?\\)</\\1>"
|
||||
(while (re-search-forward "<\\([a-zA-Z]+\\>\\).*?>\\(\\(?:.\\|\n\\)*?\\)</\\1>"
|
||||
nil t)
|
||||
(setq entry (plist-put entry
|
||||
(intern (concat ":" (match-string 1)))
|
||||
|
|
17
lisp/org.el
17
lisp/org.el
|
@ -405,7 +405,7 @@ FULL is given."
|
|||
;;;; Block
|
||||
|
||||
(defconst org-block-regexp
|
||||
"^[ \t]*#\\+begin_?\\([^ \n]+\\)\\(\\([^\n]+\\)\\)?\n\\([^\000]+?\\)#\\+end_?\\1[ \t]*$"
|
||||
"^[ \t]*#\\+begin_?\\([^ \n]+\\)\\(\\([^\n]+\\)\\)?\n\\(\\(?:.\\|\n\\)+?\\)#\\+end_?\\1[ \t]*$"
|
||||
"Regular expression for hiding blocks.")
|
||||
|
||||
(defconst org-dblock-start-re
|
||||
|
@ -611,7 +611,7 @@ Group 1 contains drawer's name or \"END\".")
|
|||
"Matches an entire property drawer.")
|
||||
|
||||
(defconst org-clock-drawer-re
|
||||
(concat "\\(" org-clock-drawer-start-re "\\)[^\000]*?\\("
|
||||
(concat "\\(" org-clock-drawer-start-re "\\)\\(?:.\\|\n\\)*?\\("
|
||||
org-clock-drawer-end-re "\\)\n?")
|
||||
"Matches an entire clock drawer.")
|
||||
|
||||
|
@ -661,14 +661,13 @@ An entry can be toggled between COMMENT and normal with
|
|||
;;;; LaTeX Environments and Fragments
|
||||
|
||||
(defconst org-latex-regexps
|
||||
'(("begin" "^[ \t]*\\(\\\\begin{\\([a-zA-Z0-9\\*]+\\)[^\000]+?\\\\end{\\2}\\)" 1 t)
|
||||
'(("begin" "^[ \t]*\\(\\\\begin{\\([a-zA-Z0-9\\*]+\\)\\(?:.\\|\n\\)+?\\\\end{\\2}\\)" 1 t)
|
||||
;; ("$" "\\([ \t(]\\|^\\)\\(\\(\\([$]\\)\\([^ \t\n,.$].*?\\(\n.*?\\)\\{0,5\\}[^ \t\n,.$]\\)\\4\\)\\)\\([ \t.,?;:'\")]\\|$\\)" 2 nil)
|
||||
;; \000 in the following regex is needed for org-inside-LaTeX-fragment-p
|
||||
("$1" "\\([^$]\\|^\\)\\(\\$[^ \t\r\n,;.$]\\$\\)\\(\\s.\\|\\s-\\|\\s(\\|\\s)\\|\\s\"\\|\000\\|'\\|$\\)" 2 nil)
|
||||
("$" "\\([^$]\\|^\\)\\(\\(\\$\\([^ \t\n,;.$][^$\n\r]*?\\(\n[^$\n\r]*?\\)\\{0,2\\}[^ \t\n,.$]\\)\\$\\)\\)\\(\\s.\\|\\s-\\|\\s(\\|\\s)\\|\\s\"\\|\000\\|'\\|$\\)" 2 nil)
|
||||
("\\(" "\\\\([^\000]*?\\\\)" 0 nil)
|
||||
("\\[" "\\\\\\[[^\000]*?\\\\\\]" 0 nil)
|
||||
("$$" "\\$\\$[^\000]*?\\$\\$" 0 nil))
|
||||
("$1" "\\([^$]\\|^\\)\\(\\$[^ \t\r\n,;.$]\\$\\)\\(\\s.\\|\\s-\\|\\s(\\|\\s)\\|\\s\"\\|'\\|$\\)" 2 nil)
|
||||
("$" "\\([^$]\\|^\\)\\(\\(\\$\\([^ \t\n,;.$][^$\n\r]*?\\(\n[^$\n\r]*?\\)\\{0,2\\}[^ \t\n,.$]\\)\\$\\)\\)\\(\\s.\\|\\s-\\|\\s(\\|\\s)\\|\\s\"\\|'\\|$\\)" 2 nil)
|
||||
("\\(" "\\\\(\\(?:.\\|\n\\)*?\\\\)" 0 nil)
|
||||
("\\[" "\\\\\\[\\(?:.\\|\n\\)*?\\\\\\]" 0 nil)
|
||||
("$$" "\\$\\$\\(?:.\\|\n\\)*?\\$\\$" 0 nil))
|
||||
"Regular expressions for matching embedded LaTeX.")
|
||||
|
||||
;;;; Node Property
|
||||
|
|
|
@ -337,7 +337,7 @@ Return output file name."
|
|||
(when org-org-htmlized-css-url
|
||||
(goto-char (point-min))
|
||||
(and (re-search-forward
|
||||
"<style type=\"text/css\">[^\000]*?\n[ \t]*</style>.*" nil t)
|
||||
"<style type=\"text/css\">\\(?:.\\|\n\\)*?\n[ \t]*</style>.*" nil t)
|
||||
(replace-match
|
||||
(format
|
||||
"<link rel=\"stylesheet\" type=\"text/css\" href=\"%s\">"
|
||||
|
|
|
@ -45,7 +45,7 @@
|
|||
;; (flet ((exp-p (arg)
|
||||
;; (and
|
||||
;; (string-match
|
||||
;; (format "noweb-%s-start\\([^\000]*\\)noweb-%s-end" arg arg)
|
||||
;; (format "noweb-%s-start\\(\\(?:.\\|\n\\)*\\)noweb-%s-end" arg arg)
|
||||
;; tang)
|
||||
;; (string-match "expanded" (match-string 1 tang)))))
|
||||
;; (should (exp-p "yes"))
|
||||
|
|
Loading…
Reference in New Issue