{"id":24408423,"url":"https://github.com/pgbiel/elembic","last_synced_at":"2026-04-01T19:45:02.223Z","repository":{"id":272212434,"uuid":"909821384","full_name":"PgBiel/elembic","owner":"PgBiel","description":"Framework for custom elements and types in Typst","archived":false,"fork":false,"pushed_at":"2025-10-07T01:24:52.000Z","size":851,"stargazers_count":58,"open_issues_count":18,"forks_count":4,"subscribers_count":2,"default_branch":"main","last_synced_at":"2026-03-28T01:55:09.483Z","etag":null,"topics":["data-structures","elements","types","typst","validation"],"latest_commit_sha":null,"homepage":"https://pgbiel.github.io/elembic/","language":"Typst","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/PgBiel.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null},"funding":{"github":"PgBiel"}},"created_at":"2024-12-29T21:46:57.000Z","updated_at":"2026-03-25T22:03:23.000Z","dependencies_parsed_at":null,"dependency_job_id":"2f404027-4688-46d3-9e94-4eeddb21b822","html_url":"https://github.com/PgBiel/elembic","commit_stats":null,"previous_names":["pgbiel/elembic"],"tags_count":8,"template":false,"template_full_name":null,"purl":"pkg:github/PgBiel/elembic","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PgBiel%2Felembic","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PgBiel%2Felembic/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PgBiel%2Felembic/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PgBiel%2Felembic/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/PgBiel","download_url":"https://codeload.github.com/PgBiel/elembic/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PgBiel%2Felembic/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31291206,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-01T13:12:26.723Z","status":"ssl_error","status_checked_at":"2026-04-01T13:12:25.102Z","response_time":53,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["data-structures","elements","types","typst","validation"],"created_at":"2025-01-20T05:46:25.457Z","updated_at":"2026-04-01T19:45:02.217Z","avatar_url":"https://github.com/PgBiel.png","language":"Typst","funding_links":["https://github.com/sponsors/PgBiel"],"categories":[],"sub_categories":[],"readme":"# elembic\nFramework for custom elements and types in Typst. **Supports Typst 0.11.0 or later.**\n\n**Read the book:** https://pgbiel.github.io/elembic\n\n**Mirrors:** [GitHub (pgbiel/elembic)](https://github.com/PgBiel/elembic); [Codeberg (pgbiel/elembic)](https://codeberg.org/PgBiel/elembic)\n\n## About\n\nElembic lets you create [**custom elements,**](https://pgbiel.github.io/elembic/elements/creating/index.html) which are **reusable and customizable document components,** with support for **typechecked fields, [show and set rules](https://pgbiel.github.io/elembic/elements/styling/index.html)** (without using any `state` by default!), **[reference and outline support,](https://pgbiel.github.io/elembic/elements/creating/labels-refs.html)** as well as features not present in Typst elements today such as **[revokable rules](https://pgbiel.github.io/elembic/elements/styling/revoke.html)** and **[nested element selectors](https://pgbiel.github.io/elembic/elements/filters/within.html)**. In addition, Elembic lets you create [**custom types,**](https://pgbiel.github.io/elembic/types/custom-types/index.html) which also support **typechecked fields** but also [**custom casting**](https://pgbiel.github.io/elembic/types/custom-types/casts.html), and can be used in element fields or by themselves in arbitrary Typst code.\n\nElembic's name comes from \"element\" + [\"alembic\"](https://en.wikipedia.org/wiki/Alembic), to indicate that one of Elembic's goals is to experiment with different approaches for this functionality, and to help shape a future update to Typst that includes native custom elements, which will eventually remove the need for using this package.\n\nIts documentation is at the Elembic Handbook: [https://pgbiel.github.io/elembic](https://pgbiel.github.io/elembic)\n\nThis library has a few limitations which are [appropriately noted in the book.](https://pgbiel.github.io/elembic/about/limitations.html)\n\n## Who is elembic for?\n\nElembic is especially suited for:\n1. **Packages:** elembic's elements allows creating reusable components which can be freely customized by your package's end users. With typechecking and other features, elembic's got you covered in terms of flexibility. See the [\"Simple Theorems\" example](https://pgbiel.github.io/elembic/examples/simple-theorems.html) for a sample.\n2. **Templates:** elembic's elements can be used for fine-grained configuration of parts of your template. See the [\"Simple Thesis\" example](https://pgbiel.github.io/elembic/examples/simple-thesis.html) for a sample.\n\n## Installation\n\nJust import the latest elembic version from the package manager and you're ready to go!\n\n```typ\n#import \"@preview/elembic:1.1.1\" as e\n\n// See the full example below\n#show: e.set_(element, stroke: red)\n// ...\n```\n\n## Example\n\n### Custom element\n\n```typ\n#import \"@preview/elembic:1.1.1\" as e: field, types\n\n#let bigbox = e.element.declare(\n  \"bigbox\",\n  prefix: \"@preview/my-package,v1\",\n  doc: \"A fancy and customizable box.\",\n  display: it =\u003e block(fill: it.fill, stroke: it.stroke, inset: 5pt, it.body),\n  fields: (\n    field(\"body\", types.option(content), doc: \"Box contents\", required: true),\n    field(\"fill\", types.option(types.paint), doc: \"Box fill\"),\n    field(\"stroke\", types.option(stroke), doc: \"Box border\", default: red)\n  )\n)\n\n#bigbox[abc]\n\n#show: e.set_(bigbox, fill: red)\n\n#bigbox(stroke: blue + 2pt)[def]\n```\n\n!['abc' with no fill and a thin red stroke, followed by 'def' with red fill and blue thicker stroke](https://github.com/user-attachments/assets/c852cfcd-c0de-446a-999b-5ecaa44809b7)\n\n### Custom type\n\n```typ\n#import \"@preview/elembic:1.1.1\" as e: field, types\n\n#let person = e.types.declare(\n  \"person\",\n  prefix: \"@preview/my-package,v1\",\n  doc: \"Relevant data for a person.\",\n  fields: (\n    field(\"name\", str, doc: \"Person's name\", required: true, named: true),\n    field(\"age\", int, doc: \"Person's age\", default: 40),\n    field(\"preference\", types.any, doc: \"Anything the person likes\", default: none)\n  ),\n  casts: (\n    (from: dictionary),\n    (from: str, with: person =\u003e name =\u003e person(name: name)),\n  )\n)\n\n#assert.eq(\n  e.repr(person(name: \"John\", age: 50, preference: \"soup\")),\n  \"person(age: 50, name: \\\"John\\\", preference: \\\"soup\\\")\"\n)\n\n// Manually invoke typechecking and cast\n#assert.eq(\n  types.cast((name: \"abc\", age: 99), person),\n  (true, person(name: \"abc\", age: 99))\n)\n\n#assert.eq(\n  types.cast(\"abc\", person),\n  (true, person(name: \"abc\"))\n)\n\n// Can then use 'person' as the type of an element's field, for example\n```\n\n## Source structure\n\n- `pub/`: Contains public re-exports of each module (so we can keep some things private)\n- `data`: Functions and constants related to extracting data from elements and types\n- `element`: Functions related to creating and using elements and their rules (set rules, revoke rules and so on)\n- `filters`: Functions to create and match element filters\n- `types`: Functions and constants related to Elembic's custom type system\n- `fields`: Functions related to element and type field parsing\n\n## License\n\nLicensed under MIT or Apache-2.0, at your option.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpgbiel%2Felembic","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpgbiel%2Felembic","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpgbiel%2Felembic/lists"}