emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* 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/)]
@ 2016-01-24 10:24 Derek Feichtinger
  2016-01-24 14:54 ` Derek Feichtinger
  0 siblings, 1 reply; 4+ messages in thread
From: Derek Feichtinger @ 2016-01-24 10:24 UTC (permalink / raw)
  To: emacs-orgmode

[-- Attachment #1: Type: text/plain, Size: 4391 bytes --]

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
"<sup>%s</sup>" :html-footnote-separator "<sup>, </sup>" ...))
  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

[-- Attachment #2: Type: text/html, Size: 5940 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

* 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/)]
  2016-01-24 10:24 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/)] Derek Feichtinger
@ 2016-01-24 14:54 ` Derek Feichtinger
  2016-01-24 17:18   ` Nicolas Goaziou
  0 siblings, 1 reply; 4+ messages in thread
From: Derek Feichtinger @ 2016-01-24 14:54 UTC (permalink / raw)
  To: emacs-orgmode

[-- Attachment #1: Type: text/plain, Size: 6620 bytes --]

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 <dfeich@gmail.com>
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
> "<sup>%s</sup>" :html-footnote-separator "<sup>, </sup>" ...))
>   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
>
>

[-- Attachment #2: Type: text/html, Size: 9113 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

* 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/)]
  2016-01-24 14:54 ` Derek Feichtinger
@ 2016-01-24 17:18   ` Nicolas Goaziou
  2016-01-24 21:55     ` Derek Feichtinger
  0 siblings, 1 reply; 4+ messages in thread
From: Nicolas Goaziou @ 2016-01-24 17:18 UTC (permalink / raw)
  To: Derek Feichtinger; +Cc: emacs-orgmode

Hello,

Derek Feichtinger <dfeich@gmail.com> writes:

> 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:

Thank you. However, I think it only papers over the problem: I see no
reason for the parser to fail in fundamental mode.

I cannot reproduce the error, neither on master nor on maint. OTOH,
there was a bug related to $$...$$ constructs, which I fixed.

Could you try again? Also, if the problem persists, could you send
a full backtrace, without compiling Org?

Thank you.

Regards,

-- 
Nicolas Goaziou

^ permalink raw reply	[flat|nested] 4+ messages in thread

* 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/)]
  2016-01-24 17:18   ` Nicolas Goaziou
@ 2016-01-24 21:55     ` Derek Feichtinger
  0 siblings, 0 replies; 4+ messages in thread
From: Derek Feichtinger @ 2016-01-24 21:55 UTC (permalink / raw)
  To: Derek Feichtinger, emacs-orgmode

[-- Attachment #1: Type: text/plain, Size: 1032 bytes --]

Hello

On Sun, Jan 24, 2016 at 6:18 PM, Nicolas Goaziou <mail@nicolasgoaziou.fr>
wrote:

> Hello,
>
> Derek Feichtinger <dfeich@gmail.com> writes:
>
> > 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:
>
> Thank you. However, I think it only papers over the problem: I see no
> reason for the parser to fail in fundamental mode.
>
> I cannot reproduce the error, neither on master nor on maint. OTOH,
> there was a bug related to $$...$$ constructs, which I fixed.
>
> Could you try again? Also, if the problem persists, could you send
> a full backtrace, without compiling Org?
>
>
I discovered some files from a previous package installation that somehow
had not been cleaned up completely. After removing the older directory, the
error does not appear again, so it must have been due to an interference.
Sorry for having led you onto a wild goose chase.

Thanks a lot for your help,
Derek

[-- Attachment #2: Type: text/html, Size: 1556 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2016-01-24 21:55 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-01-24 10:24 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/)] Derek Feichtinger
2016-01-24 14:54 ` Derek Feichtinger
2016-01-24 17:18   ` Nicolas Goaziou
2016-01-24 21:55     ` Derek Feichtinger

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).