]*\\)>\n?" rtn) (setq rtn (replace-match (format "\n" lang) t t rtn)))) (if textareap (setq rtn (concat (format "\n\n
\n")) (with-temp-buffer (insert rtn) (goto-char (point-min)) (while (re-search-forward "[<>&]" nil t) (replace-match (cdr (assq (char-before) '((?&."&")(?<."<")(?>.">")))) t t)) (setq rtn (buffer-string))) (setq rtn (concat "\n" rtn "\n")))) (unless textareap (setq rtn (org-export-number-lines rtn 'html 1 1 num cont rpllbl fmt))) (concat "\n#+BEGIN_HTML\n" (org-add-props rtn '(org-protected t)) "\n#+END_HTML\n\n")) ((eq backend 'latex) (setq rtn (org-export-number-lines rtn 'latex 0 0 num cont rpllbl fmt)) (concat "\n#+BEGIN_LaTeX\n" (org-add-props (concat "\\begin{verbatim}\n" rtn "\n\\end{verbatim}\n") '(org-protected t)) "#+END_LaTeX\n\n")) ((eq backend 'ascii) ;; This is not HTML or LaTeX, so just make it an example. (setq rtn (org-export-number-lines rtn 'ascii 0 0 num cont rpllbl fmt)) (concat "#+BEGIN_ASCII\n" (org-add-props (concat (mapconcat (lambda (l) (concat " " l)) (org-split-string rtn "\n") "\n") "\n") '(org-protected t)) "#+END_ASCII\n")))))) (defun org-export-number-lines (text backend &optional skip1 skip2 number cont replace-labels label-format) (if (and (not number) (not (eq replace-labels 'keep))) (setq replace-labels nil)) ;; must use names if no numbers (setq skip1 (or skip1 0) skip2 (or skip2 0)) (if (not cont) (setq org-export-last-code-line-counter-value 0)) (with-temp-buffer (insert text) (goto-char (point-max)) (skip-chars-backward " \t\n\r") (delete-region (point) (point-max)) (beginning-of-line (- 1 skip2)) (let* ((last (org-current-line)) (n org-export-last-code-line-counter-value) (nmax (+ n (- last skip1))) (fmt (format "%%%dd: " (length (number-to-string nmax)))) (fm (cond ((eq backend 'html) (format "%s" fmt)) ((eq backend 'ascii) fmt) ((eq backend 'latex) fmt) ((eq backend 'docbook) fmt) (t ""))) (label-format (or label-format org-coderef-label-format)) (label-pre (if (string-match "%s" label-format) (substring label-format 0 (match-beginning 0)) label-format)) (label-post (if (string-match "%s" label-format) (substring label-format (match-end 0)) "")) (lbl-re (concat ".*?\\S-.*?\\([ \t]*\\(" (regexp-quote label-pre) "\\([-a-zA-Z0-9_]+\\)" (regexp-quote label-post) "\\)\\)")) ref) (goto-line (1+ skip1)) (while (and (re-search-forward "^" nil t) (not (eobp)) (< n nmax)) (if number (insert (format fm (incf n))) (forward-char 1)) (when (and (not (eq replace-labels 'keep)) (looking-at lbl-re)) (setq ref (match-string 3)) (if replace-labels (progn (delete-region (match-beginning 1) (match-end 1)) (push (cons ref n) org-export-code-refs)) (goto-char (match-beginning 2)) (delete-region (match-beginning 2) (match-end 2)) (insert "(" ref ")") (push (cons ref (concat "(" ref ")")) org-export-code-refs)) (when (eq backend 'html) (save-excursion (beginning-of-line 1) (insert (format "" ref)) (end-of-line 1) (insert ""))))) (setq org-export-last-code-line-counter-value n) (goto-char (point-max)) (newline) (buffer-string)))) (defun org-search-todo-below (line lines level) "Search the subtree below LINE for any TODO entries." (let ((rest (cdr (memq line lines))) (re org-todo-line-regexp) line lv todo) (catch 'exit (while (setq line (pop rest)) (if (string-match re line) (progn (setq lv (- (match-end 1) (match-beginning 1)) todo (and (match-beginning 2) (not (member (match-string 2 line) org-done-keywords)))) ; TODO, not DONE (if (<= lv level) (throw 'exit nil)) (if todo (throw 'exit t)))))))) ;;;###autoload (defun org-export-visible (type arg) "Create a copy of the visible part of the current buffer, and export it. The copy is created in a temporary buffer and removed after use. TYPE is the final key (as a string) that also select the export command in the `C-c C-e' export dispatcher. As a special case, if the you type SPC at the prompt, the temporary org-mode file will not be removed but presented to you so that you can continue to use it. The prefix arg ARG is passed through to the exporting command." (interactive (list (progn (message "Export visible: [a]SCII [h]tml [b]rowse HTML [H/R]uffer with HTML [D]ocBook [x]OXO [ ]keep buffer") (read-char-exclusive)) current-prefix-arg)) (if (not (member type '(?a ?\C-a ?b ?\C-b ?h ?D ?x ?\ ))) (error "Invalid export key")) (let* ((binding (cdr (assoc type '((?a . org-export-as-ascii) (?\C-a . org-export-as-ascii) (?b . org-export-as-html-and-open) (?\C-b . org-export-as-html-and-open) (?h . org-export-as-html) (?H . org-export-as-html-to-buffer) (?R . org-export-region-as-html) (?D . org-export-as-docbook) (?x . org-export-as-xoxo))))) (keepp (equal type ?\ )) (file buffer-file-name) (buffer (get-buffer-create "*Org Export Visible*")) s e) ;; Need to hack the drawers here. (save-excursion (goto-char (point-min)) (while (re-search-forward org-drawer-regexp nil t) (goto-char (match-beginning 1)) (or (org-invisible-p) (org-flag-drawer nil)))) (with-current-buffer buffer (erase-buffer)) (save-excursion (setq s (goto-char (point-min))) (while (not (= (point) (point-max))) (goto-char (org-find-invisible)) (append-to-buffer buffer s (point)) (setq s (goto-char (org-find-visible)))) (org-cycle-hide-drawers 'all) (goto-char (point-min)) (unless keepp ;; Copy all comment lines to the end, to make sure #+ settings are ;; still available for the second export step. Kind of a hack, but ;; does do the trick. (if (looking-at "#[^\r\n]*") (append-to-buffer buffer (match-beginning 0) (1+ (match-end 0)))) (while (re-search-forward "[\n\r]#[^\n\r]*" nil t) (append-to-buffer buffer (1+ (match-beginning 0)) (min (point-max) (1+ (match-end 0)))))) (set-buffer buffer) (let ((buffer-file-name file) (org-inhibit-startup t)) (org-mode) (show-all) (unless keepp (funcall binding arg)))) (if (not keepp) (kill-buffer buffer) (switch-to-buffer-other-window buffer) (goto-char (point-min))))) (defun org-find-visible () (let ((s (point))) (while (and (not (= (point-max) (setq s (next-overlay-change s)))) (get-char-property s 'invisible))) s)) (defun org-find-invisible () (let ((s (point))) (while (and (not (= (point-max) (setq s (next-overlay-change s)))) (not (get-char-property s 'invisible)))) s)) (defvar org-archive-location) ;; gets loaded with the org-archive require. (defun org-get-current-options () "Return a string with current options as keyword options. Does include HTML export options as well as TODO and CATEGORY stuff." (require 'org-archive) (format "#+TITLE: %s #+AUTHOR: %s #+EMAIL: %s #+DATE: %s #+DESCRIPTION: #+KEYWORDS: #+LANGUAGE: %s #+OPTIONS: H:%d num:%s toc:%s \\n:%s @:%s ::%s |:%s ^:%s -:%s f:%s *:%s <:%s #+OPTIONS: TeX:%s LaTeX:%s skip:%s d:%s todo:%s pri:%s tags:%s %s #+EXPORT_SELECT_TAGS: %s #+EXPORT_EXCLUDE_TAGS: %s #+LINK_UP: %s #+LINK_HOME: %s #+CATEGORY: %s #+SEQ_TODO: %s #+TYP_TODO: %s #+PRIORITIES: %c %c %c #+DRAWERS: %s #+STARTUP: %s %s %s %s %s #+TAGS: %s #+FILETAGS: %s #+ARCHIVE: %s #+LINK: %s " (buffer-name) (user-full-name) user-mail-address (format-time-string (substring (car org-time-stamp-formats) 1 -1)) org-export-default-language org-export-headline-levels org-export-with-section-numbers org-export-with-toc org-export-preserve-breaks org-export-html-expand org-export-with-fixed-width org-export-with-tables org-export-with-sub-superscripts org-export-with-special-strings org-export-with-footnotes org-export-with-emphasize org-export-with-timestamps org-export-with-TeX-macros org-export-with-LaTeX-fragments org-export-skip-text-before-1st-heading org-export-with-drawers org-export-with-todo-keywords org-export-with-priority org-export-with-tags (if (featurep 'org-jsinfo) (org-infojs-options-inbuffer-template) "") (mapconcat 'identity org-export-select-tags " ") (mapconcat 'identity org-export-exclude-tags " ") org-export-html-link-up org-export-html-link-home (or (ignore-errors (file-name-sans-extension (file-name-nondirectory (buffer-file-name (buffer-base-buffer))))) "NOFILENAME") "TODO FEEDBACK VERIFY DONE" "Me Jason Marie DONE" org-highest-priority org-lowest-priority org-default-priority (mapconcat 'identity org-drawers " ") (cdr (assoc org-startup-folded '((nil . "showall") (t . "overview") (content . "content")))) (if org-odd-levels-only "odd" "oddeven") (if org-hide-leading-stars "hidestars" "showstars") (if org-startup-align-all-tables "align" "noalign") (cond ((eq org-log-done t) "logdone") ((equal org-log-done 'note) "lognotedone") ((not org-log-done) "nologdone")) (or (mapconcat (lambda (x) (cond ((equal '(:startgroup) x) "{") ((equal '(:endgroup) x) "}") ((cdr x) (format "%s(%c)" (car x) (cdr x))) (t (car x)))) (or org-tag-alist (org-get-buffer-tags)) " ") "") (mapconcat 'identity org-file-tags " ") org-archive-location "org file:~/org/%s.org" )) ;;;###autoload (defun org-insert-export-options-template () "Insert into the buffer a template with information for exporting." (interactive) (if (not (bolp)) (newline)) (let ((s (org-get-current-options))) (and (string-match "#\\+CATEGORY" s) (setq s (substring s 0 (match-beginning 0)))) (insert s))) (defvar org-table-colgroup-info nil) (defun org-table-clean-before-export (lines &optional maybe-quoted) "Check if the table has a marking column. If yes remove the column and the special lines." (setq org-table-colgroup-info nil) (if (memq nil (mapcar (lambda (x) (or (string-match "^[ \t]*|-" x) (string-match (if maybe-quoted "^[ \t]*| *\\\\?\\([\#!$*_^ /]\\) *|" "^[ \t]*| *\\([\#!$*_^ /]\\) *|") x))) lines)) (progn (setq org-table-clean-did-remove-column nil) (delq nil (mapcar (lambda (x) (cond ((string-match "^[ \t]*| */ *|" x) (setq org-table-colgroup-info (mapcar (lambda (x) (cond ((member x '("<" "<")) :start) ((member x '(">" ">")) :end) ((member x '("<>" "<>")) :startend) (t nil))) (org-split-string x "[ \t]*|[ \t]*"))) nil) (t x))) lines))) (setq org-table-clean-did-remove-column t) (delq nil (mapcar (lambda (x) (cond ((string-match "^[ \t]*| */ *|" x) (setq org-table-colgroup-info (mapcar (lambda (x) (cond ((member x '("<" "<")) :start) ((member x '(">" ">")) :end) ((member x '("<>" "<>")) :startend) (t nil))) (cdr (org-split-string x "[ \t]*|[ \t]*")))) nil) ((string-match "^[ \t]*| *[!_^/] *|" x) nil) ; ignore this line ((or (string-match "^\\([ \t]*\\)|-+\\+" x) (string-match "^\\([ \t]*\\)|[^|]*|" x)) ;; remove the first column (replace-match "\\1|" t nil x)))) lines)))) (defun org-export-cleanup-toc-line (s) "Remove tags and timestamps from lines going into the toc." (when (memq org-export-with-tags '(not-in-toc nil)) (if (string-match (org-re " +:[[:alnum:]_@:]+: *$") s) (setq s (replace-match "" t t s)))) (when org-export-remove-timestamps-from-toc (while (string-match org-maybe-keyword-time-regexp s) (setq s (replace-match "" t t s)))) (while (string-match org-bracket-link-regexp s) (setq s (replace-match (match-string (if (match-end 3) 3 1) s) t t s))) s) (defvar org-match-substring-regexp (concat "\\([^\\]\\)\\([_^]\\)\\(" "\\(" (org-create-multibrace-regexp "{" "}" org-match-sexp-depth) "\\)" "\\|" "\\(" (org-create-multibrace-regexp "(" ")" org-match-sexp-depth) "\\)" "\\|" "\\(\\(?:\\*\\|[-+]?[^-+*!@#$%^_ \t\r\n,:\"?<>~;./{}=()]+\\)\\)\\)") "The regular expression matching a sub- or superscript.") (defvar org-match-substring-with-braces-regexp (concat "\\([^\\]\\)\\([_^]\\)\\(" "\\(" (org-create-multibrace-regexp "{" "}" org-match-sexp-depth) "\\)" "\\)") "The regular expression matching a sub- or superscript, forcing braces.") (defun org-get-text-property-any (pos prop &optional object) (or (get-text-property pos prop object) (and (setq pos (next-single-property-change pos prop object)) (get-text-property pos prop object)))) (defun org-export-get-coderef-format (path desc) (save-match-data (if (and desc (string-match (regexp-quote (concat "(" path ")")) desc)) (replace-match "%s" t t desc) "%s"))) (provide 'org-exp) ;; arch-tag: 65985fe9-095c-49c7-a7b6-cb4ee15c0a95 ;;; org-exp.el ends here