* Multilingual quotes inside paragraphs
@ 2021-07-26 9:25 Juan Manuel Macías
2021-07-28 12:13 ` Maxim Nikulin
0 siblings, 1 reply; 4+ messages in thread
From: Juan Manuel Macías @ 2021-07-26 9:25 UTC (permalink / raw)
To: orgmode
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
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Multilingual quotes inside paragraphs
2021-07-26 9:25 Multilingual quotes inside paragraphs Juan Manuel Macías
@ 2021-07-28 12:13 ` Maxim Nikulin
2021-07-28 13:49 ` Juan Manuel Macías
0 siblings, 1 reply; 4+ messages in thread
From: Maxim Nikulin @ 2021-07-28 12:13 UTC (permalink / raw)
To: emacs-orgmode
On 26/07/2021 16:25, Juan Manuel Macías wrote:
>
> 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.
Are you intentionally avoiding macros {{{lang(ru, текст)}}}? It seems,
you are abusing links a bit. Though it allows to hide "target" part and
thus to reduce "noise" in the text. On the other hand, links may be
broadly considered as customizable element ("interactive" property is
not necessary for such snippets) since there are no other similar
objects in Org syntax. One problem is support in 3rd party tools:
pandoc, various renderers, e.g. (ruby?) on github.
Another issue is that someone will almost immediately want to put such
quote inside link or vice versa to make some fragment of a quote a
regular link. A workaround is possible:
lang:de?href=https%3A%2F%2Forgmode.org%2F with some code for handling of
unescaped target. I expect complains that it is not user-friendly to
require splitting fragment at the borders of inner link. Org does not
support nested objects of the same type.
> or explicitly preceded by
> a "!": "!german" (the reason for the latter is that in babel we can
> define new languages):
Unsure that ODT and HTML allows to define languages. I would consider
some lisp structures describing mapping of customizable languages codes
to some set of properties.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Multilingual quotes inside paragraphs
2021-07-28 12:13 ` Maxim Nikulin
@ 2021-07-28 13:49 ` Juan Manuel Macías
2021-08-01 16:02 ` Maxim Nikulin
0 siblings, 1 reply; 4+ messages in thread
From: Juan Manuel Macías @ 2021-07-28 13:49 UTC (permalink / raw)
To: Maxim Nikulin; +Cc: orgmode
Hi Maxim, thank you for your comments.
Maxim Nikulin writes:
> Are you intentionally avoiding macros {{{lang(ru, текст)}}}?
Yes. Precisely, these experiments are just an attempt to find an
alternative to macros (I use macros a lot). In scenarios like these
(chunks of text) is where the issue of the comma as a escape character
in macros becomes more evident (this comma issue has been discussed in a
past thread, and some interesting proposals were made). Links and
macros, of course, have their pros and cons.
> It seems, you are abusing links a bit.
I'm afraid it's true :-). Anyway I think the links have a great
potential. I have tried exploring other "eccentric" uses of links, for
example here (to export subfigures to LaTeX and HTML):
https://orgmode.org/list/87mty1an66.fsf@posteo.net/ or also in my
org-critical-edition package, to work on (philological) critical
editions from Org: https://gitlab.com/maciaschain/org-critical-edition
> [...]
> Another issue is that someone will almost immediately want to put such
> quote inside link or vice versa to make some fragment of a quote a
> regular link.
Yes, that issue you describe would be one of the biggest drawbacks for
the use of links in these contexts.
Links (or macros) are a good user-level solution to solve certain
specific cases, IMHO. At a native level (in case Org someday implement
consistent and native multilingual support), I don't know what would be
the best solution for multilingual chunks of text inside paragraphs.
Maybe some kind of inline `quote' block?
Best regards,
Juan Manuel
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Multilingual quotes inside paragraphs
2021-07-28 13:49 ` Juan Manuel Macías
@ 2021-08-01 16:02 ` Maxim Nikulin
0 siblings, 0 replies; 4+ messages in thread
From: Maxim Nikulin @ 2021-08-01 16:02 UTC (permalink / raw)
To: emacs-orgmode
On 28/07/2021 20:49, Juan Manuel Macías wrote:
> Links (or macros) are a good user-level solution to solve certain
> specific cases, IMHO. At a native level (in case Org someday implement
> consistent and native multilingual support), I don't know what would be
> the best solution for multilingual chunks of text inside paragraphs.
> Maybe some kind of inline `quote' block?
My personal impression is that lightweight Org markup is suitable for
simple documents. Problems grow as a snowball as soon as a document
becomes more complex. If syntax were extended too much, Org would loose
its simplicity that is one of its advantage. Complex documents require
more strict and flexible thus more verbose markup format.
It seems, your have tried all possible variants for inline quotes
https://orgmode.org/worg/dev/org-syntax.html#Objects
macros, src_org{}, even links and nothing is perfect
https://orgmode.org/list/875yzwce28.fsf@posteo.net
Code for any approach may be polished to some extent, but some
limitations will remain.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2021-08-01 16:05 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-07-26 9:25 Multilingual quotes inside paragraphs Juan Manuel Macías
2021-07-28 12:13 ` Maxim Nikulin
2021-07-28 13:49 ` Juan Manuel Macías
2021-08-01 16:02 ` Maxim Nikulin
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).