From mboxrd@z Thu Jan 1 00:00:00 1970 From: Rasmus Subject: Re: [bug?, org-element] latex-environment delimiters must be at BOL Date: Fri, 18 Jul 2014 17:49:49 +0200 Message-ID: <87vbqu1xb6.fsf@gmx.us> References: <877g3ltomt.fsf@gmx.us> <87iomxjvyv.fsf@nicolasgoaziou.fr> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:59672) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1X8AQ5-0005Zf-7V for emacs-orgmode@gnu.org; Fri, 18 Jul 2014 11:50:07 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1X8APz-0006r3-68 for emacs-orgmode@gnu.org; Fri, 18 Jul 2014 11:50:01 -0400 Received: from mout.gmx.net ([212.227.15.15]:50625) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1X8APy-0006qY-T2 for emacs-orgmode@gnu.org; Fri, 18 Jul 2014 11:49:55 -0400 Received: from W530 ([46.166.186.234]) by mail.gmx.com (mrgmx003) with ESMTPSA (Nemesis) id 0M1n4s-1WFnRU2sCQ-00thdd for ; Fri, 18 Jul 2014 17:49:50 +0200 In-Reply-To: <87iomxjvyv.fsf@nicolasgoaziou.fr> (Nicolas Goaziou's message of "Wed, 16 Jul 2014 15:04:40 +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: emacs-orgmode@gnu.org Hi Nicolas, Nicolas Goaziou writes: > Rasmus writes: > >> Looking at org-element-latex-environment-parser LaTeX environments are >> recognized as "[ \t]*\\\\begin{\\([A-Za-z0-9]+\\*?\\)}" (for start) >> and "^[ \t]*\\\\end{%s}[ \t]*$" (for the end). >> >> However, for e.g. small equations one might want to write >> >> (*) \begin{equation} PLACEHOLDER \end{equation}, >> >> i.e. in one line. This fails to be recognized as the latter regexp is >> not satisfied. For code generated by humans this is not an issue. >> However, e.g. SymPy generates code in the (*) format. Prefixing (*) >> with "#+LATEX:" will prevent ox-html from recognizing it. >> >> Should org-element try to catch one-line environments as the one >> above? Or is it "a can of worms"? > > I think allowing them is possible, as long as \end{equation} ends the > last line (with trailing whitespaces tolerated). > > I assume that, for simplicity, PLACEHOLDER could be longer than one > line, too. > > If Bastien agrees and if you want to provide a patch, please be sure to > include tests in test-org-element.el, and appropriate changes to "Org > Syntax" document. The manual may need to be updated, too. Thanks for your comments. I changed a couple of things, and org-element now recognizes what I wanted it to recognize. Next step: don't break anything. To test for immediate breakages I do: 1. Install latest version of org (beta_8.3-15-g224105) on my /usr folder and start emacs=C2=A0-q. Run tests as specified in testing/readme. I get 12 failed (1 unexpected). 2. Load my modified org-element.el file and rerun tests. The only new fail is this one, that is to be expected to fail. (should-not (eq 'latex-environment (org-test-with-temp-text "\\begin{env}{arg} something\nvalue= \n\\end{env}" (org-element-type (org-element-at-point))))) Hence, my question is: Can I now assume that my modification are now somewhat safe wrt. the current Org syntax? I have a case that I worry a bit about, namely broken LaTeX code with mismatching no. of begin/end tags: Consider: #+begin_src org=20 \begin{equation} x^2_3 \begin{equation} x^2_3 \end{equation} #+end_src With my patch, this will produce (*): #+begin_src latex \begin{equation} x^2_3 \begin{equation} x^2_3 \end{equation} #+end_src latex Before it would produce #+begin_src latex \begin{equation} x\(^{\text{2}}_{\text{3}}\) \begin{equation} x\(^{\text{2}}_{\text{3}}\) \end{equation} #+end_src latex Both will break when compiled. With some more newlines in the Org-code, I can get this without my patches #+begin_src latex \begin{equation}=20 x^2_3 \begin{equation}=20 x^2_3 \end{equation} #+end_src latex =20 which is identical to (*) to a LaTeX compiler. Should I worry about such changes to behavior? I will write some tests and review the two documents you mention and submit a patch ASAP. Cheers, Rasmus --=20 I hear there's rumors on the, uh, Internets. . .