summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLudovic Courtès2007-11-28 20:19:39 +0100
committerLudovic Courtès2007-11-28 20:19:39 +0100
commit20706dc9236f5854c2a5df16c1006910a3abafb4 (patch)
tree1276c0a111b8314d99ebb4fe9c6ab47f546beaee
parentb7230d95c0a5314256c019d9cfdc6fc4bfc3dd0a (diff)
downloadskribilo-20706dc9236f5854c2a5df16c1006910a3abafb4.tar.gz
skribilo-20706dc9236f5854c2a5df16c1006910a3abafb4.tar.lz
skribilo-20706dc9236f5854c2a5df16c1006910a3abafb4.zip
latex: Don't rely on `skribe-get-used-colors' and `\definecolor'.
* src/guile/skribilo/engine/latex.scm (*skribe-latex-color-table*, latex-declare-color, skribe-get-latex-color, skribe-latex-declare-colors): Remove. (document): Don't declare colors. (latex-color): Pass `\textcolor' the "[rgb]{x,y,z}" form instead of a color name. Same with `\colorbox'.
-rw-r--r--src/guile/skribilo/engine/latex.scm66
1 files changed, 7 insertions, 59 deletions
diff --git a/src/guile/skribilo/engine/latex.scm b/src/guile/skribilo/engine/latex.scm
index 8523c9a..c68ac89 100644
--- a/src/guile/skribilo/engine/latex.scm
+++ b/src/guile/skribilo/engine/latex.scm
@@ -1,7 +1,7 @@
;;; latex.scm -- LaTeX engine.
;;;
+;;; Copyright 2007 Ludovic Courtès <ludo@gnu.org>
;;; Copyright 2003, 2004 Manuel Serrano
-;;; Copyright 2007 Ludovic Courtès <ludovic.courtes@laas.fr>
;;;
;;;
;;; This program is free software; you can redistribute it and/or modify
@@ -39,8 +39,7 @@
:use-module (ice-9 receive)
:export (latex-engine
- LaTeX TeX !latex
- skribe-get-latex-color))
+ LaTeX TeX !latex))
(fluid-set! current-reader %skribilo-module-reader)
@@ -453,27 +452,6 @@
"normalsize"))))
;*---------------------------------------------------------------------*/
-;* *skribe-latex-color-table* ... */
-;*---------------------------------------------------------------------*/
-(define *skribe-latex-color-table* #f)
-
-;*---------------------------------------------------------------------*/
-;* latex-declare-color ... */
-;*---------------------------------------------------------------------*/
-(define (latex-declare-color name rgb)
- (format #t "\\definecolor{~a}{rgb}{~a}\n" name rgb))
-
-;*---------------------------------------------------------------------*/
-;* skribe-get-latex-color ... */
-;*---------------------------------------------------------------------*/
-(define (skribe-get-latex-color spec)
- (let ((c (and (hash-table? *skribe-latex-color-table*)
- (hash-ref *skribe-latex-color-table* spec))))
- (if (not (string? c))
- (skribe-error 'latex "Can't find color" spec)
- c)))
-
-;*---------------------------------------------------------------------*/
;* skribe-color->latex-rgb ... */
;*---------------------------------------------------------------------*/
(define (skribe-color->latex-rgb spec)
@@ -492,23 +470,6 @@
(number->string (/ b ff))))))))
;*---------------------------------------------------------------------*/
-;* skribe-latex-declare-colors ... */
-;*---------------------------------------------------------------------*/
-(define (skribe-latex-declare-colors colors)
- (set! *skribe-latex-color-table* (make-hash-table))
- (for-each (lambda (spec)
- (let ((old (hash-ref *skribe-latex-color-table* spec)))
- (if (not (string? old))
- (let ((name (symbol->string (gensym "c"))))
- ;; bind the color
- (hash-set! *skribe-latex-color-table* spec name)
- ;; and emit a latex declaration
- (latex-declare-color
- name
- (skribe-color->latex-rgb spec))))))
- colors))
-
-;*---------------------------------------------------------------------*/
;* ~ ... */
;*---------------------------------------------------------------------*/
(markup-writer '~
@@ -562,20 +523,6 @@
;; usepackage
(let ((pa (engine-custom e 'usepackage)))
(if pa (begin (display pa) (newline))))
- ;; colors
- (if (latex-color? e)
- (begin
- (skribe-use-color! (engine-custom e 'source-comment-color))
- (skribe-use-color! (engine-custom e 'source-define-color))
- (skribe-use-color! (engine-custom e 'source-module-color))
- (skribe-use-color! (engine-custom e 'source-markup-color))
- (skribe-use-color! (engine-custom e 'source-thread-color))
- (skribe-use-color! (engine-custom e 'source-string-color))
- (skribe-use-color! (engine-custom e 'source-bracket-color))
- (skribe-use-color! (engine-custom e 'source-type-color))
- (display "\n%% colors\n")
- (skribe-latex-declare-colors (skribe-get-used-colors))
- (display "\n\n")))
;; predocument
(let ((pd (engine-custom e 'predocument)))
(when pd (display pd) (newline)))
@@ -838,14 +785,15 @@
(set! latex-color-counter (+ latex-color-counter 1))
(if fg
(begin
- (format #t "\\textcolor{~a}{" (skribe-get-latex-color fg))
+ (format #t "{\\textcolor[rgb]{~a}{"
+ (skribe-color->latex-rgb fg))
(output n e)
- (display "}"))
+ (display "}}"))
(output n e))
(set! latex-color-counter (- latex-color-counter 1))
(if bg
- (format #t "\\egroup\\colorbox{~a}{\\box~a}%\n"
- (skribe-get-latex-color bg) latex-color-counter))))))
+ (format #t "\\egroup\\colorbox[rgb]{~a}{\\box~a}%\n"
+ (skribe-color->latex-rgb bg) latex-color-counter))))))
;*---------------------------------------------------------------------*/
;* color ... */