Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,16 @@ sites keep the `github.com/pgsty/oink` module path instead of moving to a
`/v2` path. Version 1.6.0 retired several in this way, and 1.8.0 replaces
the `social` shortcode of 1.7.0 with a callout. A patch release only fixes.

## Unreleased

### Added

- **Highlighted `capabilities` code visuals.** A `visual.type: code` panel
takes `code` and `lang` as `code-plate` does, and Chroma highlights it.
`lines` keeps its per-line prefix colours. Conflicting inputs and missing,
blank or non-string source warn and drop the visual. Print shows the source
as plain text. Custom shells get the dark syntax palette in the Landing stylesheet.

## [1.8.0] — 2026-11-28

Paper looks as it did in 1.6.0 again. Its 1.7.0 refresh grows into a preset
Expand Down
29 changes: 23 additions & 6 deletions assets/css/td/landing.css
Original file line number Diff line number Diff line change
Expand Up @@ -804,6 +804,7 @@
.td-landing-codeplate pre {
margin: 0;
padding: clamp(20px, 4vw, 34px);
overflow-x: auto;
border: 0;
background: transparent;
color: #c9d6e8;
Expand All @@ -812,15 +813,15 @@
line-height: 1.9;
}

.td-landing-codeplate .c {
color: #64748b;
.td-landing-codeplate pre > code > .c {
color: #94a3b8;
}

.td-landing-codeplate .p {
.td-landing-codeplate pre > code > .p {
color: #7fd39a;
}

.td-landing-codeplate .ok {
.td-landing-codeplate pre > code > .ok {
color: #55c98a;
}

Expand Down Expand Up @@ -2184,11 +2185,11 @@
max-width: 920px;
}

.td-landing-code-plate-section .td-landing-codeplate .highlight,
.td-landing-code-plate-section .td-landing-codeplate .chroma {
.td-landing-codeplate[data-bs-theme='dark'] :is(.highlight, .chroma) {
margin: 0;
border: 0;
background: transparent;
color: #c9d6e8;
}

/* `preview`: the Markdown an author writes beside what the theme renders
Expand Down Expand Up @@ -2682,6 +2683,22 @@
}

@media print {
.td-landing-codeplate {
background: #fff;
box-shadow: none;
}
.td-landing-codeplate[data-bs-theme='dark'] :is(pre, code, span, b) {
color: var(--td-print-ink, #171717) !important;
}
.td-landing-codeplate pre,
.td-landing-codeplate pre > code {
white-space: pre-wrap;
overflow-wrap: anywhere;
overflow: visible;
}
.td-landing-codeplate .chroma .line {
display: block;
}
.td-landing-marquee {
overflow: visible;
mask-image: none;
Expand Down
64 changes: 64 additions & 0 deletions bin/check-landing.py
Original file line number Diff line number Diff line change
Expand Up @@ -372,6 +372,8 @@ def create_site(root: Path, landing_data: str, *, language: str = "en") -> None:
("zero-capabilities-columns", "sections:\n - type: capabilities\n data:\n items:\n - title: Bad\n visual:\n type: components\n columns: 0\n items: [{title: A, icon: fa-solid fa-star}]\n", "capabilities visual columns must be at least 1"),
("bad-capabilities-rules", "sections:\n - type: capabilities\n data:\n items:\n - title: Bad\n visual:\n type: shell\n rules: not-a-list\n", "rules must be an array"),
("bad-capabilities-rule-width", "sections:\n - type: capabilities\n data:\n items:\n - title: Bad\n visual:\n type: shell\n rules: ['88%', 'nope']\n", "is not a CSS length"),
("capabilities-code-and-lines", "sections:\n - type: capabilities\n data:\n items:\n - title: Bad\n visual:\n type: code\n lang: python\n code: print(1)\n lines: [{text: print(1)}]\n", "code visual requires exactly one of code or lines"),
("capabilities-code-empty", "sections:\n - type: capabilities\n data:\n items:\n - title: Bad\n visual: {type: code, title: Empty}\n", "code visual requires exactly one of code or lines"),
("bad-marquee-rows", "sections:\n - type: logo-wall\n data:\n layout: marquee\n rows: nope\n items: [{title: Logo}]\n", 'marquee rows "nope" is not a whole number'),
)

Expand All @@ -395,6 +397,9 @@ def check_invalid(hugo: str) -> list[str]:
require(page.is_file(), f"invalid landing case {name} emitted no safe page output", errors)
if page.is_file():
rendered = page.read_text(encoding="utf-8")
if name.startswith("capabilities-code-"):
require("td-landing-codeplate" not in rendered and "<h3>Bad</h3>" in rendered,
f"{name} must drop only the invalid visual and keep its item", errors)
if name == "bad-preview-source":
require("td-landing-preview-section" not in rendered,
"non-string preview.source still rendered its section", errors)
Expand Down Expand Up @@ -648,6 +653,64 @@ def check_code_focus(hugo: str) -> list[str]:
return errors


def check_capabilities_highlight(hugo: str) -> list[str]:
"""Exercise highlighted source, invalid inputs and static Print in the same item list."""
errors: list[str] = []
data = """sections:
- type: capabilities
data:
items:
- title: Python
visual:
type: code
title: Python
lang: python
code: |
import pystac
cat = pystac.Catalog.from_file("<catalog>")
- title: Plain fallback
visual: {type: code, code: " a < b", lang: [python]}
- title: Map input
visual: {type: code, code: {foo: bar}}
- title: Null input
visual: {type: code, code: null}
- title: Blank input
visual: {type: code, code: " "}
"""
with tempfile.TemporaryDirectory(prefix="td-landing-capabilities-highlight-") as temp:
site = Path(temp)
create_site(site, data)
config = site / "hugo.yaml"
write(config, config.read_text().replace("page: [HTML]", "page: [HTML, print]"))
result = run(hugo, site)
if result.returncode != 0:
return [f"capabilities highlight fixture failed: {result.stdout}{result.stderr}"]
source = (site / "public/test/index.html").read_text(encoding="utf-8")
module = source.partition('<article class="td-landing-module">')[2].partition("</article>")[0]
require('class="chroma"' in module,
"capabilities code visual with code was not highlighted", errors)
require('data-lang="python"' in module or "language-python" in module,
"capabilities code visual lost its language", errors)
require('<span class="kn">import</span>' in module,
"capabilities code visual lost its Chroma tokens", errors)
diagnostics = result.stdout + result.stderr
for item, message in ((2, "visual.lang must be a string"), (3, "visual.code must be a string"),
(4, "visual.code must be a string"), (5, "visual.code must not be blank")):
require(f"capabilities item {item} {message}" in diagnostics,
f"capabilities item {item} lost its input diagnostic", errors)
printed = (site / "public/_print/test/index.html").read_text(encoding="utf-8")
for label, html in (("HTML", source), ("Print", printed)):
require(html.count('class="td-landing-codeplate"') == 2 and
all(title in html for title in ("Map input", "Null input", "Blank input")),
f"{label} must keep the invalid items' text and omit their plates", errors)
require("&lt;catalog&gt;" in html and " a &lt; b" in html,
f"{label} lost escaped source or indentation", errors)
require('<pre><code>import pystac' in printed and
all("tabindex=" not in tag for tag in re.findall(r"<pre\b[^>]*>", printed)),
"Print must preserve source without an interactive focus target", errors)
return errors


def check_rss(hugo: str) -> list[str]:
errors: list[str] = []
with tempfile.TemporaryDirectory(prefix="td-landing-components-landing-rss-") as temp:
Expand Down Expand Up @@ -877,6 +940,7 @@ def main() -> int:
+ check_rss(args.hugo)
+ check_markdown_scopes(args.hugo)
+ check_code_focus(args.hugo)
+ check_capabilities_highlight(args.hugo)
+ check_capabilities_preset_buttons(args.hugo)
)
if errors:
Expand Down
2 changes: 1 addition & 1 deletion layouts/_partials/css/layers.html
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
"appearance" "presets" "experimental-presets"
)
"landing" (slice
"charset" "landing" "presets" "experimental-presets"
"charset" "chroma/dark" "chroma/theme-dark" "landing" "presets" "experimental-presets"
)
"search" (slice
"charset" "shell/search"
Expand Down
14 changes: 14 additions & 0 deletions layouts/_partials/landing/highlight-code.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{{- $source := strings.TrimRight "\r\n" .code -}}
{{- $lang := "text" -}}
{{- if isset .data "lang" -}}
{{- if eq (printf "%T" .data.lang) "string" -}}
{{- $lang = strings.TrimSpace .data.lang | default "text" -}}
{{- else -}}
{{- warnf "%s.lang must be a string; using plain text" .position -}}
{{- end -}}
{{- end -}}
{{- if .interactive -}}
{{- transform.Highlight $source $lang (dict "noClasses" false) -}}
{{- else -}}
<pre><code>{{ $source }}</code></pre>
{{- end -}}
13 changes: 12 additions & 1 deletion layouts/_partials/landing/sections/capabilities.html
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,21 @@ <h3>
{{- if not (in (slice "code" "shell" "components" "image" "card") $visualType) -}}
{{- warnf "%s: capabilities item %d has unsupported visual.type %q; dropping the visual" $page.Path (add $index 1) $visualType -}}
{{- end -}}
{{- if eq $visualType "code" }}
{{- $hasCode := isset . "code" -}}{{- $hasLines := isset . "lines" -}}
{{- if and (eq $visualType "code") (eq $hasCode $hasLines) -}}
{{- warnf "%s: capabilities item %d code visual requires exactly one of code or lines; dropping the visual" $page.Path (add $index 1) -}}
{{- else if and (eq $visualType "code") $hasCode (ne (printf "%T" .code) "string") -}}
{{- warnf "%s: capabilities item %d visual.code must be a string; dropping the visual" $page.Path (add $index 1) -}}
{{- else if and (eq $visualType "code") $hasCode (not (strings.TrimSpace .code)) -}}
{{- warnf "%s: capabilities item %d visual.code must not be blank; dropping the visual" $page.Path (add $index 1) -}}
{{- else if eq $visualType "code" }}
<div class="td-landing-codeplate" data-bs-theme="dark" aria-label="{{ .aria_label | default .title }}">
<div class="td-landing-codeplate__head"><span><i></i><i></i><i></i></span><b>{{ .title }}</b></div>
{{- if $hasCode }}
{{- partial "landing/highlight-code.html" (dict "code" .code "data" . "interactive" $interactive "position" (printf "%s: capabilities item %d visual" $page.Path (add $index 1))) -}}
{{- else }}
<pre{{ if $interactive }} tabindex="0"{{ end }}><code>{{ partial "landing/code-lines.html" (dict "lines" .lines "position" (printf "%s: capabilities item %d visual" $page.Path (add $index 1))) }}</code></pre>
{{- end }}
</div>
{{- else if eq $visualType "shell" }}
<div class="td-landing-shell-demo" aria-hidden="true">
Expand Down
3 changes: 1 addition & 2 deletions layouts/_partials/landing/sections/code-plate.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@
<div class="td-landing-codeplate__head"><span><i></i><i></i><i></i></span><b>{{ $data.title | default $data.aria_label }}</b></div>
{{- if $hasCode }}
{{- $code := strings.TrimRight "\r\n" (printf "%v" $data.code) -}}{{- if not $code }}{{ warnf "%s: code-plate.code must not be empty; rendering an empty plate" $page.Path }}{{ end -}}
{{- $lang := strings.TrimSpace (printf "%v" ($data.lang | default "text")) -}}
{{- transform.Highlight $code $lang (dict "noClasses" false) -}}
{{- partial "landing/highlight-code.html" (dict "code" $code "data" $data "interactive" $interactive "position" (printf "%s: code-plate" $page.Path)) -}}
{{- else }}<pre{{ if $interactive }} tabindex="0"{{ end }}><code>{{ partial "landing/code-lines.html" (dict "lines" $data.lines "position" (printf "%s: code-plate" $page.Path)) }}</code></pre>{{ end -}}
</div>
</div>
Expand Down