From mboxrd@z Thu Jan 1 00:00:00 1970 From: tsd@tsdye.com (Thomas S. Dye) Subject: Re: [ANN] ASCII back-end for new export engine Date: Fri, 27 Jan 2012 07:00:01 -1000 Message-ID: References: <87pqec4xua.fsf@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: quoted-printable Return-path: Received: from eggs.gnu.org ([140.186.70.92]:51132) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Rqp9w-0001Bf-Pq for emacs-orgmode@gnu.org; Fri, 27 Jan 2012 12:00:26 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Rqp9p-0001rV-Oz for emacs-orgmode@gnu.org; Fri, 27 Jan 2012 12:00:20 -0500 Received: from oproxy8-pub.bluehost.com ([69.89.22.20]:60941) by eggs.gnu.org with smtp (Exim 4.71) (envelope-from ) id 1Rqp9p-0001o0-BP for emacs-orgmode@gnu.org; Fri, 27 Jan 2012 12:00:13 -0500 In-Reply-To: <87pqec4xua.fsf@gmail.com> (Nicolas Goaziou's message of "Sat, 21 Jan 2012 21:14:37 +0100") List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: Nicolas Goaziou Cc: Org Mode List Nicolas Goaziou writes: > Hello, > > I've commited an ASCII back-end for new export engine. > > Assuming contrib directory is in your load-path, you just need to > (require 'org-export) to have both LaTeX and ASCII exporters ready to > boot. > > You can then access to the dispatcher with M-x org-export-dispatch and > test various configurations from there. > > As a reminder, you can ask for a table of contents, list of tables and > list of listings with, respectively, "#+toc: headlines", "#+toc: tables" > and "#+toc: listings". Also, drawers[1] are exported transparently by > default. > > Feedback is welcome. > > > Regards, > > [1] properties drawers excepted: those are different elements anyway. Aloha Nicolas, I haven't been able to export a listing yet. The following source exports with the old exporter, but fails with the experimental exporter. * Listing heading #+BEGIN_SRC python :results output print "hello world" #+END_SRC With the old exporter I get: \section{Listing heading} \label{sec-6} \begin{verbatim} print "hello world" \end{verbatim} The backtrace with the experimental exporter follows. Debugger entered--Lisp error: (wrong-type-argument stringp nil) get-file-buffer(nil) (org-babel-expand-noweb-references info (get-file-buffer org-current-expo= rt-file)) (if (org-babel-noweb-p (nth 2 info) :export) (org-babel-expand-noweb-refe= rences info (get-file-buffer org-current-export-file)) (nth 1 info)) (setcar (nthcdr 1 info) (if (org-babel-noweb-p ... :export) (org-babel-ex= pand-noweb-references info ...) (nth 1 info))) (setf (nth 1 info) (if (org-babel-noweb-p ... :export) (org-babel-expand-= noweb-references info ...) (nth 1 info))) (progn (when (member ... ...) (org-babel-exp-in-export-file lang ...) (se= tf hash ...)) (setf (nth 1 info) (if ... ... ...)) (org-babel-exp-do-export= info (quote block) hash)) (if info (progn (when ... ... ...) (setf ... ...) (org-babel-exp-do-expor= t info ... hash))) (when info (when (member ... ...) (org-babel-exp-in-export-file lang ...)= (setf hash ...)) (setf (nth 1 info) (if ... ... ...)) (org-babel-exp-do-ex= port info (quote block) hash)) (let* ((info ...) (lang ...) (raw-params ...) hash) (when info (when ... = ... ...) (setf ... ...) (org-babel-exp-do-export info ... hash))) (save-excursion (goto-char (match-beginning 0)) (let* (... ... ... hash) = (when info ... ... ...))) org-babel-exp-src-block(#("print \"hello world\"\n" 0 1 (fontified t font= -lock-fontified t font-lock-multiline t face py-builtins-face) 1 5 (fontifi= ed t font-lock-fontified t font-lock-multiline t face py-builtins-face) 5 6= (fontified t font-lock-fontified t font-lock-multiline t face nil) 6 7 (fo= ntified t font-lock-fontified t font-lock-multiline t face font-lock-string= -face) 7 19 (fontified t font-lock-fontified t font-lock-multiline t face f= ont-lock-string-face) 19 20 (fontified t font-lock-fontified t font-lock-mu= ltiline t face font-lock-string-face)) #("python" 0 6 (font-lock-multiline = t face org-block-begin-line font-lock-fontified t fontified t)) #(":results= " 0 8 (font-lock-multiline t face org-block-begin-line font-lock-fontified = t fontified t)) #("output" 0 6 (font-lock-multiline t face org-block-begin-= line font-lock-fontified t fontified t))) apply(org-babel-exp-src-block #("print \"hello world\"\n" 0 1 (fontified = t font-lock-fontified t font-lock-multiline t face py-builtins-face) 1 5 (f= ontified t font-lock-fontified t font-lock-multiline t face py-builtins-fac= e) 5 6 (fontified t font-lock-fontified t font-lock-multiline t face nil) 6= 7 (fontified t font-lock-fontified t font-lock-multiline t face font-lock-= string-face) 7 19 (fontified t font-lock-fontified t font-lock-multiline t = face font-lock-string-face) 19 20 (fontified t font-lock-fontified t font-l= ock-multiline t face font-lock-string-face)) (#("python" 0 6 (font-lock-mul= tiline t face org-block-begin-line font-lock-fontified t fontified t)) #(":= results" 0 8 (font-lock-multiline t face org-block-begin-line font-lock-fon= tified t fontified t)) #("output" 0 6 (font-lock-multiline t face org-block= -begin-line font-lock-fontified t fontified t)))) (if (memq type org-export-blocks-witheld) "" (apply func body headers)) (progn (if (memq type org-export-blocks-witheld) "" (apply func body head= ers))) (unwind-protect (progn (if ... "" ...)) (set-match-data save-match-data-i= nternal (quote evaporate))) (let ((save-match-data-internal ...)) (unwind-protect (progn ...) (set-ma= tch-data save-match-data-internal ...))) (save-match-data (if (memq type org-export-blocks-witheld) "" (apply func= body headers))) (let ((replacement ...)) (when replacement (delete-region match-start mat= ch-end) (goto-char match-start) (insert replacement) (unless preserve-inden= t ...))) (progn (let (...) (when replacement ... ... ... ...))) (if (setq func (cadr ...)) (progn (let ... ...))) (when (setq func (cadr ...)) (let (...) (when replacement ... ... ... ...= ))) (let* ((match-start ...) (body-start ...) (indentation ...) (inner-re ...= ) (type ...) (headers ...) (balanced 1) (preserve-indent ...) match-end) (w= hile (and ... ...) (if ... ... ...)) (when (not ...) (error "unbalanced beg= in/end_%s blocks with %S" type ...)) (setq match-end (copy-marker ...)) (un= less preserve-indent (setq body ...)) (unless (memq type types) (setq types= ...)) (save-match-data (interblock start match-start)) (when (setq func ..= .) (let ... ...)) (set-marker match-start nil) (set-marker body-start nil) = (set-marker match-end nil)) (while (re-search-forward beg-re nil t) (let* (... ... ... ... ... ... ..= . ... match-end) (while ... ...) (when ... ...) (setq match-end ...) (unles= s preserve-indent ...) (unless ... ...) (save-match-data ...) (when ... ...= ) (set-marker match-start nil) (set-marker body-start nil) (set-marker matc= h-end nil)) (setq start (point))) (let ((beg-re "^\\([ ]*\\)#\\+begin_\\(\\S-+\\)[ ]*\\(.*\\)?[ \n]")) (while (re-search-forward beg-re nil t) (let* ... ... ... ... ... ..= . ... ... ... ... ...) (setq start ...))) (progn (fset (quote interblock) (function* ...)) (goto-char (point-min)) = (setq start (point)) (let (...) (while ... ... ...)) (interblock start (poi= nt-max)) (run-hooks (quote org-export-blocks-postblock-hook))) (unwind-protect (progn (fset ... ...) (goto-char ...) (setq start ...) (l= et ... ...) (interblock start ...) (run-hooks ...)) (if --cl-letf-bound-- (= fset ... --cl-letf-save--) (fmakunbound ...))) (let* ((--cl-letf-bound-- ...) (--cl-letf-save-- ...)) (unwind-protect (p= rogn ... ... ... ... ... ...) (if --cl-letf-bound-- ... ...))) (letf ((... ...)) (goto-char (point-min)) (setq start (point)) (let (...)= (while ... ... ...)) (interblock start (point-max)) (run-hooks (quote org-= export-blocks-postblock-hook))) (letf* ((... ...)) (goto-char (point-min)) (setq start (point)) (let (...= ) (while ... ... ...)) (interblock start (point-max)) (run-hooks (quote org= -export-blocks-postblock-hook))) (flet ((interblock ... ...)) (goto-char (point-min)) (setq start (point))= (let (...) (while ... ... ...)) (interblock start (point-max)) (run-hooks = (quote org-export-blocks-postblock-hook))) (let ((case-fold-search t) (types ...) matched indentation type func star= t end body headers preserve-indent progress-marker) (flet (...) (goto-char = ...) (setq start ...) (let ... ...) (interblock start ...) (run-hooks ...))) (save-window-excursion (let (... ... matched indentation type func start = end body headers preserve-indent progress-marker) (flet ... ... ... ... ...= ...))) org-export-blocks-preprocess() (progn (org-export-blocks-preprocess) (org-element-parse-buffer nil visib= le-only)) (let ((buffer-invisibility-spec nil)) (org-clone-local-variables --origin= al-buffer "^\\(org-\\|orgtbl-\\|major-mode$\\|outline-regexp$\\)") (insert = --buffer-string) (mapc (lambda ... ...) --overlays) (goto-char (point-min))= (progn (org-export-blocks-preprocess) (org-element-parse-buffer nil visibl= e-only))) (progn (let (...) (org-clone-local-variables --original-buffer "^\\(org-\= \|orgtbl-\\|major-mode$\\|outline-regexp$\\)") (insert --buffer-string) (ma= pc ... --overlays) (goto-char ...) (progn ... ...))) (unwind-protect (progn (let ... ... ... ... ... ...)) (and (buffer-name t= emp-buffer) (kill-buffer temp-buffer))) (save-current-buffer (set-buffer temp-buffer) (unwind-protect (progn ...)= (and ... ...))) (with-current-buffer temp-buffer (unwind-protect (progn ...) (and ... ...= ))) (let ((temp-buffer ...)) (with-current-buffer temp-buffer (unwind-protect= ... ...))) (with-temp-buffer (let (...) (org-clone-local-variables --original-buffer= "^\\(org-\\|orgtbl-\\|major-mode$\\|outline-regexp$\\)") (insert --buffer-= string) (mapc ... --overlays) (goto-char ...) (progn ... ...))) (let ((--original-buffer #) (--offset 0) (--buff= er-string #("#+TITLE: latex-export.org\n#+AUTHOR: Thomas Dye\n#+EMAI= L: tsd@tsdye.com\n#+DATE: 2012-01-21 Sat\n#+DESCRIPTION:\n#+KEYWOR= DS:\n#+LANGUAGE: en\n#+OPTIONS: H:3 num:1 toc:nil \\n:nil @:t ::t |:t ^:= t -:t f:t *:t <:t\n#+OPTIONS: TeX:t LaTeX:t skip:nil d:nil todo:t pri:nil= tags:not-in-toc\n#+INFOJS_OPT: view:nil toc:nil ltoc:t mouse:underline but= tons:0 path:http://orgmode.org/org-info.js\n#+EXPORT_SELECT_TAGS: export\n#= +EXPORT_EXCLUDE_TAGS: noexport\n#+LINK_UP: \n#+LINK_HOME: \n#+XSLT:\n#+La= TeX_HEADER: \\usepackage{paralist}\n\n#+BEGIN_abstract\nThis is an abstract= .\n#+END_abstract\n\n#+toc: headlines\n#+toc: tables\n#+toc: figures\n\n* F= irst heading\n :PROPERTIES:\n :ID: A0EF6F8D-DC06-4AA7-8090-401B90BD= ACF0\n :END:\n\nNote the use of =3D#+toc: headlines=3D together with =3D#+= OPTIONS: toc:nil=3D\nto produce a table of contents without a =3D\\vspace*= =3D following.\n\nIn Section [[First heading]] we will set up Section [[Tab= le heading]].\n\n** First sub heading\nThis is some text after the subheadi= ng.\n\n* Table heading\nThis is a test table. Note that the new exporter f= aithfully\nreproduces the behavior of the old exporter. Look into how it m= ight\nbe modified to produce tables with the booktabs package. \n\n#+CAPTIO= N: A test table\n#+LABEL: tab:test\n| One | Two |\n|-----+-----|\n| 1 | 2= |\n\n* Figure heading\n\nThis is an example of adding a figure.\n\n#+CAP= TION[An example photograph]: An example photograph.\n#+NAME: fig:photo\n[[f= ile:~/Public/projects/308/photo/IMG_0072_cropped.jpg]]\n\n* Reference headi= ng\n\nThis is a reference \n\n* List heading\nThis is an in-paragraph enume= rated list:\n #+attr_latex: inparaenum (i)\n - one;\n - two; and\n - th= ree.\n\nThis should be a sentence in a new paragraph.\n* Listing heading\nT= his is a listing.\n\n#+BEGIN_SRC python :results output\nprint \"hello worl= d\"\n#+END_SRC\n\n#+RESULTS:\n: hello world\n\n" 0 8 ... 8 13 ... 13 29 ...= 29 30 ... 30 39 ... 39 43 ... 43 53 ... 53 54 ... 54 62 ... 62 67 ... 67 8= 0 ... 80 81 ... 81 88 ... 88 94 ... 94 108 ... 108 109 ... 109 123 ... 123 = 124 ... 124 135 ... 135 136 ... 136 151 ... 151 152 ... 152 221 ... 221 222= ... 222 294 ... 294 295 ... 295 364 ... 364 393 ... 393 394 ... 394 395 ..= . 395 423 ... 423 424 ... 424 455 ... 455 456 ... 456 469 ... 469 470 ... 4= 70 483 ... 483 484 ... 484 491 ... 491 492 ... 492 529 ... 529 530 ... 530 = 531 ... 531 547 ... 547 548 ... 548 568 ... 568 569 ... 569 583 ... 583 584= ... 584 585 ... 585 601 ... 601 602 ... 602 615 ... 615 616 ... 616 630 ..= . 630 631 ... 631 632 ... 632 634 ... 634 647 ... 647 648 ... 648 662 ... 6= 62 665 ... 665 669 ... 669 676 ... 676 712 ... 712 713 ... 713 720 ... 720 = 737 ... 737 738 ... 738 756 ... 756 757 ... 757 770 ... 770 771 ... 771 791= ... 791 832 ... 832 833 ... 833 843 ... 843 844 ... 844 867 ... 867 868 ..= . 868 869 ... 869 881 ... 881 882 ... 882 883 ... 883 884 ... 884 908 ... 9= 08 909 ... 909 910 ... 910 922 ... 922 923 ... 923 924 ... 924 925 ... 925 = 928 ... 928 929 ... 929 931 ... 931 948 ... 948 990 ... 990 992 ... 992 100= 5 ... 1005 1067 ... 1067 1279 ... 1279 1280 ... 1280 1282 ... 1282 1296 ...= 1296 1338 ... 1338 1394 ... 1394 1395 ... 1395 1412 ... 1412 1413 ... 1413= 1414 ... 1414 1415 ... 1415 1467 ... 1467 1468 ... 1468 1469 ... 1469 1470= ... 1470 1472 ... 1472 1474 ... 1474 1491 ... 1491 1515 ... 1515 1517 ... = 1517 1529 ... 1529 1530 ... 1530 1571 ... 1571 1601 ... 1601 1682 ... 1682 = 1684 ... 1684 1699 ... 1699 1700 ... 1700 1719 ... 1719 1720 ... 1720 1754 = ... 1754 1755 ... 1755 1756 ... 1756 1760 ... 1760 1761 ... 1761 1762 ... 1= 762 1774 ... 1774 1775 ... 1775 1784 ... 1784 1785 ... 1785 1786 ... 1786 1= 796 ... 1796 1797 ... 1797 1799 ... 1799 1811 ... 1811 1812 ...)) (--overla= ys ...)) (with-temp-buffer (let ... ... ... ... ... ...))) (org-export-with-current-buffer-copy (org-export-blocks-preprocess) (org-= element-parse-buffer nil visible-only)) (org-export-filter-apply-functions (plist-get info :filter-parse-tree) (o= rg-export-with-current-buffer-copy (org-export-blocks-preprocess) (org-elem= ent-parse-buffer nil visible-only)) backend) (progn (when subtreep (let ... ...)) (org-export-filter-apply-functions (= plist-get info :filter-parse-tree) (org-export-with-current-buffer-copy ...= ...) backend)) (let* ((info ...) (raw-data ...)) (setq info (org-combine-plists info ...= )) (let* (... ... ...) (when org-export-copy-to-kill-ring ...) output)) (save-restriction (when (org-region-active-p) (narrow-to-region ... ...) = (goto-char ...)) (when (and subtreep ...) (org-with-limited-levels ...)) (l= et* (... ...) (setq info ...) (let* ... ... output))) (save-excursion (save-restriction (when ... ... ...) (when ... ...) (let*= ... ... ...))) org-export-as(e-latex nil nil nil nil) (let ((out ...) (buffer ...)) (with-current-buffer buffer (erase-buffer) = (insert out) (goto-char ...)) buffer) org-export-to-buffer(e-latex "*Org E-LaTeX Export*" nil nil nil) (let ((outbuf ...)) (with-current-buffer outbuf (latex-mode)) (when org-e= xport-show-temporary-export-buffer (switch-to-buffer-other-window outbuf))) (cond ((member* --cl-var-- ...) (let ... ... ...)) ((member* --cl-var-- .= ..) (org-e-ascii-export-to-ascii ... ... ... ...)) ((eql --cl-var-- ...) (l= et ... ... ...)) ((eql --cl-var-- ...) (org-e-latex-export-to-latex ... ...= ...)) ((eql --cl-var-- ...) (org-e-latex-export-to-pdf ... ... ...)) ((eql= --cl-var-- ...) (org-open-file ...)) (t (error "No command associated with= key %s" ...))) (let ((--cl-var-- ...)) (cond (... ...) (... ...) (... ...) (... ...) (..= . ...) (... ...) (t ...))) (case (if (< raw-key 27) (+ raw-key 96) raw-key) ((65 78 85) (let ... ...= ...)) ((97 110 117) (org-e-ascii-export-to-ascii ... ... ... ...)) (76 (le= t ... ... ...)) (108 (org-e-latex-export-to-latex ... ... ...)) (112 (org-e= -latex-export-to-pdf ... ... ...)) (100 (org-open-file ...)) (t (error "No = command associated with key %s" ...))) (let* ((input ...) (raw-key ...) (scope ...)) (case (if ... ... raw-key) = (... ...) (... ...) (76 ...) (108 ...) (112 ...) (100 ...) (t ...))) org-export-dispatch() call-interactively(org-export-dispatch t nil) execute-extended-command(nil) call-interactively(execute-extended-command nil nil) All the best, Tom --=20 Thomas S. Dye http://www.tsdye.com