From mboxrd@z Thu Jan 1 00:00:00 1970 From: Matt Price Subject: Re: small caps Date: Thu, 29 Oct 2015 16:17:04 -0400 Message-ID: References: <87si4toc4g.fsf@nicolasgoaziou.fr> Mime-Version: 1.0 Content-Type: multipart/alternative; boundary=001a113f9ae0958e8e052343fe40 Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:34661) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZrtdD-0006Fb-1W for emacs-orgmode@gnu.org; Thu, 29 Oct 2015 16:17:08 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZrtdB-0002SA-9B for emacs-orgmode@gnu.org; Thu, 29 Oct 2015 16:17:06 -0400 Received: from mail-io0-x22d.google.com ([2607:f8b0:4001:c06::22d]:32772) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZrtdB-0002Rq-1a for emacs-orgmode@gnu.org; Thu, 29 Oct 2015 16:17:05 -0400 Received: by iodd200 with SMTP id d200so58626646iod.0 for ; Thu, 29 Oct 2015 13:17:04 -0700 (PDT) In-Reply-To: List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Cc: Org Mode --001a113f9ae0958e8e052343fe40 Content-Type: text/plain; charset=UTF-8 Tom, Am I right that this should turn {sc hello} into hello ? If so, it doesn't seem to be working for me so far. Thanks, m On Thu, Oct 29, 2015 at 12:55 PM, Thomas S. Dye wrote: > Aloha Matt, > > Nicolas Goaziou writes: > > > Hello, > > > > Matt Price 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 "%s")) > (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 "%s" > (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 > --001a113f9ae0958e8e052343fe40 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
Tom,

Am I right that= this should turn
{sc hello}

into

<span s= tyle=3D\"font-variant:small-caps;\">hello</span>

= ?

If so, it doesn't seem to be working for me so far.=C2= =A0 Thanks,
m


On Thu, Oct 29, 2015 at 12:55 PM, Thomas S. Dye <tsd@tsdye.= com> wrote:
Aloha Matt,

Nicolas Goaziou <mail@nicolasg= oaziou.fr> writes:

> Hello,
>
> Matt Price <moptop99@gmail.co= m> 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.=C2= =A0 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)
=C2=A0 (when (org-export-derived-backend-p backend 'html)
=C2=A0 =C2=A0 (let ((rx "{\\\\sc ")
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (fmt "<span style=3D\"font-= variant:small-caps;\">%s</span>"))
=C2=A0 =C2=A0 =C2=A0 (with-temp-buffer
=C2=A0 =C2=A0 =C2=A0 =C2=A0 (insert string)
=C2=A0 =C2=A0 =C2=A0 =C2=A0 (goto-char (point-min))
=C2=A0 =C2=A0 =C2=A0 =C2=A0 (while (re-search-forward rx nil t)
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (let* ((start (match-beginning 0))
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(end (progn (= goto-char start)
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(forward-sexp)
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(point)))
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(content (buf= fer-substring (+ start 5) (- end 1))))
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (delete-region start end)
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (goto-char start)
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (insert (format fmt content)))) =C2=A0 =C2=A0 =C2=A0 =C2=A0 (buffer-string)))))

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

(defun org-export-latex-sc (tree backend info)
=C2=A0 "Handle sc: links for latex export."
=C2=A0 (org-element-map tree 'link
=C2=A0 =C2=A0 (lambda (object)
=C2=A0 =C2=A0 =C2=A0 (when (equal (org-element-property :type object) "= ;sc")
=C2=A0 =C2=A0 =C2=A0 =C2=A0 (org-element-insert-before
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(cond
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 ((org-export-derived-backend-p backend &= #39;latex)
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(list 'latex-fragment
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(list :value = (format "{\\sc %s}"
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (org-element-pr= operty :path object))
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0:post-blank (org-element-property
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 :post-blank object))))=
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 ((org-export-derived-backend-p backend &= #39;html)
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(list 'export-snippet
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(list :back-e= nd "html"
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0:value
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0(format "<span class=3D\"sc\">%s</span>= ;"
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(org-element-property :path object))<= br> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0:post-blank
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0(org-element-property :post-blank object))))
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (:otherwise
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(error "unsupported backend f= or `org-export-latex-sc'")))
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0object)
=C2=A0 =C2=A0 =C2=A0 =C2=A0 (org-element-extract-element object))))
=C2=A0 tree)

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

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

#+end_src

hth,
Tom

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

--001a113f9ae0958e8e052343fe40--