[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [O] [export] org-export-with-* bugs
From: |
Nicolas Goaziou |
Subject: |
Re: [O] [export] org-export-with-* bugs |
Date: |
Tue, 17 Dec 2013 18:29:40 +0100 |
Hello,
Aaron Ecay <address@hidden> writes:
> 1) In exporting the following org buffer to latex, I get the following
> stack trace (at end of email because of length):
>
> =====
> #+options: |:nil
>
> | foo | bar |
> =====
The more I look at it, the more I'm inclined to think that it's totally
useless. I don't think anyone wants tables removed from Org syntax.
Though, occasionally some line starting with "|" can be interpreted as
a table. In this case, it's possible to use "\vert" entity anyway.
I'm not sure it is worth fixing. I think we really should remove it, or
change its meaning, like "|:nil means that all tables are ignored in
export process" (which is probably almost as useless). The same goes for
"::nil".
> 2) When exporting the following buffer to latex:
>
> =====
> #+options: ^:nil
>
> foo_{*bar*}
> =====
>
> I get (ignoring document preamble):
>
> =====
> foo\_\{$\backslash$textbf\{bar\}\}
> =====
>
> Note the escaping of the backslash and inner pair of braces. I would
> have expected:
>
> =====
> foo\_\{\textbf{bar}\}
> =====
I attach a patch that should solve this (but doesn't handle tables or
fixed-width areas).
Regards,
--
Nicolas Goaziou
>From f906c641d6dc0dce9314ac952e70f8c8ece93d26 Mon Sep 17 00:00:00 2001
From: Nicolas Goaziou <address@hidden>
Date: Mon, 16 Dec 2013 22:01:59 +0100
Subject: [PATCH] ox: Fix export of uninterpreted elements
* lisp/ox.el (org-export-data): Do not check for uninterpreted
elements or objects. These are removed from parse tree anyway.
(org-export--remove-uninterpreted): New function.
(org-export--interpret-p): Removed function.
(org-export-as): Handle uninterpreted elements and objects.
---
lisp/ox.el | 107 ++++++++++++++++++++++++++++++++++++++-----------------------
1 file changed, 67 insertions(+), 40 deletions(-)
diff --git a/lisp/ox.el b/lisp/ox.el
index ad6ee04..44f6241 100644
--- a/lisp/ox.el
+++ b/lisp/ox.el
@@ -2170,10 +2170,8 @@ a tree with a select tag."
;; Internally, three functions handle the filtering of objects and
;; elements during the export. In particular,
;; `org-export-ignore-element' marks an element or object so future
-;; parse tree traversals skip it, `org-export--interpret-p' tells which
-;; elements or objects should be seen as real Org syntax and
-;; `org-export-expand' transforms the others back into their original
-;; shape
+;; parse tree traversals skip it and `org-export-expand' transforms
+;; the others back into their original shape
;;
;; `org-export-transcoder' is an accessor returning appropriate
;; translator function for a given element or object.
@@ -2208,16 +2206,6 @@ Return transcoded string."
(let ((transcoder (org-export-transcoder data info)))
(if transcoder (funcall transcoder data info) data))
info))
- ;; Uninterpreted element/object: change it back to Org
- ;; syntax and export again resulting raw string.
- ((not (org-export--interpret-p data info))
- (org-export-data
- (org-export-expand
- data
- (mapconcat (lambda (blob) (org-export-data blob info))
- (org-element-contents data)
- ""))
- info))
;; Secondary string.
((not type)
(mapconcat (lambda (obj) (org-export-data obj info)) data ""))
@@ -2315,31 +2303,68 @@ recursively convert DATA using BACKEND translation
table."
;; will probably be used on small trees.
:exported-data (make-hash-table :test 'eq :size 401)))))
-(defun org-export--interpret-p (blob info)
- "Non-nil if element or object BLOB should be interpreted during export.
-If nil, BLOB will appear as raw Org syntax. Check is done
-according to export options INFO, stored as a plist."
- (case (org-element-type blob)
- ;; ... entities...
- (entity (plist-get info :with-entities))
- ;; ... emphasis...
- ((bold italic strike-through underline)
- (plist-get info :with-emphasize))
- ;; ... fixed-width areas.
- (fixed-width (plist-get info :with-fixed-width))
- ;; ... LaTeX environments and fragments...
- ((latex-environment latex-fragment)
- (let ((with-latex-p (plist-get info :with-latex)))
- (and with-latex-p (not (eq with-latex-p 'verbatim)))))
- ;; ... sub/superscripts...
- ((subscript superscript)
- (let ((sub/super-p (plist-get info :with-sub-superscript)))
- (if (eq sub/super-p '{})
- (org-element-property :use-brackets-p blob)
- sub/super-p)))
- ;; ... tables...
- (table (plist-get info :with-tables))
- (otherwise t)))
+(defun org-export--remove-uninterpreted (data info)
+ "Change uninterpreted elements back into Org syntax.
+DATA is the parse tree. INFO is a plist containing export
+options."
+ (org-element-map data
+ '(entity bold fixed-width italic latex-environment latex-fragment
+ strike-through subscript superscript underline)
+ (lambda (blob)
+ (let ((type (org-element-type blob))
+ new)
+ (case type
+ ;; ... entities...
+ (entity
+ (unless (plist-get info :with-entities)
+ (setq new (list (org-export-expand blob nil)))))
+ ;; ... emphasis...
+ ((bold italic strike-through underline)
+ (unless (plist-get info :with-emphasize)
+ (let ((marker (case type
+ (bold "*")
+ (italic "/")
+ (strike-through "+")
+ (underline "_"))))
+ (setq new
+ (append
+ (list marker)
+ (org-element-contents blob)
+ (list (concat
+ marker
+ (make-string
+ (or (org-element-property :post-blank blob) 0)
+ ?\s))))))))
+ ;; ... fixed-width areas.
+ (fixed-width
+ (unless (plist-get info :with-fixed-width)
+ (setq new (list (org-export-expand blob nil)))))
+ ;; ... LaTeX environments and fragments...
+ ((latex-environment latex-fragment)
+ (let ((with-latex-p (plist-get info :with-latex)))
+ (when (or (not with-latex-p) (eq with-latex-p 'verbatim))
+ (setq new (list (org-export-expand blob nil))))))
+ ;; ... sub/superscripts...
+ ((subscript superscript)
+ (let ((sub/super-p (plist-get info :with-sub-superscript))
+ (bracketp (org-element-property :use-brackets-p blob)))
+ (unless (if (eq sub/super-p '{}) bracketp sub/super-p)
+ (setq new
+ (append
+ (list (concat (if (eq type 'subscript) "_" "^")
+ (and bracketp "{")))
+ (org-element-contents blob)
+ (list (concat
+ (and bracketp "}")
+ (make-string
+ (or (org-element-property :post-blank blob) 0)
+ ?\s)))))))))
+ (when new
+ (dolist (e new) (org-element-insert-before e blob))
+ (org-element-extract-element blob))))
+ info)
+ ;; Return modified parse tree.
+ data)
(defun org-export-expand (blob contents &optional with-affiliated)
"Expand a parsed element or object to its original state.
@@ -3086,7 +3111,9 @@ Return code as a string."
(setq tree
(org-export-filter-apply-functions
(plist-get info :filter-parse-tree)
- (org-element-parse-buffer nil visible-only) info))
+ (org-export--remove-uninterpreted
+ (org-element-parse-buffer nil visible-only) info)
+ info))
;; Now tree is complete, compute its properties and add them
;; to communication channel.
(setq info
--
1.8.5.1