From mboxrd@z Thu Jan 1 00:00:00 1970 From: Derek Feichtinger Subject: Re: Bug: HTML export of equations leads to error [8.3.3 (8.3.3-17-gce80a0-elpaplus @ /home/dfeich/.emacs.d/elpa/org-plus-contrib-20160118/)] Date: Sun, 24 Jan 2016 15:54:51 +0100 Message-ID: References: Mime-Version: 1.0 Content-Type: multipart/alternative; boundary=047d7b1118ff76a547052a15a25a Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:50382) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aNM46-0000FR-Qd for emacs-orgmode@gnu.org; Sun, 24 Jan 2016 09:54:56 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aNM44-0005Wt-Ps for emacs-orgmode@gnu.org; Sun, 24 Jan 2016 09:54:54 -0500 Received: from mail-ig0-x22b.google.com ([2607:f8b0:4001:c05::22b]:34890) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aNM44-0005Wm-Hm for emacs-orgmode@gnu.org; Sun, 24 Jan 2016 09:54:52 -0500 Received: by mail-ig0-x22b.google.com with SMTP id t15so20223076igr.0 for ; Sun, 24 Jan 2016 06:54:52 -0800 (PST) In-Reply-To: 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 --047d7b1118ff76a547052a15a25a Content-Type: text/plain; charset=UTF-8 Hi I was able to repair the problem by setting the temp buffer that is created within ort-html-format-latex to org-mode. I put the function with the added line marked by PATCH here: #+BEGIN_SRC elisp (defun org-html-format-latex (latex-frag processing-type info) "Format a LaTeX fragment LATEX-FRAG into HTML. PROCESSING-TYPE designates the tool used for conversion. It is a symbol among `mathjax', `dvipng', `imagemagick', `verbatim' nil and t. See `org-html-with-latex' for more information. INFO is a plist containing export properties." (let ((cache-relpath "") (cache-dir "")) (unless (eq processing-type 'mathjax) (let ((bfn (or (buffer-file-name) (make-temp-name (expand-file-name "latex" temporary-file-directory)))) (latex-header (let ((header (plist-get info :latex-header))) (and header (concat (mapconcat (lambda (line) (concat "#+LATEX_HEADER: " line)) (org-split-string header "\n") "\n") "\n"))))) (setq cache-relpath (concat "ltxpng/" (file-name-sans-extension (file-name-nondirectory bfn))) cache-dir (file-name-directory bfn)) ;; Re-create LaTeX environment from original buffer in ;; temporary buffer so that dvipng/imagemagick can properly ;; turn the fragment into an image. (setq latex-frag (concat latex-header latex-frag)))) (with-temp-buffer (insert latex-frag) (org-mode) ; <--- PATCH (org-format-latex cache-relpath cache-dir nil "Creating LaTeX Image..." nil processing-type) (buffer-string)))) #+END_SRC Best regards, Derek On Sun, Jan 24, 2016 at 11:24 AM, Derek Feichtinger wrote: > Dear Org maintainers > > HTML export of equations leads to an error since my last update from > MELPA, yesterday. I can trace it back to the invocation of > org-element-context in a temporary buffer in fundamental mode. A more > exact analysis follows. > > Emacs : GNU Emacs 24.5.1 (x86_64-unknown-linux-gnu, GTK+ Version 3.10.8) > of 2015-05-04 on dflt1w > Package: Org-mode version 8.3.3 (8.3.3-17-gce80a0-elpaplus @ > /home/dfeich/.emacs.d/elpa/org-plus-contrib-20160118/) > > > The error can be reproduced using a minimal org file with these contents: > > #+BEGIN_EXAMPLE > * Equation export error > > This equation produces an error on html export > > $$ > U = R \cdot I > $$ > > #+END_EXAMPLE > > Upon export to html the following error and backtrace result (I took > the liberty of cutting the lines to avoid special characters). > > #+BEGIN_EXAMPLE > Debugger entered--Lisp error: (wrong-type-argument stringp nil) > looking-at(nil) > byte-code("\212\214~\210... > org-element-context() > org-format-latex("" "" nil "Creating LaTeX Image..." nil mathjax) > org-html-format-latex("$$\n ... > org-html-latex-fragment((latex-fragment ... > org-export-data((latex-fragment ... > #[(element)... > mapconcat(#[(element)... > org-export-data((paragraph... > #[(element) "\302... > mapconcat(#[(element)... > org-export-data((section... > #[(element) "\302... > mapconcat(#[(element)... > org-export-data((headline... > #[(element) "\302... > mapconcat(#[(element) "\302... > org-export-data((org-data nil (headline (:raw-value "Equation export > error" :begin 1 :end 108 :pre-blank 1 :contents-begin 26 :contents-end 104 > :level 1 :priority nil :tags nil :todo-keyword nil :todo-type nil > :post-blank 2 :footnote-section-p nil :archivedp nil :commentedp nil > :post-affiliated 1 :title (#("Equation export error" 0 21 (:parent #1))) > :parent #0) (section (:begin 26 :end 108 :contents-begin 26 :contents-end > 104 :post-blank 2 :post-affiliated 26 :parent #1) (paragraph (:begin 26 > :end 76 :contents-begin 26 :contents-end 75 :post-blank 1 :post-affiliated > 26 :parent #2) #("This equation produces an error on html export\n" 0 47 > (:parent #3))) (paragraph (:begin 76 :end 104 :contents-begin 76 > :contents-end 104 :post-blank 0 :post-affiliated 76 :parent #2) "" > (latex-fragment (:value "$$\n U = R \\cdot I\n $$" :begin 78 :end 103 > :post-blank 0 :parent #3)) #("\n" 0 1 (:parent #3)))))) (:export-options > nil :input-buffer "err-example.org" :input-file "/tmp/html-exp-error/ > err-example.org" :html-doctype "xhtml-strict" :html-container "div" > :description nil :keywords nil :html-html5-fancy nil :html-link-use-abs-url > nil :html-link-home "" :html-link-up "" :html-mathjax "" :html-postamble > auto :html-preamble t :html-head "" :html-head-extra "" :subtitle nil > :html-head-include-default-style t :html-head-include-scripts t > :html-allow-name-attribute-in-anchors nil :html-divs ((preamble "div" > "preamble") (content "div" "content") (postamble "div" "postamble")) > :html-checkbox-type ascii :html-extension "html" :html-footnote-format > "%s" :html-footnote-separator ", " ...)) > org-export-as(html nil nil nil (:output-file "./err-example.html")) > org-export-to-file(html "./err-example.html" nil nil nil nil nil) > org-html-export-to-html(nil nil nil nil) > org-export-dispatch(nil) > call-interactively(org-export-dispatch nil nil) > command-execute(org-export-dispatch) > #+END_EXAMPLE > > From the debugger I can see that the org-element-context is executed in a > temporary buffer: > > : Debugger Eval ((point)): 1 > : Debugger Eval (major-mode): fundamental-mode > : Debugger Eval ((buffer-name)): *temp*-831342 > : Debugger Eval ((buffer-string)): $$ > : U = R \cdot I > : $$ > > > I can reproduce the error by creating a file and filling it with the > contents > that "buffer-string" yielded and opening it in fundamental mode. > #+BEGIN_EXAMPLE > $$ > U = R \cdot I > $$ > #+END_EXAMPLE > > When I now execute "org-element-context" with point at 1 then I get the > same error: > > Debugger entered--Lisp error: (wrong-type-argument stringp nil) > looking-at(nil) > byte-code("\212\214~\210... > org-element-context() > eval((org-element-context) nil) > eval-expression((org-element-context) nil) > call-interactively(eval-expression nil nil) > command-execute(eval-expression) > > If the buffer is set to org-mode, the error does not appear, and > org-element-context > correctly recognizes the text as a latex-fragment. > > > Best regards, > Derek > > --047d7b1118ff76a547052a15a25a Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
Hi

