aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArun Isaac2023-08-28 14:17:36 +0100
committerArun Isaac2023-08-29 17:08:46 +0100
commit71ecb3860c1a18df7bd46f8827cec55b9a53bae8 (patch)
tree077c9aa3bf12747f56ce3974d4094eadb071b46f
parente855bf0dde648a5361618eee6a0d02b236be60b2 (diff)
downloadskribilo-71ecb3860c1a18df7bd46f8827cec55b9a53bae8.tar.gz
skribilo-71ecb3860c1a18df7bd46f8827cec55b9a53bae8.tar.lz
skribilo-71ecb3860c1a18df7bd46f8827cec55b9a53bae8.zip
html: Implement color without HTML tables.
* src/guile/skribilo/engine/html.scm (color): Implement without HTML tables, using only CSS.
-rw-r--r--src/guile/skribilo/engine/html.scm51
1 files changed, 22 insertions, 29 deletions
diff --git a/src/guile/skribilo/engine/html.scm b/src/guile/skribilo/engine/html.scm
index 549bcfd..bb2f1d0 100644
--- a/src/guile/skribilo/engine/html.scm
+++ b/src/guile/skribilo/engine/html.scm
@@ -1597,35 +1597,28 @@ ignored, return #f."
;* color ... */
;*---------------------------------------------------------------------*/
(markup-writer 'color
- :options '(:bg :fg :width :margin)
- :before (lambda (node engine)
- (let ((m (markup-option node :margin))
- (w (markup-option node :width))
- (bg (markup-option node :bg))
- (fg (markup-option node :fg)))
- (when (html-color-spec? bg)
- (html-open 'table
- `((class . ,(markup-class node))
- (cellspacing . "0")
- (cellpadding . ,(or m 0))
- (width . ,(and w (html-width w)))))
- (html-open 'tbody)
- (html-open 'tr)
- (html-open 'td
- `((bgcolor . ,(with-output-to-string
- (cut output bg engine))))))
- (when (html-color-spec? fg)
- (html-open 'font
- `((color . ,(with-output-to-string
- (cut output fg engine))))))))
- :after (lambda (node engine)
- (when (html-color-spec? (markup-option node :fg))
- (html-close 'font))
- (when (html-color-spec? (markup-option node :bg))
- (html-close 'td)
- (html-close 'tr)
- (html-close 'tbody)
- (html-close 'table))))
+ :options '(:bg :fg :width :margin)
+ :before (lambda (node engine)
+ (let ((margin (markup-option node :margin))
+ (width (markup-option node :width))
+ (background-color (markup-option node :bg))
+ (foreground-color (markup-option node :fg)))
+ (html-open 'span
+ `((class . ,(markup-class node))
+ (style . ,(style-declaration
+ `((color . ,(and (html-color-spec? foreground-color)
+ (with-output-to-string
+ (cut output foreground-color engine))))
+ (background-color . ,(and (html-color-spec? background-color)
+ (with-output-to-string
+ (cut output background-color engine))))
+ (padding . ,(and margin
+ (string-append (number->string margin)
+ "px")))
+ (width . ,(and width
+ (string-append (html-width width)
+ "px"))))))))))
+ :after "</span>\n")
;*---------------------------------------------------------------------*/
;* frame ... */