emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Christian Moe <mail@christianmoe.com>
To: Herbert Sitz <hesitz@gmail.com>
Cc: emacs-orgmode@gnu.org
Subject: Re: Directional quotes in html
Date: Tue, 06 Dec 2011 23:55:02 +0100	[thread overview]
Message-ID: <4EDE9D46.2020509@christianmoe.com> (raw)
In-Reply-To: <loom.20111206T212417-459@post.gmane.org>

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

  reply	other threads:[~2011-12-06 22:49 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4EDE9D46.2020509@christianmoe.com \
    --to=mail@christianmoe.com \
    --cc=emacs-orgmode@gnu.org \
    --cc=hesitz@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).