emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* Directional quotes in html
@ 2011-12-06 18:25 Herbert Sitz
  2011-12-06 19:09 ` Christian Moe
  2011-12-06 21:12 ` tycho garen
  0 siblings, 2 replies; 10+ messages in thread
From: Herbert Sitz @ 2011-12-06 18:25 UTC (permalink / raw)
  To: emacs-orgmode

In my exports to pdf standard double-quote and single-quote (apostrophe)
characters both get translated to corresponding pairs of opening and closing
quotes.  But in export to html both double- and single-quotes seem to be same
in resulting html as they were in the org text, non-paired, non-directional.

What is best way to get directional pairs of open- and close-quotes in html
export?

-- Herb

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

* Re: Directional quotes in html
  2011-12-06 18:25 Directional quotes in html Herbert Sitz
@ 2011-12-06 19:09 ` Christian Moe
  2011-12-06 20:37   ` Herbert Sitz
  2011-12-06 21:12 ` tycho garen
  1 sibling, 1 reply; 10+ messages in thread
From: Christian Moe @ 2011-12-06 19:09 UTC (permalink / raw)
  To: Herbert Sitz; +Cc: emacs-orgmode

On 12/6/11 7:25 PM, Herbert Sitz wrote:
> What is best way to get directional pairs of open- and close-quotes in html
> export?
>
> -- Herb

Hi, Herb,

I keep this in my .emacs:

(setq org-export-html-special-string-regexps
       (cons
        '(" \"\\([^\"]+\\)\"" . " “\\1”")
        org-export-html-special-string-regexps))

There may be a better way to do it altogether, and I'm sure the very 
simple regexp could be improved on (in fact, I'm posting this in the 
hope someone will improve on it), but it mostly works.

Yours,
Christian

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

* Re: Directional quotes in html
  2011-12-06 19:09 ` Christian Moe
@ 2011-12-06 20:37   ` Herbert Sitz
  2011-12-06 22:55     ` Christian Moe
  0 siblings, 1 reply; 10+ messages in thread
From: Herbert Sitz @ 2011-12-06 20:37 UTC (permalink / raw)
  To: emacs-orgmode

Christian Moe <mail <at> christianmoe.com> writes:
> 
> Hi, Herb,
> 
> I keep this in my .emacs:
> 
> (setq org-export-html-special-string-regexps
>        (cons
>         '(" \"\\([^\"]+\\)\"" . " &ldquo;\\1&rdquo;")
>         org-export-html-special-string-regexps))
> 
> There may be a better way to do it altogether, and I'm sure the very 
> simple regexp could be improved on (in fact, I'm posting this in the 
> hope someone will improve on it), but it mostly works.
> 
> Yours,
> Christian
> 

Christian -- Thanks a lot.  If there's nothing built in to Org to do it then
that looks like a good method.  

Question: Does this work only if quotes both appear on the same line of Org-mode
text?  Or is the regex applied to paragraph as a whole after it's been assembled
as part of export?

It looks like it does only double-quotes; makes me realize single quotes are a
bit harder because they're often used alone as apostrophes.  It seems like even
single-quote pairs could work well if you put beginning-of-word (\<) and
end-of-word (\<) regex anchors in there.  

Beginning-of-word and end-of-word anchors may be appropriate even for the
double-quote search, so maybe something like change below could be improvement.
Take it for what's it's worth, since I don't do emacs regexes.

>         '("\<\"\\([^\"]+\\)\"\>" . " &ldquo;\\1&rdquo;")

-- Herb

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

* Re: Directional quotes in html
  2011-12-06 18:25 Directional quotes in html Herbert Sitz
  2011-12-06 19:09 ` Christian Moe
@ 2011-12-06 21:12 ` tycho garen
  2011-12-06 21:45   ` Herbert Sitz
                     ` (2 more replies)
  1 sibling, 3 replies; 10+ messages in thread
From: tycho garen @ 2011-12-06 21:12 UTC (permalink / raw)
  To: Herbert Sitz; +Cc: emacs-orgmode

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

On Tue, Dec 06, 2011 at 06:25:09PM +0000, Herbert Sitz wrote:
> In my exports to pdf standard double-quote and single-quote (apostrophe)
> characters both get translated to corresponding pairs of opening and closing
> quotes.  But in export to html both double- and single-quotes seem to be same
> in resulting html as they were in the org text, non-paired, non-directional.

The directional quotes are processed by LaTeX and org have very little
to do with this.

> What is best way to get directional pairs of open- and close-quotes in html
> export?

http://daringfireball.net/projects/smartypants/

There's a php port that may be more your style.

Cheers,
sam

--
tycho(ish) @
garen@tychoish.com
http://tychoish.com/
"don't get it right, get it written" -- james thurber

