Re: [O] [bug, ox-latex] footnotes with math in narrowed buffer

2015-04-25 Thread Nicolas Goaziou
Rasmus ras...@gmx.us writes:

 Nicolas Goaziou m...@nicolasgoaziou.fr writes:

 `org-html--build-mathjax-config' needs to check, in addition to parse
 tree, cdr of all associations in (plist-get
 info :footnote-definition-alist), and values of all parsed keywords.

 It seems you did not do this.  I will add this over the weekend.

Actually, it isn't a very good idea because we cannot assume all parsed
keywords and all footnote definitions will actually be used to create
the document. This can introduce false positives.

What about inserting a :with-mathjax option (default value
`org-html-with-mathjax'). If nil, no template, if t, template, if
`auto', current behaviour (i.e. template if some math snippet /in
body/)?

`auto' is a decent default value for `org-html-with-mathjax' and it can
be overridden per document with :with-mathjax.


Regards,



Re: [O] [bug, ox-latex] footnotes with math in narrowed buffer

2015-04-25 Thread Rasmus
Nicolas Goaziou m...@nicolasgoaziou.fr writes:

 Rasmus ras...@gmx.us writes:

 Nicolas Goaziou m...@nicolasgoaziou.fr writes:

 `org-html--build-mathjax-config' needs to check, in addition to parse
 tree, cdr of all associations in (plist-get
 info :footnote-definition-alist), and values of all parsed keywords.

 It seems you did not do this.  I will add this over the weekend.

 Actually, it isn't a very good idea because we cannot assume all parsed
 keywords and all footnote definitions will actually be used to create
 the document. This can introduce false positives.

OK.

 What about inserting a :with-mathjax option (default value
 `org-html-with-mathjax'). If nil, no template, if t, template, if
 `auto', current behafviour (i.e. template if some math snippet /in
 body/)?

OK.

 `auto' is a decent default value for `org-html-with-mathjax' and it can
 be overridden per document with :with-mathjax.

I guess the example I showed is a limitation that we can live with.  Also
it's pretty unlikely that you /only/ have math in footnotes.

—Rasmus

-- 
With monopolies the cake is a lie!



[O] [bug, ox-latex] footnotes with math in narrowed buffer

2015-04-24 Thread Rasmus
Hi,

Consider the following example:

* h1
foo[fn:1]

* Footnotes
[fn:1] if \alpha $\beta$ \(\gamma\)

Narrow it to h1 and export the buffer.  Something like this is exported:

   foo\footnote{if \alpha \beta \gamma}

Somehow org-export-get-footnote-definition knows about math-blocks for
footnotes that are within the buffer view, but not outside.  The patch
fixes the above example, but I doubt it's the Right Wayᵀᴹ to fix this
(i.e. there could be a more fundamental bug).

—Rasmus

-- 
Bang bang
From ce22e0e6d92b79cfec41c1a2295f8e0a21cc3775 Mon Sep 17 00:00:00 2001
From: Rasmus ras...@gmx.us
Date: Fri, 24 Apr 2015 18:00:30 +0200
Subject: [PATCH 2/2] ox-latex: Fix footnote bug when narrowed buffer

* ox-latex.el (org-latex-footnote-reference): Support math in outside
  footnotes when narrowed.
---
 lisp/ox-latex.el | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/lisp/ox-latex.el b/lisp/ox-latex.el
