From mboxrd@z Thu Jan 1 00:00:00 1970 From: Nicolas Goaziou Subject: Re: [patch][ox-latex] context-aware subscript Date: Sat, 31 Aug 2013 10:11:57 +0200 Message-ID: <87k3j2nusy.fsf@gmail.com> References: <877gfjqq6w.fsf@pank.eu> <87tximt7bb.fsf@gmail.com> <87r4deqbav.fsf@gmx.us> <874naaorz1.fsf@gmail.com> <8761uqorlr.fsf@gmx.us> <87sixty63g.fsf@gmail.com> <87vc2oojnx.fsf@gmx.us> Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:48373) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VFgHf-0007kO-2X for emacs-orgmode@gnu.org; Sat, 31 Aug 2013 04:11:57 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VFgHZ-0003gA-8P for emacs-orgmode@gnu.org; Sat, 31 Aug 2013 04:11:51 -0400 Received: from mail-ea0-x22c.google.com ([2a00:1450:4013:c01::22c]:49325) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VFgHZ-0003g4-1R for emacs-orgmode@gnu.org; Sat, 31 Aug 2013 04:11:45 -0400 Received: by mail-ea0-f172.google.com with SMTP id r16so1321665ead.17 for ; Sat, 31 Aug 2013 01:11:43 -0700 (PDT) In-Reply-To: <87vc2oojnx.fsf@gmx.us> (rasmus@gmx.us's message of "Thu, 29 Aug 2013 12:50:26 +0200") 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: Rasmus Cc: emacs-orgmode@gnu.org Hello, Rasmus writes: > I've just enclosed a quick patch (as in doesn't contain proper commit > msg), but it's basically the previous patch minus the removal of \text > in math plus some quick checks towards potential nasty filters. > > It works with the following test file, but let me know about more > hair-pulling test cases, and/or filters. Thanks for the patch. Here are a few comments. > filter replace all & $\beta_{\text{}}$ & \texttimes{}$_{\text{}}$ \\ We might be able to handle it more nicely, i.e. by skipping \text when contents are empty. > + (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) 1) 0)) > + (no-pre-blanks-p (= (or (org-element-property :post-blank > + (org-export-get-previous-element > + entity info)) 1) 0)) A nil :post-blank property means 0, not 1. Also, you don't re-use PREV in NO-PRE-BLANKS-P. > + (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? This is the difficult part of the problem. > + (not (org-element-property :latex-math-p prev)) Sure, but I'd rather make a stricter check and also test PREV's type. Regards, -- Nicolas Goaziou