diff --git a/collects/scribble/html-render.ss b/collects/scribble/html-render.ss index 06d7c1d9..1e4c82d3 100644 --- a/collects/scribble/html-render.ss +++ b/collects/scribble/html-render.ss @@ -432,15 +432,26 @@ [(string? style) `((span ([class ,style]) ,@(super render-element e part ri)))] [(and (pair? style) - (eq? (car style) 'show-color)) - `((font ((style ,(format "background-color: ~a" - (apply string-append "#" - (map (lambda (v) (let ([s (format "0~x" v)]) - (substring s (- (string-length s) 2)))) - (cdr style)))))) - (tt nbsp nbsp nbsp nbsp nbsp)) - nbsp - ,@(super render-element e part ri))] + (or (eq? (car style) 'bg-color) + (eq? (car style) 'color))) + (unless (and (list? style) + (or (and (= 4 (length style)) + (andmap byte? (cdr style))) + (and (= 2 (length style)) + (member (cadr style) + '("white" "black" "red" "green" "blue" "cyan" "magenta" "yellow"))))) + (error 'render-font "bad color style: ~e" style)) + `((font ((style ,(format "~acolor: ~a" + (if (eq? (car style) 'bg-color) + "background-" + "") + (if (= 2 (length style)) + (cadr style) + (apply string-append "#" + (map (lambda (v) (let ([s (format "0~x" v)]) + (substring s (- (string-length s) 2)))) + (cdr style))))))) + ,@(super render-element e part ri)))] [(target-url? style) (if (current-no-links) (super render-element e part ri) diff --git a/collects/scribble/latex-render.ss b/collects/scribble/latex-render.ss index 292d591f..15a1d69a 100644 --- a/collects/scribble/latex-render.ss +++ b/collects/scribble/latex-render.ss @@ -68,7 +68,11 @@ (printf "\\newcommand{\\smaller}[1]{{\\footnotesize #1}}\n") (printf "\\definecolor{PaleBlue}{rgb}{0.90,0.90,1.0}\n") (printf "\\definecolor{LightGray}{rgb}{0.90,0.90,0.90}\n") - (printf "\\newcommand{\\schemeinput}[1]{\\colorbox{LightGray}{\\hspace{-0.5ex}\\schemeinputbg{#1}\\hspace{-0.5ex}}}\n") + (printf "\\newcommand{\\intextcolor}[2]{\\textcolor{#1}{#2}}\n") + (printf "\\newcommand{\\intextrgbcolor}[2]{\\textcolor[rgb]{#1}{#2}}\n") + (printf "\\newcommand{\\incolorbox}[2]{{\\fboxrule=0pt\\fboxsep=0pt\\colorbox{#1}{#2}}}\n") + (printf "\\newcommand{\\inrgbcolorbox}[2]{{\\fboxrule=0pt\\fboxsep=0pt\\colorbox[rgb]{#1}{#2}}}\n") + (printf "\\newcommand{\\schemeinput}[1]{\\incolorbox{LightGray}{\\schemeinputbg{#1}}}\n") (printf "\\newcommand{\\highlighted}[1]{\\colorbox{PaleBlue}{\\hspace{-0.5ex}\\schemeinputbg{#1}\\hspace{-0.5ex}}}\n") (printf "\\newcommand{\\plainlink}[1]{#1}\n") (printf "\\newcommand{\\techlink}[1]{#1}\n") @@ -175,6 +179,23 @@ [else (error 'latex-render "unrecognzied style symbol: ~s" style)])] [(string? style) (wrap e style (regexp-match? #px"^scheme(?!error)" style))] + [(and (pair? style) + (or (eq? (car style) 'bg-color) + (eq? (car style) 'color))) + (wrap e (format "~a{~a}" + (format (if (eq? (car style) 'bg-color) + "in~acolorbox" + "intext~acolor") + (if (= (length style) 2) + "" + "rgb")) + (if (= (length style) 2) + (cadr style) + (format "~a,~a,~a" + (/ (cadr style) 255.0) + (/ (caddr style) 255.0) + (/ (cadddr style) 255.0)))) + #f)] [(image-file? style) (let ([fn (install-file (image-file-path style))]) (printf "\\includegraphics{~a}" fn))] diff --git a/collects/scribblings/scribble/struct.scrbl b/collects/scribblings/scribble/struct.scrbl index 75676766..e8ea211e 100644 --- a/collects/scribblings/scribble/struct.scrbl +++ b/collects/scribblings/scribble/struct.scrbl @@ -342,6 +342,19 @@ The @scheme[style] field is normally either @scheme['subscript], @scheme['superscript], or @scheme['hspace];} + @item{a list of the form @scheme[(list 'color _name)] or + @scheme[(list 'color _byte _byte _byte)] to set the text color, + where @scheme[_name] is one of @scheme["white"], + @scheme["black"], @scheme["red"], @scheme["green"], + @scheme["blue"], @scheme["cyan"], @scheme["magenta"], or + @scheme["yellow"], or three @scheme[_byte]s specify RGB + values;} + + @item{a list of the form @scheme[(list 'bg-color _name)] or + @scheme[(list 'bg-color _byte _byte _byte)] to set the text + background color (with the same constraints and meanings as for + @scheme['color]);} + @item{an instance of @scheme[target-url] to generate a hyperlink; or} @item{an instance of @scheme[image-file] to support an inline image.}