emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [O] [patch][ox-latex] context-aware subscript


From: Nicolas Goaziou
Subject: Re: [O] [patch][ox-latex] context-aware subscript
Date: Sat, 31 Aug 2013 16:46:14 +0200

Rasmus <address@hidden> writes:

> What I do in the patch is that I apply the filters within the
> function

Why is that? `org-export-data' already takes care of filters. These
calls are redundant.

> Also, filters using a regexp with "\text{whatever}" wouldn't work.

I don't get it.

>>> +   (scripts '(subscript superscript)))
>>> +    (if (not (org-element-property :latex-math-p entity)) ent
>>> +      (concat
>>> +       (if (and no-pre-blanks-p
>>> +           (memq (org-element-type prev) scripts)
>>> +           (not (eq (org-export-data prev info) "")))
>>> +      "" "$")
>>> +       ent
>>> +       (if (and no-post-blanks-p
>>> +           (memq (org-element-type next) scripts)
>>> +           (not (eq (org-export-data next info) "")))
>>> +      "" "$")))))
>>
>> I think this is problematic: if an entity needs to export both the
>> previous and the next object, what happens when we have two consecutive
>> entities? An infloop?
>
> I agree, but I haven't been able to cause any nasty behavior. I've
> probably neglected some case.  These works fine
>
>   1. \alpha\beta_t : \alpha is not a subscript
>   2. \alpha\beta_\xi\nu : runs OK recursively.

There's still some infloop smell around this code. Perhaps with
something like the following (untested):

  A_b^c

> On 2.: on my system I've tried with many entities (around 500).  It
> works, but obviously it's slow due to the recursiveness.This is very
> nasty.  I don't know if some other mechanism can be derived, tho. . .

`org-export-data' caches its results, so calling it more than once on
the same object/element isn't really costly.

> +  (let* ((ent (org-element-property :latex entity))
> +      (prev (org-export-get-previous-element entity info))
> +      (next (org-export-get-next-element entity info))
> +      (no-post-blanks-p (= (or (org-element-property :post-blank entity) 0) 
> 0))

aka `zerop' (slightly easier to read).

> +      (no-pre-blanks-p (= (or (org-element-property :post-blank prev) 0) 0))


Ditto.

> +      (scripts '(subscript superscript)))
> +
> +    (if (not (org-element-property :latex-math-p entity)) ent
> +      (concat
> +       (if (and no-pre-blanks-p
> +             (memq (org-element-type prev) scripts)
> +             ;; check if nil
> +             (org-export-data prev info))
> +        "" "$")
> +       ent
> +       (if (and no-post-blanks-p
> +             (memq (org-element-type next) scripts)
> +             ;; check if nil
> +             (org-export-data next info))

You don't need to check for nil. `org-export-data' returns nil when the
element or object is ignored. But `org-export-get-previous-element'
never returns ignored objects or elements.

> +        (let ((out (or (org-export-filter-apply-functions
> +                        org-export-filter-subscript-functions
> +                        (org-export-data obj info)
> +                        info) "")))

See above.

Thanks again.


Regards,

-- 
Nicolas Goaziou



reply via email to

[Prev in Thread] Current Thread [Next in Thread]