12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394 |
- (defvar org-special-blocks-ignore-regexp "^\\(LaTeX\\|HTML\\)$"
- "A regexp indicating the names of blocks that should be ignored
- by org-special-blocks. These blocks will presumably be
- interpreted by other mechanisms.")
- (defun org-special-blocks-make-special-cookies ()
- "Adds special cookies when #+begin_foo and #+end_foo tokens are
- seen. This is run after a few special cases are taken care of."
- (when (or htmlp latexp)
- (goto-char (point-min))
- (while (re-search-forward "^#\\+\\(begin\\|end\\)_\\(.*\\)$" nil t)
- (unless (org-string-match-p org-special-blocks-ignore-regexp (match-string 2))
- (replace-match
- (if (equal (downcase (match-string 1)) "begin")
- (concat "ORG-" (match-string 2) "-START")
- (concat "ORG-" (match-string 2) "-END"))
- t t)))))
- (add-hook 'org-export-preprocess-after-blockquote-hook
- 'org-special-blocks-make-special-cookies)
- (defun org-special-blocks-convert-latex-special-cookies ()
- "Converts the special cookies into LaTeX blocks."
- (goto-char (point-min))
- (while (re-search-forward "^ORG-\\([^ \t\n]*\\)[ \t]*\\(.*\\)-\\(START\\|END\\)$" nil t)
- (replace-match
- (if (equal (match-string 3) "START")
- (concat "\\begin{" (match-string 1) "}" (match-string 2))
- (concat "\\end{" (match-string 1) "}"))
- t t)))
- (add-hook 'org-export-latex-after-blockquotes-hook
- 'org-special-blocks-convert-latex-special-cookies)
- (defun org-special-blocks-convert-html-special-cookies ()
- "Converts the special cookies into div blocks."
-
- (when (string-match "^ORG-\\(.*\\)-\\(START\\|END\\)$" line)
- (message "%s" (match-string 1))
- (if (equal (match-string 2 line) "START")
- (insert "<div class=\"" (match-string 1 line) "\">\n")
- (insert "</div>\n"))
- (throw 'nextline nil)))
- (add-hook 'org-export-html-after-blockquotes-hook
- 'org-special-blocks-convert-html-special-cookies)
- (provide 'org-special-blocks)
|