[-- Attachment #2: Type: application/pgp-signature, Size: 198 bytes --]

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

* Re: Directional quotes in html
  2011-12-06 21:12 ` tycho garen
@ 2011-12-06 21:45   ` Herbert Sitz
  2011-12-06 21:55   ` Jambunathan K
  2011-12-07  8:58   ` Eric S Fraga
  2 siblings, 0 replies; 10+ messages in thread
From: Herbert Sitz @ 2011-12-06 21:45 UTC (permalink / raw)
  To: emacs-orgmode

tycho garen <garen <at> tychoish.com> writes:
> 
> The directional quotes are processed by LaTeX and org have very little
> to do with this.

Ahh, thanks, I should have known that.

> 
> > What is best way to get directional pairs of open- and close-quotes in html
> > export?
> 
> http://daringfireball.net/projects/smartypants/

Thanks.  Looks like Christian Moe's method in different post is a simplified and
perhaps not quite as effective way of doing something similar.  

-- Herb

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

* Re: Directional quotes in html
  2011-12-06 21:12 ` tycho garen
  2011-12-06 21:45   ` Herbert Sitz
@ 2011-12-06 21:55   ` Jambunathan K
  2011-12-07  8:58   ` Eric S Fraga
  2 siblings, 0 replies; 10+ messages in thread
From: Jambunathan K @ 2011-12-06 21:55 UTC (permalink / raw)
  To: tycho garen; +Cc: emacs-orgmode, Herbert Sitz

tycho garen <garen@tychoish.com> writes:

> On Tue, Dec 06, 2011 at 06:25:09PM +0000, Herbert Sitz wrote:
>> In my exports to pdf standard double-quote and single-quote (apostrophe)
>> characters both get translated to corresponding pairs of opening and closing
>> quotes.  But in export to html both double- and single-quotes seem to be same
>> in resulting html as they were in the org text, non-paired, non-directional.
>
> The directional quotes are processed by LaTeX and org have very little
> to do with this.

If one has 

--8<---------------cut here---------------start------------->8---
(setq org-export-with-TeX-macros t)
--8<---------------cut here---------------end--------------->8---

then I believe something like

--8<---------------cut here---------------start------------->8---
\rdquo This is a quoted text \ldquo 
--8<---------------cut here---------------end--------------->8---

will do the trick. FWIW, a dump of quotations section in
org-entities.el.

,----
|     "** Quotations"
|     ("quot" "\\textquotedbl{}" nil "&quot;" "\"" "\"" "\"")
|     ("acute" "\\textasciiacute{}" nil "&acute;" "'" "´" "´")
|     ("ldquo" "\\textquotedblleft{}" nil "&ldquo;" "\"" "\"" "“")
|     ("rdquo" "\\textquotedblright{}" nil "&rdquo;" "\"" "\"" "”")
|     ("bdquo" "\\quotedblbase{}" nil "&bdquo;" "\"" "\"" "„")
|     ("lsquo" "\\textquoteleft{}" nil "&lsquo;" "`" "`" "‘")
|     ("rsquo" "\\textquoteright{}" nil "&rsquo;" "'" "'" "’")
|     ("sbquo" "\\quotesinglbase{}" nil "&sbquo;" "," "," "‚")
|     ("laquo" "\\guillemotleft{}" nil "&laquo;" "<<" "«" "«")
|     ("raquo" "\\guillemotright{}" nil "&raquo;" ">>" "»" "»")
|     ("lsaquo" "\\guilsinglleft{}" nil "&lsaquo;" "<" "<" "‹")
|     ("rsaquo" "\\guilsinglright{}" nil "&rsaquo;" ">" ">" "›")
`----
-- 

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

* Re: Directional quotes in html
  2011-12-06 20:37   ` Herbert Sitz
@ 2011-12-06 22:55     ` Christian Moe
  2011-12-07  9:44       ` Christer Boräng
  0 siblings, 1 reply; 10+ messages in thread
From: Christian Moe @ 2011-12-06 22:55 UTC (permalink / raw)
  To: Herbert Sitz; +Cc: emacs-orgmode

On 12/6/11 9:37 PM, Herbert Sitz wrote:
> Question: Does this work only if quotes both appear on the same line of Org-mode
> text?  Or is the regex applied to paragraph as a whole after it's been assembled
> as part of export?

Oops, that's embarrassing. I never even noticed. I'm not sure why it 
doesn't work -- the regexp /does/ catch multiline quotes.

Anyway, after some experimenting, the following mess seems to work in 
most cases:

#+begin_src
(setq org-export-html-special-string-regexps
       (append
        '(("\\(^\\|[ \"(]\\)'" . "\\1&lsquo;")
	 ("\\([^ ]\\)'" . "\\1&rsquo;")
	 ("\\(^\\|[ (]\\)\"" . "\\1&ldquo;")
	 ("\"\\([ [:punct:]]\\|$\\)" . "&rdquo;\\1"))
	org-export-html-special-string-regexps))
#+end_src

At least, it should work
- if the opening single or double quotation mark comes at the 
beginning of the line, after a space, or after opening parenthesis,
- or if the opening single quotation mark comes after an opening 
double quotation mark,
- and if the closing double quotation mark comes before a space, 
before punctuation, including a closing parenthesis, or at the end of 
the line.

It will work if you put the period /after/ the closing quotation mark, 
"like this". Typographically, though, you should do it "like this."

>
> It looks like it does only double-quotes; makes me realize single quotes are a
> bit harder because they're often used alone as apostrophes.

