home
readme
diff
tree
note
docs
0commit f1441e4939fad0f4d8aab7555f937452cb6d3a8a
1Author: lakefox <mason@lakefox.net>
2Date: Tue Jan 13 19:38:13 2026 -0700
3
4 docs
5
6diff --git a/cat b/cat
7deleted file mode 100644
8index d72af31..0000000
9--- a/cat
10+++ /dev/null
11@@ -1 +0,0 @@
12-asd
13diff --git a/man/adding-css-properties.3 b/docs/adding-css-properties.3
14similarity index 100%
15rename from man/adding-css-properties.3
16rename to docs/adding-css-properties.3
17diff --git a/man/grim.3 b/docs/grim.3
18similarity index 100%
19rename from man/grim.3
20rename to docs/grim.3
21diff --git a/man/supported-css-selectors.1 b/docs/supported-css-selectors.1
22similarity index 100%
23rename from man/supported-css-selectors.1
24rename to docs/supported-css-selectors.1
25diff --git a/playground/window.cc b/playground/window.cc
26index ed43569..e8ec151 100644
27--- a/playground/window.cc
28+++ b/playground/window.cc
29@@ -7,7 +7,7 @@
30
31 int main() {
32 std::string html = "<!DOCTYPE html>"
33- "<html width=\"100\">"
34+ "<html width=\"\">"
35 "<head>"
36 "<title>This is a simple test</title>"
37 "<link rel=\"stylesheet\" href=\'tests/style.css\'/>"
38@@ -47,7 +47,10 @@ int main() {
39 document.cacheHeight(700);
40 document.cacheEM(16);
41
42- std::vector<Unit> units = getUnit(&window.CSS, "attr(width vw, 10px)");
43+
44+ document.children[0].cacheWidth(1000);
45+
46+ std::vector<Unit> units = getUnit(&window.CSS, "attr(width px, 10px)");
47
48 std::cout << UnitLengthValue(&document.children[0], &window.CSS, units, 0, units.size()) << std::endl;
49 }
50diff --git a/src/grim.cc b/src/grim.cc
51index a2bbff7..e18d42c 100755
52--- a/src/grim.cc
53+++ b/src/grim.cc
54@@ -1296,33 +1296,33 @@ float UnitLengthValue(Node* n, Style* style, const std::vector<Unit>& units, siz
55 case UnitType::ATTR:
56 extracted = extractUnits(units, i+1, i+1+unit.value.INT);
57
58- if (extracted.size() == 3) {
59- if (units[extracted[0].start].type == UnitType::VAR) {
60- s = n->getAttribute(style->variables.key(units[extracted[0].start].value.INT));
61-
62- if (!s.empty()) {
63- // attr(size px, 10)
64- // s = n->getAttribute(size) size="20"
65- std::vector<Unit> us = getUnit(style, s);
66- // us = {NUMBER, 20}
67- // extracted[1] == {type: PX} || {type::TYPE}
68- // Add the type of the next if the type is inside of type(px) or just add the type px
69- if (units[extracted[1].start].type == UnitType::TYPE && extracted[1].end-extracted[1].start >= 2) {
70+ if (units[extracted[0].start].type == UnitType::VAR) {
71+ s = n->getAttribute(style->variables.key(units[extracted[0].start].value.INT));
72+
73+ if (!s.empty()) {
74+ // attr(size px, 10)
75+ // s = n->getAttribute(size) size="20"
76+ std::vector<Unit> us = getUnit(style, s);
77+ // us = {NUMBER, 20}
78+ // extracted[1] == {type: PX} || {type::TYPE}
79+ // Add the type of the next if the type is inside of type(px) or just add the type px
80+ if (extracted.size() > 1) {
81+ if (units[extracted[1].start].type == UnitType::TYPE) {
82 us[0].type = units[extracted[1].start+1].type;
83 } else {
84 us[0].type = units[extracted[1].start].type;
85 }
86-
87- i = extracted[1].end;
88- value = UnitLengthValue(n, style, us, 0, us.size());
89- } else {
90- // Default value
91- value = UnitLengthValue(n, style, units, extracted[2].start, extracted[2].end);
92- i = extracted[2].end;
93 }
94+
95+ value = UnitLengthValue(n, style, us, 0, us.size());
96+ } else if (extracted.size() == 3) {
97+ // Default value
98+ value = UnitLengthValue(n, style, units, extracted[2].start, extracted[2].end);
99 }
100 }
101
102+ i += unit.value.INT;
103+
104 // Need to add variable injection and group handling
105 }
106