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
>