emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* HTML export doesn't convert quote before footnote
@ 2014-01-08  2:09 James Harkins
  2014-01-08  5:03 ` Nick Dokos
  2014-01-08 15:33 ` Nicolas Goaziou
  0 siblings, 2 replies; 9+ messages in thread
From: James Harkins @ 2014-01-08  2:09 UTC (permalink / raw)
  To: orgmode

This appears to be an HTML export bug: A straight double-quote mark before 
a footnote fails to convert into ”

Minimal example:

* Heading
Krusty the Klown opined, "Well, that's showbiz for ya."[fn:1]
* Footnotes
[fn:1] /The Simpsons/.

Expected:

<p>
Krusty the Klown opined, &ldquo;Well, that&rsquo;s showbiz for 
ya.&rdquo;<sup><a id="fnr.1" name="fnr.1" class="footref" 
href="#fn.1">1</a></sup>
</p>

Got:

<p>
Krusty the Klown opined, &ldquo;Well, that&rsquo;s showbiz for ya."<sup><a 
id="fnr.1" name="fnr.1" class="footref" href="#fn.1">1</a></sup>
</p>

I guess I can filter for it as a workaround.

hjh

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

* Re: HTML export doesn't convert quote before footnote
  2014-01-08  2:09 HTML export doesn't convert quote before footnote James Harkins
@ 2014-01-08  5:03 ` Nick Dokos
  2014-01-08 15:33 ` Nicolas Goaziou
  1 sibling, 0 replies; 9+ messages in thread
From: Nick Dokos @ 2014-01-08  5:03 UTC (permalink / raw)
  To: emacs-orgmode

James Harkins <jamshark70@gmail.com> writes:

> This appears to be an HTML export bug: A straight double-quote mark
> before a footnote fails to convert into &rdquo;
>
> Minimal example:
>
> * Heading
> Krusty the Klown opined, "Well, that's showbiz for ya."[fn:1]
> * Footnotes
> [fn:1] /The Simpsons/.
>
> Expected:
>
> <p>
> Krusty the Klown opined, &ldquo;Well, that&rsquo;s showbiz for
> ya.&rdquo;<sup><a id="fnr.1" name="fnr.1" class="footref"
> href="#fn.1">1</a></sup>
> </p>
>
> Got:
>
> <p>
> Krusty the Klown opined, &ldquo;Well, that&rsquo;s showbiz for
> ya."<sup><a id="fnr.1" name="fnr.1" class="footref"
> href="#fn.1">1</a></sup>
> </p>
>

FWIW, I tried it and I get a different behavior: neither the opening quote
nor the closing quote is touched. I get:

,----
| <p>
| Krusty the Klown opined, "Well, that's showbiz for ya."<sup><a id="fnr.1" name="fnr.1" class="footref" href="#fn.1">1</a></sup>
| </p>
`----

Org-mode version 8.2.5c (release_8.2.5c-430-gf8e174)

-- 
Nick

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

* Re: HTML export doesn't convert quote before footnote
  2014-01-08  2:09 HTML export doesn't convert quote before footnote James Harkins
  2014-01-08  5:03 ` Nick Dokos
@ 2014-01-08 15:33 ` Nicolas Goaziou
  2014-01-08 15:50   ` James Harkins
  1 sibling, 1 reply; 9+ messages in thread
From: Nicolas Goaziou @ 2014-01-08 15:33 UTC (permalink / raw)
  To: James Harkins; +Cc: orgmode

Hello,

James Harkins <jamshark70@gmail.com> writes:

> This appears to be an HTML export bug: A straight double-quote mark
> before a footnote fails to convert into &rdquo;
>
> Minimal example:
>
> * Heading
> Krusty the Klown opined, "Well, that's showbiz for ya."[fn:1]
> * Footnotes
> [fn:1] /The Simpsons/.
>
> Expected:
>
> <p>
> Krusty the Klown opined, &ldquo;Well, that&rsquo;s showbiz for
> ya.&rdquo;<sup><a id="fnr.1" name="fnr.1" class="footref"
> href="#fn.1">1</a></sup>
> </p>
>
> Got:
>
> <p>
> Krusty the Klown opined, &ldquo;Well, that&rsquo;s showbiz for
> ya."<sup><a id="fnr.1" name="fnr.1" class="footref"
> href="#fn.1">1</a></sup>
> </p>
>
> I guess I can filter for it as a workaround.

