emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Thomas S. Dye <tsd@tsdye.com>
To: Nicolas Goaziou <mail@nicolasgoaziou.fr>
Cc: Org Mode <emacs-orgmode@gnu.org>
Subject: Re: small caps
Date: Thu, 29 Oct 2015 06:55:18 -1000	[thread overview]
Message-ID: <m2eggdehs9.fsf@tsdye.com> (raw)
In-Reply-To: <87si4toc4g.fsf@nicolasgoaziou.fr>

Aloha Matt,

Nicolas Goaziou <mail@nicolasgoaziou.fr> writes:

> Hello,
>
> Matt Price <moptop99@gmail.com> writes:
>
>> do we have a syntax for the "small caps" text attribute in Org?
>
> No, we don't.
>

I've been using this export filter, written by Eric Schulte.  It works
fine for my uses.

**** Eric Schulte's filter for HTML small caps

#+name: es-small-caps
#+begin_src emacs-lisp
;;; "sc" links for the \sc{} latex command
(defun org-export-html-small-caps (string backend channel)
  (when (org-export-derived-backend-p backend 'html)
    (let ((rx "{\\\\sc ")
          (fmt "<span style=\"font-variant:small-caps;\">%s</span>"))
      (with-temp-buffer
        (insert string)
        (goto-char (point-min))
        (while (re-search-forward rx nil t)
          (let* ((start (match-beginning 0))
                 (end (progn (goto-char start)
                             (forward-sexp)
                             (point)))
                 (content (buffer-substring (+ start 5) (- end 1))))
            (delete-region start end)
            (goto-char start)
            (insert (format fmt content))))
        (buffer-string)))))

(add-to-list 'org-export-filter-final-output-functions
             'org-export-html-small-caps)

(defun org-export-latex-sc (tree backend info)
  "Handle sc: links for latex export."
  (org-element-map tree 'link
    (lambda (object)
      (when (equal (org-element-property :type object) "sc")
        (org-element-insert-before
         (cond
          ((org-export-derived-backend-p backend 'latex)
           (list 'latex-fragment
                 (list :value (format "{\\sc %s}"
                                      (org-element-property :path object))
                       :post-blank (org-element-property
                                    :post-blank object))))
          ((org-export-derived-backend-p backend 'html)
           (list 'export-snippet
                 (list :back-end "html"
                       :value
                       (format "<span class=\"sc\">%s</span>"
                               (org-element-property :path object))
                       :post-blank
                       (org-element-property :post-blank object))))
          (:otherwise
           (error "unsupported backend for `org-export-latex-sc'")))
         object)
        (org-element-extract-element object))))
  tree)

(org-add-link-type "sc")

(add-hook 'org-export-filter-parse-tree-functions
          'org-export-latex-sc)

#+end_src

hth,
Tom

-- 
Thomas S. Dye
http://www.tsdye.com

  reply	other threads:[~2015-10-29 16:55 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-10-29 16:39 small caps Matt Price
2015-10-29 16:47 ` Nicolas Goaziou
2015-10-29 16:55   ` Thomas S. Dye [this message]
2015-10-29 20:17     ` Matt Price
2015-10-29 20:42       ` Thomas S. Dye
2015-10-30 13:10         ` Christian Moe
2015-10-31 16:16           ` Matt Price
2015-10-29 17:25   ` Aaron Ecay
2015-10-29 17:39     ` Thomas S. Dye
2015-10-29 17:46       ` Nicolas Goaziou
2015-10-29 17:44     ` Nicolas Goaziou
2015-10-29 20:37 ` Rasmus
2015-10-29 21:18 ` Robert Klein

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=m2eggdehs9.fsf@tsdye.com \
    --to=tsd@tsdye.com \
    --cc=emacs-orgmode@gnu.org \
    --cc=mail@nicolasgoaziou.fr \
    /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).