The above now also handles single quotes, including apostrophes 
between word characters ("it's"). The rule is that any single quote 
that is not an opening quote is turned into a closing quote, which 
works for apostrophes too.

It also handles nested quotes (single quotes within double quotes). 
The following example should illustrate parentheses and nested quotes:

#+begin_example
Philosophy ain't easy ("being" is a surprisingly difficult concept,
but not as hard as "non-being"). Who said: "'Being' is a surprisingly
difficult concept, but not as hard as 'non-being'"?
#+end_example

> It seems like even
> single-quote pairs could work well if you put beginning-of-word (\<) and
> end-of-word (\<) regex anchors in there.

I've experimented with those anchors, but ended up doing without them; 
punctuation mixes with quotation marks in odd ways.

Yours,
Christian

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

* Re: Directional quotes in html
  2011-12-06 21:12 ` tycho garen
  2011-12-06 21:45   ` Herbert Sitz
  2011-12-06 21:55   ` Jambunathan K
@ 2011-12-07  8:58   ` Eric S Fraga
  2 siblings, 0 replies; 10+ messages in thread
From: Eric S Fraga @ 2011-12-07  8:58 UTC (permalink / raw)
  To: tycho garen; +Cc: emacs-orgmode, Herbert Sitz

tycho garen <garen@tychoish.com> writes:

> On Tue, Dec 06, 2011 at 06:25:09PM +0000, Herbert Sitz wrote:
>> In my exports to pdf standard double-quote and single-quote (apostrophe)
>> characters both get translated to corresponding pairs of opening and closing
>> quotes.  But in export to html both double- and single-quotes seem to be same
>> in resulting html as they were in the org text, non-paired, non-directional.
>
> The directional quotes are processed by LaTeX and org have very little
> to do with this.

Actually, that's not true.  Org is creating the latex with the
appropriate (left/right) quotes in place.  Latex expects this.  In a
latex file, you need have written ``a quoted string'' instead of "a
quoted string" for things to look right in the output.

So it is indeed org's latex exporter that is handling quotes appropriately.

-- 
: Eric S Fraga (GnuPG: 0xC89193D8FFFCF67D) in Emacs 24.0.90.1
: using Org-mode version 7.7 (release_7.7.622.g92d30)

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

* Re: Directional quotes in html
  2011-12-06 22:55     ` Christian Moe
@ 2011-12-07  9:44       ` Christer Boräng
  2011-12-07 10:04         ` Christian Moe
  0 siblings, 1 reply; 10+ messages in thread
From: Christer Boräng @ 2011-12-07  9:44 UTC (permalink / raw)
  To: emacs-orgmode

In message <4EDE9D46.2020509@christianmoe.com>, Christian Moe writes:
>The above now also handles single quotes, including apostrophes 
>between word characters ("it's"). The rule is that any single quote 
>that is not an opening quote is turned into a closing quote, which 
>works for apostrophes too.

>It also handles nested quotes (single quotes within double quotes). 
>The following example should illustrate parentheses and nested quotes:

>#+begin_example
>Philosophy ain't easy ("being" is a surprisingly difficult concept,
>but not as hard as "non-being"). Who said: "'Being' is a surprisingly
>difficult concept, but not as hard as 'non-being'"?
>#+end_example

Does it handle possessive ' at the end of words ending with an "s" or
"z" sound? Like "James' house"?

Just curious...:-)

//Christer

-- 
| Hagåkersgatan 18C | Phone: Home +46 31 43 52 03   CTH: +46 31 772 5431  |
| S-431 41 Mölndal  |        Cell: +46 707 53 57 57                       |
| Sweden            | Mail:  mort@chalmers.se                             |
"An NT server can be run by an idiot, and usually is." -- Tom Holub, a.h.b-o-i

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

* Re: Directional quotes in html
  2011-12-07  9:44       ` Christer Boräng
@ 2011-12-07 10:04         ` Christian Moe
  0 siblings, 0 replies; 10+ messages in thread
From: Christian Moe @ 2011-12-07 10:04 UTC (permalink / raw)
  To: Christer Boräng; +Cc: emacs-orgmode

On 12/7/11 10:44 AM, Christer Boräng wrote:
> Does it handle possessive ' at the end of words ending with an "s" or
> "z" sound? Like "James' house"?

Sure, but not because it cares what letter they end with, only because 
it turns any straight single quote that doesn't become an opening 
curly quote into a closing curly quote, identical to curly apostrophe.

Yours,
Christian

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

end of thread, other threads:[~2011-12-07  9:59 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-12-06 18:25 Directional quotes in html Herbert Sitz
2011-12-06 19:09 ` Christian Moe
2011-12-06 20:37   ` Herbert Sitz
2011-12-06 22:55     ` Christian Moe
2011-12-07  9:44       ` Christer Boräng
2011-12-07 10:04         ` Christian Moe
2011-12-06 21:12 ` tycho garen
2011-12-06 21:45   ` Herbert Sitz
2011-12-06 21:55   ` Jambunathan K
2011-12-07  8:58   ` Eric S Fraga

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