add colored string for rst export

This commit is contained in:
2026-01-25 18:59:55 +01:00
parent 26e5ea8ba9
commit a22d7a3954

View File

@@ -549,6 +549,23 @@ Example usage
r g b
(or description color)))
(format "No Color RGB for %s" color))))
;; text :raw-html:`<span style="color:red">foo</span>` baz
;; need in Sphinx conf.py rst_prolog = """
;; .. role:: raw-html(raw)
;; :format: html
;; """
((eq backend 'rst)
(let ((rgb (color-name-to-rgb color))
r g b)
(if rgb
(progn
(setq r (truncate (* 255 (nth 0 rgb))))
(setq g (truncate (* 255 (nth 1 rgb))))
(setq b (truncate (* 255 (nth 2 rgb))))
(format ":raw-html:`<span style=\"color: rgb(%s,%s,%s)\">%s</span>`"
r g b
(or description color)))
(format "No Color RGB for %s" color))))
((eq backend 'latex)
(let ((rgb (color-name-to-rgb color)))
(if rgb