all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: "Juan Manuel Macías" <maciaschain@posteo.net>
To: orgmode <emacs-orgmode@gnu.org>
Subject: Multilingual quotes inside paragraphs
Date: Mon, 26 Jul 2021 09:25:04 +0000	[thread overview]
Message-ID: <87mtq9zatr.fsf@posteo.net> (raw)

Hi all,

I'm experimenting with `org-link-set-parameters' to create multilingual
quotes (chunks of text) inside paragraphs. Although I focus mainly on
the export to LaTeX with babel and csquotes packages, I also want extend
support for HTML and odt output. I leave here some sketches.

For the `:face' parameter I use for laziness a face already defined in
Magit :-). `:display' with the value 'full can be removed.

First, we have the LaTeX babel command \foreignlanguage{lang}{chunk of
text}. The language can be expressed by abbreviation ("de" for German;
here I reuse `org-latex-babel-language-alist') or explicitly preceded by
a "!": "!german" (the reason for the latter is that in babel we can
define new languages):

[[lang:de][some text in German]]

or

[[lang:!german][some text in German]]

The code:

(org-link-set-parameters "lang"
			   :display 'full
			   :face 'magit-header-line-key
			   :export (lambda (target desc format)
				     (cond
				      ((eq format 'latex)
				       (let ((langs org-latex-babel-language-alist))
					 (concat
					  "\\foreignlanguage{"
					  (if (string-match-p "!" target)
					      (replace-regexp-in-string "!" "" target)
					    (cdr (assoc target langs)))
					  "}{" desc "}")))
                                          ;; TODO
				      ((or (eq format 'html)
					   (eq format 'odt))
				       (format "%s" desc)))))

We also have this command from the csquotes package for foreign quoted
texts (loads only the hyphenation rules for the language and sets the
text between quotation marks): \hyphentextquote{lang}{quoted text}. For
this I have defined a new link "qlang":

  (org-link-set-parameters "qlang"
			   :display 'full
			   :face 'magit-header-line-key
			   :export (lambda (target desc format)
				     (cond
				      ((eq format 'latex)
				       (let ((langs org-latex-babel-language-alist))
					 (concat
					  "\\hyphentextquote{"
					  (if (string-match-p "!" target)
					      (replace-regexp-in-string "!" "" target)
					    (cdr (assoc target langs)))
					  "}{" desc "}")))
				      ((or (eq format 'html)
					   (eq format 'odt))
				       ;; TODO (use here the proper quotes)
				       (format "«%s»" desc)))))

We can even make the citations come out in color when we are in draft
mode, thanks to the LaTeX ifdraft package:

(org-link-set-parameters "qlang"
			 :display 'full
			 :face 'magit-header-line-key
			 :export (lambda (target desc format)
				   (cond
				    ((eq format 'latex)
				     (let ((langs org-latex-babel-language-alist))
				       (concat
					"{\\ifdraft{\\color{teal}}{}\\hyphentextquote{"
					(if (string-match-p "!" target)
					    (replace-regexp-in-string "!" "" target)
					  (cdr (assoc target langs)))
					"}{"
					desc "}}")))
				    ((or (eq format 'html)
					 (eq format 'odt))
				     ;; TODO
				     (format "«%s»" desc)))))


Best regards,

Juan Manuel 


             reply	other threads:[~2021-07-26  9:26 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-07-26  9:25 Juan Manuel Macías [this message]
2021-07-28 12:13 ` Multilingual quotes inside paragraphs Maxim Nikulin
2021-07-28 13:49   ` Juan Manuel Macías
2021-08-01 16:02     ` Maxim Nikulin

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

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

  git send-email \
    --in-reply-to=87mtq9zatr.fsf@posteo.net \
    --to=maciaschain@posteo.net \
    --cc=emacs-orgmode@gnu.org \
    /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 external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.