Smart quotes mechanism is based on regexps. There are unavoidable
ambiguous cases, like this one. We can pile up new rules to handle most
of them, but in the end, I don't think we cannot handle them all. Worse,
some advanced rules may create false positives.

Anyway, here are some options :

  1. Do nothing.

  2. Change the closing regexp to
     "\\(?:\\w\\|\\s.\\|\\s_\\)\\([\"']\\)", i.e. ignore characters
     after the quote. But then we have to find a way to know a closing
     single quote from an apostrophe.

  3. Do not rely on regexps but on some simple depth rules:

     1. At a given level in the parse tree, the first quote is always an
        opening quote ;

     2. Every subsequent quote in the level alternates between closing
        and opening state.

Second option probably has its shortcomings too, but it may be sturdier.
It also doesn't solve the problem of apostrophes.


Regards,

-- 
Nicolas Goaziou

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

* Re: HTML export doesn't convert quote before footnote
  2014-01-08 15:33 ` Nicolas Goaziou
@ 2014-01-08 15:50   ` James Harkins
  2014-01-08 16:37     ` Nicolas Goaziou
  0 siblings, 1 reply; 9+ messages in thread
From: James Harkins @ 2014-01-08 15:50 UTC (permalink / raw)
  To: Nicolas Goaziou; +Cc: orgmode

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

On Jan 8, 2014 11:33 PM, "Nicolas Goaziou" <n.goaziou@gmail.com> wrote:
> Smart quotes mechanism is based on regexps. There are unavoidable
> ambiguous cases, like this one.

But the export is as expected in LaTeX, so... If the LaTeX backend can
interpret the input properly, why not the html backend?

hjh

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

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

* Re: HTML export doesn't convert quote before footnote
  2014-01-08 15:50   ` James Harkins
@ 2014-01-08 16:37     ` Nicolas Goaziou
  2014-01-09  2:13       ` James Harkins
  0 siblings, 1 reply; 9+ messages in thread
From: Nicolas Goaziou @ 2014-01-08 16:37 UTC (permalink / raw)
  To: jamshark70; +Cc: orgmode

James Harkins <jamshark70@gmail.com> writes:

> On Jan 8, 2014 11:33 PM, "Nicolas Goaziou" <n.goaziou@gmail.com> wrote:
>> Smart quotes mechanism is based on regexps. There are unavoidable
>> ambiguous cases, like this one.
>
> But the export is as expected in LaTeX, so...

It isn't. Look at the LaTeX code produced.


Regards,

-- 
Nicolas Goaziou

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

* Re: HTML export doesn't convert quote before footnote
  2014-01-08 16:37     ` Nicolas Goaziou
@ 2014-01-09  2:13       ` James Harkins
  2014-01-09  3:03         ` James Harkins
  0 siblings, 1 reply; 9+ messages in thread
From: James Harkins @ 2014-01-09  2:13 UTC (permalink / raw)
  To: Nicolas Goaziou; +Cc: orgmode

On Thursday, January 9, 2014 12:37:39 AM HKT, Nicolas Goaziou wrote:
>> On Jan 8, 2014 11:33 PM, "Nicolas Goaziou" <n.goaziou@gmail.com> wrote:
>>> Smart quotes mechanism is based on regexps. There are unavoidable
>>> ambiguous cases, like this one.
>> 
>> But the export is as expected in LaTeX, so...
>
> It isn't. Look at the LaTeX code produced.

Ah, I see. LaTeX displays the closing curly quote I wanted if I have this 
in the preamble.

#+LATEX_HEADER: \usepackage[no-math]{fontspec}
#+LATEX_HEADER: \setmainfont[Ligatures={Common,TeX}]{CharisSIL}

If I leave that out, then the appearance in the PDF matches the straight 
closing quote that ox-latex generates.

OK, I'll work around it on my side.

hjh

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

* Re: HTML export doesn't convert quote before footnote
  2014-01-09  2:13       ` James Harkins
@ 2014-01-09  3:03         ` James Harkins
  2014-01-09 11:07           ` Nicolas Goaziou
  0 siblings, 1 reply; 9+ messages in thread
From: James Harkins @ 2014-01-09  3:03 UTC (permalink / raw)
  To: orgmode

On Thursday, January 9, 2014 10:13:32 AM HKT, James Harkins wrote:
> OK, I'll work around it on my side.

