[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [O] small caps
From: |
Rasmus |
Subject: |
Re: [O] small caps |
Date: |
Thu, 29 Oct 2015 21:37:28 +0100 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/25.0.50 (gnu/linux) |
Matt Price <address@hidden> writes:
> do we have a syntax for the "small caps" text attribute in Org? If not,
> should we? It is available in odt, html, and latex, and is used in some
I use the following filter(s) (second one is not essential).
Example input:
CO_2
fOO
Fo1O
/FoO/
Example output:
\textsc{co}\(_{\text{2}}\)
f\textsc{oo}
\textsc{f}o1\textsc{o}
\emph{\textsc{f}o\textsc{o}}
For emph to play nice with textsc in latex use the slantsc package.
(defun rasmus/org-guess-textsc (content backend info)
"Automatically downcase and wrap all-caps words in textsc.
The function is a bit slow...
TODO: Make the function work with headlines, but without doing it
on subsequent text.
TODO: Add ODT support."
(if (org-export-derived-backend-p backend 'latex 'html)
(let* (case-fold-search
(latexp (org-export-derived-backend-p backend 'latex))
(wrap (if latexp "\\textsc{%s}"
"<span class=\"small-caps\">%s</span>")))
(replace-regexp-in-string
"\\w+"
(lambda (str)
(if (or (string-equal str (downcase str))
(string-equal str (capitalize str)))
str
(replace-regexp-in-string
"[[:upper:]]+"
(lambda (x) (format wrap (downcase x)))
str t t)))
content t t))
content))
(add-to-list 'org-export-filter-plain-text-functions
'rasmus/org-guess-textsc)
(defun rasmus/org-guess-textsc-html-cleanup-title (content backend info)
(when (org-export-derived-backend-p backend 'html)
(replace-regexp-in-string
"<title>\\(.*\\)</title>"
(lambda (str0)
(format
"<title>%s</title>"
(replace-regexp-in-string
"<span class=\"small-caps\">\\(.*?\\)</span>"
(lambda (str) (upcase (match-string 1 str)))
(match-string 1 str0))))
content)))
--
⠠⠵
Re: [O] small caps,
Rasmus <=
Re: [O] small caps, Robert Klein, 2015/10/29