fix color link

This commit is contained in:
2026-10-11 19:37:23 +02:00
parent cd7f32b668
commit a640b93eec
+17 -24
View File
@@ -540,43 +540,36 @@ Example usage
"if link description is empty use color as description. "if link description is empty use color as description.
[[color:COLOR][DESCRIPTION]]" [[color:COLOR][DESCRIPTION]]"
(cond (cond
((eq backend 'html) ((or (eq backend 'html) (eq backend 'article-html))
(let ((rgb (color-name-to-rgb color)) (let ((rgb (color-name-to-rgb color)))
r g b)
(if rgb (if rgb
(progn (format "<span style=\"color: rgb(%d,%d,%d)\">%s</span>"
(setq r (truncate (* 255 (nth 0 rgb)))) (truncate (* 255 (nth 0 rgb)))
(setq g (truncate (* 255 (nth 1 rgb)))) (truncate (* 255 (nth 1 rgb)))
(setq b (truncate (* 255 (nth 2 rgb)))) (truncate (* 255 (nth 2 rgb)))
(format "<span style=\"color: rgb(%s,%s,%s)\">%s</span>" (or description color))
r g b (format "<span style=\"color: %s\">%s</span>" color (or description color)))))
(or description color)))
(format "No Color RGB for %s" color))))
;; text :raw-html:`<span style="color:red">foo</span>` baz ;; text :raw-html:`<span style="color:red">foo</span>` baz
;; need in Sphinx conf.py rst_prolog = """ ;; need in Sphinx conf.py rst_prolog = """
;; .. role:: raw-html(raw) ;; .. role:: raw-html(raw)
;; :format: html ;; :format: html
;; """ ;; """
((eq backend 'rst) ((eq backend 'rst)
(let ((rgb (color-name-to-rgb color)) (let ((rgb (color-name-to-rgb color)))
r g b)
(if rgb (if rgb
(progn (format ":raw-html:`<span style=\"color: rgb(%d,%d,%d)\">%s</span>`"
(setq r (truncate (* 255 (nth 0 rgb)))) (truncate (* 255 (nth 0 rgb)))
(setq g (truncate (* 255 (nth 1 rgb)))) (truncate (* 255 (nth 1 rgb)))
(setq b (truncate (* 255 (nth 2 rgb)))) (truncate (* 255 (nth 2 rgb)))
(format ":raw-html:`<span style=\"color: rgb(%s,%s,%s)\">%s</span>`" (or description color))
r g b (or description color))))
(or description color)))
(format "No Color RGB for %s" color))))
((eq backend 'latex) ((eq backend 'latex)
(let ((rgb (color-name-to-rgb color))) (let ((rgb (color-name-to-rgb color)))
(if rgb (if rgb
(progn
(format "\\textcolor[rgb]{%s,%s,%s}{%s}" (format "\\textcolor[rgb]{%s,%s,%s}{%s}"
(nth 0 rgb) (nth 1 rgb) (nth 2 rgb) (nth 0 rgb) (nth 1 rgb) (nth 2 rgb)
(or description color))) (or description color))
(format "No Color RGB for %s" color)))) (format "\\textcolor{%s}{%s}" color (or description color)))))
))) )))
(defun my-org-link-color (limit) (defun my-org-link-color (limit)
"Helper function for colored text in buffer. "Helper function for colored text in buffer.