You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Documents the ~30 CSS functional values Folio recognizes, grouped by
category: math (calc/min/max/clamp), color (rgb/rgba/hsl/hsla/cmyk),
gradients (linear/radial + repeating- variants), content/counters
(var, attr, content, counter, counters, string), transforms (10
2D forms), and url.
Each table calls out known limitations alongside related issue
numbers (#222, #265, #266, #274, #275) so an evaluator hits known
gaps from the doc, not from a failed render.
Same hand-written + drift-guard pattern as the At-rules section:
function dispatch is spread across 6 files (properties.go,
converter_style_parsers.go, css_props.go, page.go, converter_style.go,
bookmark.go) so a single AST grep isn't tractable. Instead,
TestFunctionsDocCoverage maintains a static expected list and asserts
(a) each name is referenced in the rendered doc and (b) one form per
category is actually accepted by the relevant parser — a sanity net
that fires if a parser is removed under a documented function.
CSS functional values recognized by Folio's parsers, grouped by category.
320
+
Functions not listed here pass through as opaque text and almost always
321
+
cause the containing declaration to be discarded.
322
+
323
+
### Math
324
+
325
+
Accepted everywhere a `<length>` or `<percentage>` is expected.
326
+
Folio's parser preserves these as single tokens through shorthand splitting,
327
+
so they survive inside `margin`, `padding`, `flex`, `transform()`, etc.
328
+
329
+
| Function | Notes |
330
+
|---|---|
331
+
|`calc()`| Supports `+`, `-`, `*`, `/` with operator precedence and nested parentheses. Mixed units (e.g. `calc(100% - 20px)`) resolve at layout time. |
332
+
|`min()`| Comma-separated argument list. Returns the smallest resolved value. |
333
+
|`max()`| Comma-separated argument list. Returns the largest resolved value. |
334
+
|`clamp()`|`clamp(<min>, <preferred>, <max>)`. |
335
+
336
+
Known limitations: `calc()` does not yet expand inside `rotate()`, `scale()`, `skew()`, `background-position`, or `linear-gradient()` color stops — see issues #265, #266, #274, #275.
337
+
338
+
### Color
339
+
340
+
Accepted everywhere a `<color>` is expected. Output is sRGB regardless of input form.
341
+
342
+
| Function | Notes |
343
+
|---|---|
344
+
|`rgb()`|`rgb(R, G, B)` or `rgb(R G B)`. Components are 0-255 integers or 0-100% percentages. |
345
+
|`rgba()`|`rgba(R, G, B, A)`. Alpha is 0-1 or 0-100%. |
346
+
|`hsl()`|`hsl(H, S%, L%)`. Hue in degrees. |
347
+
|`hsla()`|`hsla(H, S%, L%, A)`. |
348
+
|`cmyk()` / `device-cmyk()`|`cmyk(C, M, Y, K)` with components as 0-1 or 0-100%. Folio converts to sRGB for raster compositing; the original CMYK is preserved in the PDF color space for print pipelines. |
349
+
350
+
Known unsupported color functions: `oklch()`, `oklab()`, `lch()`, `lab()`, `color-mix()`, `color()` — see [Known unsupported features](#known-unsupported-features) for workarounds.
351
+
352
+
### Gradients
353
+
354
+
Accepted as `background-image` values.
355
+
356
+
| Function | Notes |
357
+
|---|---|
358
+
|`linear-gradient()`| Direction (`to right`, `45deg`, etc.) plus 2+ `<color>` stops. |
359
+
|`repeating-linear-gradient()`| Same syntax; tiles the gradient pattern. |
360
+
|`radial-gradient()`| Shape (`circle`, `ellipse`), size, and `<color>` stops. |
361
+
|`repeating-radial-gradient()`| Same syntax; tiles the gradient pattern. |
362
+
363
+
`conic-gradient()` is not supported.
364
+
365
+
### Content and counters
366
+
367
+
Used in `string-set`, `bookmark-label`, `content`, and `@page` margin boxes.
368
+
369
+
| Function | Notes |
370
+
|---|---|
371
+
|`var()`| CSS custom property reference. Supports a fallback as the second argument: `var(--c, #000)`. Resolved BEFORE per-property dispatch, so functions and gradients receive resolved values. |
372
+
|`attr()`| Reads an HTML attribute. Used in `bookmark-label`. |
373
+
|`content()`| Substitutes the element's text content. Used in `string-set` and `bookmark-label`. |
374
+
|`counter()`|`counter(<name>)` or `counter(<name>, <list-style>)`. Page counter `counter(page)` is supported in `@page` margin boxes. |
375
+
|`counters()`|`counters(<name>, <separator>)` for nested counter chains. |
376
+
|`string()`| Reads the latest value of a named string set via `string-set` (used in running headers). |
377
+
378
+
Known unsupported: `target-counter()` for cross-references — tracked as #222.
379
+
380
+
### Transform
381
+
382
+
Used in `transform`. Multiple functions compose in the listed order.
383
+
384
+
| Function | Notes |
385
+
|---|---|
386
+
|`translate()`|`translate(<tx>)` or `translate(<tx>, <ty>)`. Lengths in any supported unit; bare numbers treated as px. |
387
+
|`translateX()`| Single `<length>` argument. |
388
+
|`translateY()`| Single `<length>` argument. |
389
+
|`rotate()`| Single `<angle>`: `deg`, `rad`, `grad`, `turn`, or bare number (degrees). |
390
+
|`scale()`|`scale(<s>)` (uniform) or `scale(<sx>, <sy>)`. |
|`url()`| Used in `background-image`, `@font-face``src`, and asset references. Resolves through Folio's asset loader (BaseFS or HTTP via Client, subject to `Options.URLPolicy`). |
404
+
317
405
## Known unsupported features
318
406
319
407
These properties / values are commonly requested but NOT recognized by Folio.
b.WriteString("Known limitations: `calc()` does not yet expand inside `rotate()`, `scale()`, `skew()`, `background-position`, or `linear-gradient()` color stops — see issues #265, #266, #274, #275.\n\n")
214
+
b.WriteString("### Color\n\n")
215
+
b.WriteString("Accepted everywhere a `<color>` is expected. Output is sRGB regardless of input form.\n\n")
216
+
b.WriteString("| Function | Notes |\n")
217
+
b.WriteString("|---|---|\n")
218
+
b.WriteString("| `rgb()` | `rgb(R, G, B)` or `rgb(R G B)`. Components are 0-255 integers or 0-100% percentages. |\n")
219
+
b.WriteString("| `rgba()` | `rgba(R, G, B, A)`. Alpha is 0-1 or 0-100%. |\n")
220
+
b.WriteString("| `hsl()` | `hsl(H, S%, L%)`. Hue in degrees. |\n")
b.WriteString("| `cmyk()` / `device-cmyk()` | `cmyk(C, M, Y, K)` with components as 0-1 or 0-100%. Folio converts to sRGB for raster compositing; the original CMYK is preserved in the PDF color space for print pipelines. |\n\n")
223
+
b.WriteString("Known unsupported color functions: `oklch()`, `oklab()`, `lch()`, `lab()`, `color-mix()`, `color()` — see [Known unsupported features](#known-unsupported-features) for workarounds.\n\n")
224
+
b.WriteString("### Gradients\n\n")
225
+
b.WriteString("Accepted as `background-image` values.\n\n")
226
+
b.WriteString("| Function | Notes |\n")
227
+
b.WriteString("|---|---|\n")
228
+
b.WriteString("| `linear-gradient()` | Direction (`to right`, `45deg`, etc.) plus 2+ `<color>` stops. |\n")
229
+
b.WriteString("| `repeating-linear-gradient()` | Same syntax; tiles the gradient pattern. |\n")
b.WriteString("| `repeating-radial-gradient()` | Same syntax; tiles the gradient pattern. |\n\n")
232
+
b.WriteString("`conic-gradient()` is not supported.\n\n")
233
+
b.WriteString("### Content and counters\n\n")
234
+
b.WriteString("Used in `string-set`, `bookmark-label`, `content`, and `@page` margin boxes.\n\n")
235
+
b.WriteString("| Function | Notes |\n")
236
+
b.WriteString("|---|---|\n")
237
+
b.WriteString("| `var()` | CSS custom property reference. Supports a fallback as the second argument: `var(--c, #000)`. Resolved BEFORE per-property dispatch, so functions and gradients receive resolved values. |\n")
238
+
b.WriteString("| `attr()` | Reads an HTML attribute. Used in `bookmark-label`. |\n")
239
+
b.WriteString("| `content()` | Substitutes the element's text content. Used in `string-set` and `bookmark-label`. |\n")
240
+
b.WriteString("| `counter()` | `counter(<name>)` or `counter(<name>, <list-style>)`. Page counter `counter(page)` is supported in `@page` margin boxes. |\n")
241
+
b.WriteString("| `counters()` | `counters(<name>, <separator>)` for nested counter chains. |\n")
242
+
b.WriteString("| `string()` | Reads the latest value of a named string set via `string-set` (used in running headers). |\n\n")
243
+
b.WriteString("Known unsupported: `target-counter()` for cross-references — tracked as #222.\n\n")
244
+
b.WriteString("### Transform\n\n")
245
+
b.WriteString("Used in `transform`. Multiple functions compose in the listed order.\n\n")
246
+
b.WriteString("| Function | Notes |\n")
247
+
b.WriteString("|---|---|\n")
248
+
b.WriteString("| `translate()` | `translate(<tx>)` or `translate(<tx>, <ty>)`. Lengths in any supported unit; bare numbers treated as px. |\n")
249
+
b.WriteString("| `translateX()` | Single `<length>` argument. |\n")
250
+
b.WriteString("| `translateY()` | Single `<length>` argument. |\n")
251
+
b.WriteString("| `rotate()` | Single `<angle>`: `deg`, `rad`, `grad`, `turn`, or bare number (degrees). |\n")
252
+
b.WriteString("| `scale()` | `scale(<s>)` (uniform) or `scale(<sx>, <sy>)`. |\n")
253
+
b.WriteString("| `scaleX()` | Single `<number>` argument. |\n")
254
+
b.WriteString("| `scaleY()` | Single `<number>` argument. |\n")
255
+
b.WriteString("| `skew()` | `skew(<ax>)` or `skew(<ax>, <ay>)`. |\n")
256
+
b.WriteString("| `skewX()` | Single `<angle>` argument. |\n")
257
+
b.WriteString("| `skewY()` | Single `<angle>` argument. |\n\n")
b.WriteString("| `url()` | Used in `background-image`, `@font-face` `src`, and asset references. Resolves through Folio's asset loader (BaseFS or HTTP via Client, subject to `Options.URLPolicy`). |\n\n")
263
+
190
264
// Known unsupported list — hardcoded for now; future work could
191
265
// derive this from a separate registry.
192
266
b.WriteString("## Known unsupported features\n\n")
t.Errorf("function %q is in the documented-functions list but not present in CSS_SUPPORT.md — add it to the Functions section in html/css_props_doc.go", name)
1146
+
}
1147
+
}
1148
+
1149
+
// Behavioral smoke checks: one representative form per category to
1150
+
// catch the case where a function is documented but its parser was
1151
+
// removed. Per-function parity is covered exhaustively elsewhere
1152
+
// (parseLength, parseColor, parseTransform have their own test
1153
+
// suites); these assertions are a bare sanity net.
1154
+
ifl:=parseLength("calc(10px + 5px)"); l==nil {
1155
+
t.Error("parseLength rejected calc(10px + 5px) — Math section is documenting an unsupported form")
0 commit comments