index 2d7ffe5..3b71bfb 100644
--- a/lisp/ox-latex.el
+++ b/lisp/ox-latex.el
@@ -1554,7 +1554,8 @@ CONTENTS is nil.  INFO is a plist holding contextual information.
  \\footnotemark)
 ;; Otherwise, define it with \footnote command.
 (t
- (let ((def (org-export-get-footnote-definition footnote-reference info)))
+ (let ((def (org-latex--wrap-latex-math-block
+		 (org-export-get-footnote-definition footnote-reference info) info)))
(concat
 	(format \\footnote{%s} (org-trim (org-export-data def info)))
 	;; Retrieve all footnote references within the footnote and
-- 
2.3.6



Re: [O] [bug, ox-latex] footnotes with math in narrowed buffer

2015-04-24 Thread Rasmus
Rasmus ras...@gmx.us writes:

 * h1
 foo[fn:1]

 * Footnotes
 [fn:1] if \alpha $\beta$ \(\gamma\)

 Narrow it to h1 and export the buffer.  Something like this is exported:

This also does not seem to work correctly when exporting with ox-html.
But there the problem is that the parse-tree does not recognize any
latex-fragments.  So org-html--build-mathjax-config returns nil rather
than the appropriate mathjax setup.

BTW: While it's nice to try to make a sensible decision on whether to load
mathjax, this rest of pretty fragile assumptions.  I could INCLUDE a html
file with math.

—Rasmus

-- 
Enough with the bla bla!




Re: [O] [bug, ox-latex] footnotes with math in narrowed buffer

2015-04-24 Thread Rasmus
Rasmus ras...@gmx.us writes:

 Rasmus ras...@gmx.us writes:

 * h1
 foo[fn:1]

 * Footnotes
 [fn:1] if \alpha $\beta$ \(\gamma\)

 Narrow it to h1 and export the buffer.  Something like this is exported:

 This also does not seem to work correctly when exporting with ox-html.
 But there the problem is that the parse-tree does not recognize any
 latex-fragments.  So org-html--build-mathjax-config returns nil rather
 than the appropriate mathjax setup.

Add to this that the class of p is missing when including footnotes
from outside of the narrowed region.  E.g.
 p bar /p 
(ugly) vs (not ugly):
 p class=footpara bar /p

—Rasmus

-- 
The right to be left alone is a human right




Re: [O] [bug, ox-latex] footnotes with math in narrowed buffer

2015-04-24 Thread Nicolas Goaziou
Hello,

Rasmus ras...@gmx.us writes:

 Consider the following example:

 * h1
 foo[fn:1]

 * Footnotes
 [fn:1] if \alpha $\beta$ \(\gamma\)

 Narrow it to h1 and export the buffer.  Something like this is exported:

foo\footnote{if \alpha \beta \gamma}

 Somehow org-export-get-footnote-definition knows about math-blocks for
 footnotes that are within the buffer view, but not outside.  The patch
 fixes the above example, but I doubt it's the Right Wayᵀᴹ to fix this
 (i.e. there could be a more fundamental bug).

It looks good. You can push it. Thank you.


Regards,

-- 
Nicolas Goaziou



Re: [O] [bug, ox-latex] footnotes with math in narrowed buffer

2015-04-24 Thread Nicolas Goaziou
Hello,

Rasmus ras...@gmx.us writes:

 Rasmus ras...@gmx.us writes:

 Rasmus ras...@gmx.us writes:

 * h1
 foo[fn:1]

 * Footnotes
 [fn:1] if \alpha $\beta$ \(\gamma\)

 Narrow it to h1 and export the buffer.  Something like this is exported:

[...]

 Add to this that the class of p is missing when including footnotes
 from outside of the narrowed region.  E.g.
  p bar /p 
 (ugly) vs (not ugly):
  p class=footpara bar /p

This should be fixed. Thank you.

Regards,

-- 
Nicolas Goaziou



Re: [O] [bug, ox-latex] footnotes with math in narrowed buffer

2015-04-24 Thread Nicolas Goaziou
Hello,

Rasmus ras...@gmx.us writes:

 Rasmus ras...@gmx.us writes:

 * h1
 foo[fn:1]

 * Footnotes
 [fn:1] if \alpha $\beta$ \(\gamma\)

 Narrow it to h1 and export the buffer.  Something like this is exported:

 This also does not seem to work correctly when exporting with ox-html.
 But there the problem is that the parse-tree does not recognize any
 latex-fragments.  So org-html--build-mathjax-config returns nil rather
 than the appropriate mathjax setup.

`org-html--build-mathjax-config' needs to check, in addition to parse
tree, cdr of all associations in (plist-get
info :footnote-definition-alist), and values of all parsed keywords.

 BTW: While it's nice to try to make a sensible decision on whether to load
 mathjax, this rest of pretty fragile assumptions.  I could INCLUDE a html
 file with math.

What do you suggest instead? Load mathjax every time?

Regards,

-- 
Nicolas Goaziou



Re: [O] [bug, ox-latex] footnotes with math in narrowed buffer

2015-04-24 Thread Rasmus
Hi,

Nicolas Goaziou m...@nicolasgoaziou.fr writes:

 * h1
 foo[fn:1]

 * Footnotes
 [fn:1] if \alpha $\beta$ \(\gamma\)

 Narrow it to h1 and export the buffer.  Something like this is exported:

 This also does not seem to work correctly when exporting with ox-html.
 But there the problem is that the parse-tree does not recognize any
 latex-fragments.  So org-html--build-mathjax-config returns nil rather
 than the appropriate mathjax setup.

 `org-html--build-mathjax-config' needs to check, in addition to parse
 tree, cdr of all associations in (plist-get
 info :footnote-definition-alist), and values of all parsed keywords.

It seems you did not do this.  I will add this over the weekend.

 BTW: While it's nice to try to make a sensible decision on whether to load
 mathjax, this rest of pretty fragile assumptions.  I could INCLUDE a html
 file with math.

 What do you suggest instead? Load mathjax every time?

Perhaps.  It's a tough call.  On the one hand the current behavior very
much seems like the famous smart can of worms.  On the other hand,
unnecessary JS should be avoided at very high costs.

Perhaps it's enough to check is mathjax or latex math has been explicitly
set for these corner cases.

—Rasmus

-- 
Hvor meget poesi tror De kommer ud af et glas isvand?




Re: [O] [bug, ox-latex] footnotes with math in narrowed buffer

2015-04-24 Thread Rasmus
Nicolas Goaziou m...@nicolasgoaziou.fr writes:

 Hello,

 Rasmus ras...@gmx.us writes:

 Consider the following example:

 * h1
 foo[fn:1]

 * Footnotes
 [fn:1] if \alpha $\beta$ \(\gamma\)

 Narrow it to h1 and export the buffer.  Something like this is exported:

foo\footnote{if \alpha \beta \gamma}

 Somehow org-export-get-footnote-definition knows about math-blocks for
 footnotes that are within the buffer view, but not outside.  The patch
 fixes the above example, but I doubt it's the Right Wayᵀᴹ to fix this
 (i.e. there could be a more fundamental bug).

 It looks good. You can push it. Thank you.

Pushed.

-- 
This message is brought to you by the department of redundant departments