I was able to repair the = problem by setting the temp buffer that is created
within ort-htm= l-format-latex to org-mode. I put the function with the
added lin= e marked by PATCH here:

#+BEGIN_SRC elisp
=C2=A0 (defun org-html-format-latex (latex-frag processing-type info)
=C2=A0 =C2=A0 "Format a LaTeX fragment LATEX-FRAG into HTML.
=C2=A0 PROCESSING-TYPE designates the tool used for conversion.=C2= =A0 It is
=C2=A0 a symbol among `mathjax', `dvipng', `ima= gemagick', `verbatim' nil
=C2=A0 and t.=C2=A0 See `org-ht= ml-with-latex' for more information.=C2=A0 INFO is
=C2=A0 a p= list containing export properties."
=C2=A0 =C2=A0 (let ((cac= he-relpath "") (cache-dir ""))
=C2=A0 =C2=A0 = =C2=A0 (unless (eq processing-type 'mathjax)
=C2=A0 =C2=A0 = =C2=A0 =C2=A0 (let ((bfn (or (buffer-file-name)
=C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(make-tem= p-name
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 (expand-file-name "latex" temporary-f= ile-directory))))
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 (latex-header
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0(let ((header (plist-get info :latex-header)))
=C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(and header
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 (concat (mapconcat
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(lambd= a (line) (concat "#+LATEX_HEADER: " line))
=C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0(org-split-string header "\n")
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0"\n")
=C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 "\n")))))
=C2=A0 =C2=A0 =C2=A0= =C2=A0 =C2=A0 (setq cache-relpath
=C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 (concat "ltxpng/"
=C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 (file-name-sans-extension
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(file-name-nondirect= ory bfn)))
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 cache-dir (file-name-directory bfn))
=C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 ;; Re-create LaTeX environment from original buffer in
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 ;; temporary buffer so that dvipng/imag= emagick can properly
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 ;; turn t= he fragment into an image.
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (se= tq latex-frag (concat latex-header latex-frag))))
=C2=A0 =C2=A0 = =C2=A0 (with-temp-buffer
=C2=A0 =C2=A0 =C2=A0 =C2=A0 (insert late= x-frag)
=C2=A0 =C2=A0 =C2=A0 =C2=A0 (org-mode) ; <--- =C2=A0PA= TCH
=C2=A0 =C2=A0 =C2=A0 =C2=A0 (org-format-latex cache-relpath c= ache-dir nil "Creating LaTeX Image..."
=C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 nil processing-type)
=C2=A0 =C2=A0 =C2=A0 =C2=A0 (buffer-stri= ng))))
#+END_SRC

Best regards,
Derek


On Sun, Jan 24, 2016 at 11:24 AM, Derek Feichtinger <dfeic= h@gmail.com> wrote:
Dear Org maintainers

HTML = export of equations leads to an error since my last update from
M= ELPA, yesterday. I can trace it back to the invocation of
org-ele= ment-context in a temporary buffer in fundamental mode. A more
ex= act analysis follows.

Emacs =C2=A0: GNU Emacs 24.5= .1 (x86_64-unknown-linux-gnu, GTK+ Version 3.10.8)
=C2=A0of 2015-= 05-04 on dflt1w
Package: Org-mode version 8.3.3 (8.3.3-17-gce80a0= -elpaplus @ /home/dfeich/.emacs.d/elpa/org-plus-contrib-20160118/)


The error can be reproduced using a minimal= org file with these contents:

#+BEGIN_EXAMPLE
* Equation export error

=C2=A0 This equatio= n produces an error on html export

=C2=A0 $$
=
=C2=A0 =C2=A0 U =3D R \cdot I
=C2=A0 $$

=
#+END_EXAMPLE

Upon export to html the followi= ng error and backtrace result (I took
the liberty of cutting the = lines to avoid special characters).

#+BEGIN_EXAMPL= E
Debugger entered--Lisp error: (wrong-type-argument stringp nil)=
=C2=A0 looking-at(nil)
=C2=A0 byte-code("\212\214= ~\210...
=C2=A0 org-element-context()
=C2=A0 org-format= -latex("" "" nil "Creating LaTeX Image..." ni= l mathjax)
=C2=A0 org-html-format-latex("$$\n ...
= =C2=A0 org-html-latex-fragment((latex-fragment ...
=C2=A0 org-exp= ort-data((latex-fragment ...
=C2=A0 #[(element)...
=C2= =A0 mapconcat(#[(element)...
=C2=A0 org-export-data((paragraph...=
=C2=A0 #[(element) "\302...
=C2=A0 mapconcat(#[(e= lement)...
=C2=A0 org-export-data((section...
=C2=A0 #[= (element) "\302...
=C2=A0 mapconcat(#[(element)...
=C2=A0 org-export-data((headline...
=C2=A0 #[(element) "\30= 2...
=C2=A0 mapconcat(#[(element) "\302...
=C2=A0 = org-export-data((org-data nil (headline (:raw-value "Equation export e= rror" :begin 1 :end 108 :pre-blank 1 :contents-begin 26 :contents-end = 104 :level 1 :priority nil :tags nil :todo-keyword nil :todo-type nil :post= -blank 2 :footnote-section-p nil :archivedp nil :commentedp nil :post-affil= iated 1 :title (#("Equation export error" 0 21 (:parent #1))) :pa= rent #0) (section (:begin 26 :end 108 :contents-begin 26 :contents-end 104 = :post-blank 2 :post-affiliated 26 :parent #1) (paragraph (:begin 26 :end 76= :contents-begin 26 :contents-end 75 :post-blank 1 :post-affiliated 26 :par= ent #2) #("This equation produces an error on html export\n" 0 47= (:parent #3))) (paragraph (:begin 76 :end 104 :contents-begin 76 :contents= -end 104 :post-blank 0 :post-affiliated 76 :parent #2) "" (latex-= fragment (:value "$$\n =C2=A0 =C2=A0U =3D R \\cdot I\n =C2=A0$$" = :begin 78 :end 103 :post-blank 0 :parent #3)) #("\n" 0 1 (:parent= #3)))))) (:export-options nil :input-buffer "err-example.org" :input-file "/t= mp/html-exp-error/err-= example.org" :html-doctype "xhtml-strict" :html-containe= r "div" :description nil :keywords nil :html-html5-fancy nil :htm= l-link-use-abs-url nil :html-link-home "" :html-link-up "&qu= ot; :html-mathjax "" :html-postamble auto :html-preamble t :html-= head "" :html-head-extra "" :subtitle nil :html-head-in= clude-default-style t :html-head-include-scripts t :html-allow-name-attribu= te-in-anchors nil :html-divs ((preamble "div" "preamble"= ;) (content "div" "content") (postamble "div"= "postamble")) :html-checkbox-type ascii :html-extension "ht= ml" :html-footnote-format "<sup>%s</sup>" :html-= footnote-separator "<sup>, </sup>" ...))
= =C2=A0 org-export-as(html nil nil nil (:output-file "./err-example.htm= l"))
=C2=A0 org-export-to-file(html "./err-example.html= " nil nil nil nil nil)
=C2=A0 org-html-export-to-html(nil ni= l nil nil)
=C2=A0 org-export-dispatch(nil)
=C2=A0 call-= interactively(org-export-dispatch nil nil)
=C2=A0 command-execute= (org-export-dispatch)
#+END_EXAMPLE

From= the debugger I can see that the org-element-context is executed in a tempo= rary buffer:

: Debugger Eval ((point)): 1
: Debugger Eval (major-mode): fundamental-mode
: Debugger Eval = ((buffer-name)): =C2=A0*temp*-831342
: Debugger Eval ((buffer-str= ing)): $$
: =C2=A0 =C2=A0 U =3D R \cdot I
: =C2=A0 $$


I can reproduce the error by creatin= g a file and filling it with the contents
that "buffer-strin= g" yielded and opening it in fundamental mode.
#+BEGIN_EXAMP= LE
$$
=C2=A0 =C2=A0 U =3D R \cdot I
$$
<= div>#+END_EXAMPLE

When I now execute "org-ele= ment-context" with point at 1 then I get the
same error:

Debugger entered--Lisp error: (wrong-type-argument st= ringp nil)
=C2=A0 looking-at(nil)
=C2=A0 byte-code(&quo= t;\212\214~\210...
=C2=A0 org-element-context()
=C2=A0 = eval((org-element-context) nil)
=C2=A0 eval-expression((org-eleme= nt-context) nil)
=C2=A0 call-interactively(eval-expression nil ni= l)
=C2=A0 command-execute(eval-expression)

If the buffer is set to org-mode, the error does not appear, and org-ele= ment-context
correctly recognizes the text as a latex-fragment.


Best regards,
Derek
<= /div>


--047d7b1118ff76a547052a15a25a--