Continuing... I've tried to write a filter for this, but I'm stuck on 
choosing strings based on the backend name.

(cdr (assoc
			  (org-export-backend-name backend)
			  '((latex . "\"\\footnote") (html . "\"<sup><a"))))

Apparently org-export-backend-name returns neither a symbol nor a string.

What does it return? Or, what is the right way to look up a value based on 
the backend name?

hjh

(defun hjh-quote-before-footnote (contents backend info)
  "Convert '\"[fn' to the appropriate closing quote per backend."
  (when (and (and
	      (org-export-derived-backend-p backend 'latex 'html)
	      (plist-get info :with-smart-quotes))
	     (let ((teststring
		    (cdr (assoc
			  (org-export-backend-name backend)
			  '((latex . "\"\\footnote") (html . "\"<sup><a"))))))
	     (string-match teststring contents)))
    (let ((replacements '((latex . "''[fn") (html . "&rdquo;[fn")))
	  (replacement (assoc (org-export-backend-name backend) replacements)))
      (replace-match (cdr replacement) nil nil contents))))

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

* Re: HTML export doesn't convert quote before footnote
  2014-01-09  3:03         ` James Harkins
@ 2014-01-09 11:07           ` Nicolas Goaziou
  2014-01-11  2:45             ` James Harkins
  0 siblings, 1 reply; 9+ messages in thread
From: Nicolas Goaziou @ 2014-01-09 11:07 UTC (permalink / raw)
  To: James Harkins; +Cc: orgmode

Hello,

James Harkins <jamshark70@gmail.com> writes:

> On Thursday, January 9, 2014 10:13:32 AM HKT, James Harkins wrote:
>> OK, I'll work around it on my side.
>
> Continuing... I've tried to write a filter for this, but I'm stuck on
> choosing strings based on the backend name.
>
> (cdr (assoc
> 			  (org-export-backend-name backend)
> 			  '((latex . "\"\\footnote") (html . "\"<sup><a"))))
>
> Apparently org-export-backend-name returns neither a symbol nor
> a string.

That's because BACKEND is already a symbol, not a real back-end (i.e.
a defstruct).  Thus, you can use:

  (cdr (assq backend ...) ...)



Regards,

-- 
Nicolas Goaziou

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

* Re: HTML export doesn't convert quote before footnote
  2014-01-09 11:07           ` Nicolas Goaziou
@ 2014-01-11  2:45             ` James Harkins
  0 siblings, 0 replies; 9+ messages in thread
From: James Harkins @ 2014-01-11  2:45 UTC (permalink / raw)
  To: Nicolas Goaziou; +Cc: orgmode

On Thursday, January 9, 2014 7:07:15 PM HKT, Nicolas Goaziou wrote:
> Hello,
>
> James Harkins <jamshark70@gmail.com> writes:
>
>> On Thursday, January 9, 2014 10:13:32 AM HKT, James Harkins wrote:
>  ...
>
> That's because BACKEND is already a symbol, not a real back-end (i.e.
> a defstruct).  Thus, you can use:
>
>   (cdr (assq backend ...) ...)

And, I have a working filter now.

(defun hjh-quote-before-footnote (contents backend info)
  "Convert '\"[fn' to the appropriate closing quote per backend."
  (when (and (and
	      (org-export-derived-backend-p backend 'latex 'html)
	      (plist-get info :with-smart-quotes))
	     (let ((teststring
		    (cdr (assq backend
			       '((latex . "\"\\\\footnote") (html . "\"<sup><a"))))))
	     (string-match teststring contents)))
    (let* ((replacements '((latex . "''\\\\footnote") (html . 
"&rdquo;<sup><a")))
	  (replacement (assoc backend replacements)))
      (replace-match (cdr replacement) nil nil contents))))

Filters are... really cool. Thanks for the help!

Next up: Try to control image sizes when using beamerarticle...

hjh

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

end of thread, other threads:[~2014-01-11  2:46 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-01-08  2:09 HTML export doesn't convert quote before footnote James Harkins
2014-01-08  5:03 ` Nick Dokos
2014-01-08 15:33 ` Nicolas Goaziou
2014-01-08 15:50   ` James Harkins
2014-01-08 16:37     ` Nicolas Goaziou
2014-01-09  2:13       ` James Harkins
2014-01-09  3:03         ` James Harkins
2014-01-09 11:07           ` Nicolas Goaziou
2014-01-11  2:45             ` James Harkins

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).