about summary refs log tree commit diff stats
path: root/src/html
diff options
context:
space:
mode:
authorbptato <nincsnevem662@gmail.com>2024-02-24 18:14:00 +0100
committerbptato <nincsnevem662@gmail.com>2024-02-24 18:19:58 +0100
commitf11c942585446be074412b2cc270f30532351882 (patch)
tree5bc37a67f6bde5dccd8d685b47ef6f9602e33a26 /src/html
parentea3c192626b4a33d9a6201d82a1b4a1f306f58eb (diff)
downloadchawan-f11c942585446be074412b2cc270f30532351882.tar.gz
Allow non-RGB colors in CSS
The -cha-ansi color type now sets ANSI colors in CSS.

Also, color correction etc. has been improved a bit:

* don't completely reset output state in processFormat for new colors
* defaultColor is now separated from ANSI color type 0
* bright ANSI colors are no longer replaced with bold + dark variant
* replaced ANSI color map to match xterm defaults
Diffstat (limited to 'src/html')
-rw-r--r--src/html/dom.nim10
1 files changed, 8 insertions, 2 deletions
diff --git a/src/html/dom.nim b/src/html/dom.nim
index 597d34b9..39a80681 100644
--- a/src/html/dom.nim
+++ b/src/html/dom.nim
@@ -2288,12 +2288,18 @@ isDefaultPassive = func (eventTarget: EventTarget): bool =
 
 proc parseColor(element: Element, s: string): RGBAColor =
   let cval = parseComponentValue(newStringStream(s))
-  #TODO TODO TODO return element style
+  #TODO return element style
   # For now we just use white.
   let ec = rgb(255, 255, 255)
   if cval.isErr:
     return ec
-  return cssColor(cval.get).get(ec)
+  let color0 = cssColor(cval.get)
+  if color0.isErr:
+    return ec
+  let color = color0.get
+  if color.t != ctRGB:
+    return ec
+  return color.rgbacolor
 
 #TODO ??
 func target0*(element: Element): string =