typst / typst/typst

More typed `style` parameter for the typed HTML API

Open
#6,861 1 comment 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

feature request html scripting
Dominant language
Rust
Stars
56.1k
Forks
1.7k
Avg merge
3d 10h
Merged PRs (30d)
22

Description

Description

Currently, the style parameter of HTML element functions (part of the typed HTML API) accepts a string. It should accept a dictionary mapping CSS properties to values. Passing the dictionary d would be equivalent to passing the string d.pairs().map(((prop, value)) => prop + ": " + value).join("; ") with the current API. One could also imagine that the values of the properties be checked as well.

Note that one limitation of dictionaries is that they can only contain a given key once, whereas the HTML style attribute may contain the same CSS property multiple times. Therefore, it is probably desirable to keep allowing bare strings.

Use Case

More readable code when the value of the style parameter is not a constant string.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by locating the typed HTML API and the implementation of its style parameter; the issue names no files or tests. Confirm how string styles are currently handled, then define the dictionary form while retaining bare strings and verify that dictionary pairs produce equivalent CSS declarations.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
api
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.