emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [O] Directional quotes in html


From: Christian Moe
Subject: Re: [O] Directional quotes in html
Date: Tue, 06 Dec 2011 23:55:02 +0100
User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.6; rv:6.0.2) Gecko/20110902 Thunderbird/6.0.2

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‘")
         ("\\([^ ]\\)'" . "\\1’")
         ("\\(^\\|[ (]\\)\"" . "\\1“")
         ("\"\\([ [:punct:]]\\|$\\)" . "”\\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



reply via email to

[Prev in Thread] Current Thread [Next in Thread]