{"id":39748738,"url":"https://github.com/nutthead/nutthead-ebnf.typ","last_synced_at":"2026-01-18T11:23:40.124Z","repository":{"id":326475879,"uuid":"1105698170","full_name":"nutthead/nutthead-ebnf.typ","owner":"nutthead","description":"A Typst package for rendering Extended Backus-Naur Form (EBNF) grammars with customizable fonts and color schemes","archived":false,"fork":false,"pushed_at":"2025-12-14T18:18:45.000Z","size":309,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-12-15T18:33:35.456Z","etag":null,"topics":["ebnf","typst","typst-package"],"latest_commit_sha":null,"homepage":"","language":"Typst","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/nutthead.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"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}},"created_at":"2025-11-28T02:57:37.000Z","updated_at":"2025-12-14T14:16:22.000Z","dependencies_parsed_at":"2025-12-02T01:00:01.199Z","dependency_job_id":null,"html_url":"https://github.com/nutthead/nutthead-ebnf.typ","commit_stats":null,"previous_names":["nutthead/nutthead-ebnf"],"tags_count":4,"template":false,"template_full_name":null,"purl":"pkg:github/nutthead/nutthead-ebnf.typ","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nutthead%2Fnutthead-ebnf.typ","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nutthead%2Fnutthead-ebnf.typ/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nutthead%2Fnutthead-ebnf.typ/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nutthead%2Fnutthead-ebnf.typ/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nutthead","download_url":"https://codeload.github.com/nutthead/nutthead-ebnf.typ/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nutthead%2Fnutthead-ebnf.typ/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28535163,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-18T10:13:46.436Z","status":"ssl_error","status_checked_at":"2026-01-18T10:13:11.045Z","response_time":98,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: 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":["ebnf","typst","typst-package"],"created_at":"2026-01-18T11:23:40.023Z","updated_at":"2026-01-18T11:23:40.087Z","avatar_url":"https://github.com/nutthead.png","language":"Typst","funding_links":[],"categories":[],"sub_categories":[],"readme":"# nutthead-ebnf\n\nA Typst package for rendering Extended Backus-Naur Form (EBNF) grammars.\n\nFaithful to the [ISO 14977 (PDF)](https://www.cl.cam.ac.uk/~mgk25/iso-14977.pdf) standard, albeit with a few judicious departures where deemed necessary.\n\n## Rust Function Example\n\n![Rust function example](examples/rust.svg)\n\n## Usage\n\n````typ\n#import \"@preview/nutthead-ebnf:0.3.1\": *\n\n#context [\n  #ebnf[\n    #[\n      #syntax-rule(\n        meta-id: [CHAR],\n        definition-list: (\n          [\n            #special-sequence[a Unicode scalar value]\n          ],\n        )\n      )\n\n      #syntax-rule(\n        meta-id: [NUL],\n        definition-list: (\n          [\n            #terminal[U+0000]\n          ],\n        )\n      )\n\n      #syntax-rule(\n        meta-id: [Function],\n        rule-comment: [some comment],\n        rule-example: [```rust fn main() { }```],\n        definition-list: (\n          [\n            #single-definition(illumination: \"dimmed\")[FunctionQualifiers]\n            #terminal[fn]\n            #single-definition[IDENTIFIER]\n            #single-definition(illumination: \"dimmed\", qualifier: \"opt\")[GenericParams]\n          ],\n          (indent: 2),\n          [\n            #terminal[(]\n            #single-definition(qualifier: \"opt\")[FunctionParameters]\n            #terminal[)]\n          ],\n          [\n            #single-definition(illumination: \"dimmed\", qualifier: \"opt\")[FunctionReturnType]\n            #single-definition(illumination: \"dimmed\", qualifier: \"opt\")[WhereClause]\n          ],\n          [\n            #grouped-sequence(\n              single-definition[BlockExpression],\n              terminal(illumination: \"dimmed\")[;]\n            )\n          ],\n        ),\n      )\n    ]\n  ]\n]\n````\n\n## API Reference\n\n### `ebnf()`\n\nContainer function that configures the EBNF rendering context.\n\n| Parameter                     | Type      | Default                  | Description                        |\n| ----------------------------- | --------- | ------------------------ | ---------------------------------- |\n| `body`                        | `content` | —                        | Content to render                  |\n| `definition-separator-symbol` | `str`     | `\"\\|\"`                   | Symbol for separating alternatives |\n| `delimiter-symbol`            | `str`     | ``\"`\"``                  | Delimiter for terminal symbols     |\n| `default-font`                | `dict`    | Libertinus Serif 1em     | Default text font                  |\n| `monospaced-font`             | `dict`    | DejaVu Sans Mono 0.887em | Monospace font for terminals       |\n\n```typ\n#context [\n  #ebnf[\n    #syntax-rule(...)\n  ]\n]\n```\n\n### `syntax-rule()`\n\nDefines a production rule with a meta-identifier, optional comment, optional code example, and definition list.\n\n| Parameter         | Type      | Default | Description                                   |\n| ----------------- | --------- | ------- | --------------------------------------------- |\n| `meta-id`         | `content` | `none`  | Left-hand side identifier                     |\n| `rule-comment`    | `content` | `none`  | Optional comment for the rule                 |\n| `rule-example`    | `content` | `none`  | Optional code example (typically raw content) |\n| `definition-list` | `array`   | `none`  | Array of definitions and indent controls      |\n\n````typ\n#syntax-rule(\n  meta-id: [Function],\n  rule-comment: [some comment],\n  rule-example: [```rust fn main() { }```],\n  definition-list: (\n    (indent: 1),\n    [#terminal[fn] #single-definition[IDENTIFIER]],\n    (indent: 2),\n    [#terminal[(] #single-definition(qualifier: \"opt\")[Params] #terminal[)]],\n  ),\n)\n````\n\n### `single-definition()`\n\nRenders one or more non-terminal references or terminals as a sequence in italic. Accepts variadic positional arguments.\n\n| Parameter      | Type      | Default | Description                                  |\n| -------------- | --------- | ------- | -------------------------------------------- |\n| `..body`       | `content` | —       | One or more elements to render as a sequence |\n| `illumination` | `str`     | `none`  | `\"dimmed\"` or `\"highlighted\"`                |\n| `qualifier`    | `str`     | `none`  | `\"opt\"` (?), `\"some\"` (+), or `\"any\"` (\\*)   |\n\n```typ\n#single-definition[IDENTIFIER]\n#single-definition(illumination: \"dimmed\")[FunctionQualifiers]\n#single-definition(qualifier: \"opt\")[GenericParams]\n// Multiple elements in a sequence\n#single-definition(\n  terminal[fn],\n  [IDENTIFIER],\n  terminal[(]\n)\n```\n\n### `terminal()`\n\nRenders a terminal symbol in monospace font with delimiters.\n\n| Parameter      | Type      | Default | Description                                |\n| -------------- | --------- | ------- | ------------------------------------------ |\n| `body`         | `content` | —       | The terminal text                          |\n| `illumination` | `str`     | `none`  | `\"dimmed\"` or `\"highlighted\"`              |\n| `qualifier`    | `str`     | `none`  | `\"opt\"` (?), `\"some\"` (+), or `\"any\"` (\\*) |\n\n```typ\n#terminal[fn]\n#terminal(illumination: \"dimmed\")[;]\n#terminal(qualifier: \"opt\")[const]\n```\n\n### `meta-identifier()`\n\nRenders a meta-identifier (left-hand side of a production) in bold with a production arrow.\n\n```typ\n#meta-identifier[Function]\n```\n\n### `comment()`\n\nRenders a comment enclosed in comment delimiters `(* ... *)`.\n\n| Parameter | Type      | Default | Description     |\n| --------- | --------- | ------- | --------------- |\n| `body`    | `content` | —       | Comment content |\n\n```typ\n#comment[This is a comment about the grammar rule]\n```\n\n### `code-example()`\n\nRenders a code example enclosed in comment delimiters `(* ... *)`. Typically used with raw content blocks.\n\n| Parameter | Type      | Default | Description      |\n| --------- | --------- | ------- | ---------------- |\n| `raw`     | `content` | —       | Raw code example |\n\n````typ\n#code-example[```rust fn main() { }```]\n````\n\n### `grouped-sequence()`\n\nRenders content in parentheses `( ... )` for grouping alternatives. Accepts variadic positional arguments separated by the definition separator symbol.\n\n| Parameter      | Type      | Default | Description                                |\n| -------------- | --------- | ------- | ------------------------------------------ |\n| `..body`       | `content` | —       | One or more alternatives to group          |\n| `illumination` | `str`     | `none`  | `\"dimmed\"` or `\"highlighted\"`              |\n| `qualifier`    | `str`     | `none`  | `\"opt\"` (?), `\"some\"` (+), or `\"any\"` (\\*) |\n\n```typ\n#grouped-sequence(\n  single-definition[BlockExpression],\n  terminal(illumination: \"dimmed\")[;]\n)\n```\n\n### `optional-sequence()`\n\nRenders content in square brackets `[ ... ]` for optional elements. Accepts variadic positional arguments separated by the definition separator symbol.\n\n| Parameter      | Type      | Default | Description                                |\n| -------------- | --------- | ------- | ------------------------------------------ |\n| `..body`       | `content` | —       | One or more optional alternatives          |\n| `illumination` | `str`     | `none`  | `\"dimmed\"` or `\"highlighted\"`              |\n| `qualifier`    | `str`     | `none`  | `\"opt\"` (?), `\"some\"` (+), or `\"any\"` (\\*) |\n\n```typ\n#optional-sequence(\n  terminal[else],\n  single-definition[Block]\n)\n```\n\n### `repeated-sequence()`\n\nRenders content in curly braces `{ ... }` for repetition (zero or more). Accepts variadic positional arguments separated by the definition separator symbol.\n\n| Parameter      | Type      | Default | Description                                |\n| -------------- | --------- | ------- | ------------------------------------------ |\n| `..body`       | `content` | —       | One or more alternatives to repeat         |\n| `illumination` | `str`     | `none`  | `\"dimmed\"` or `\"highlighted\"`              |\n| `qualifier`    | `str`     | `none`  | `\"opt\"` (?), `\"some\"` (+), or `\"any\"` (\\*) |\n\n```typ\n#repeated-sequence(single-definition[Statement])\n```\n\n### `special-sequence()`\n\nRenders content in question marks `? ... ?` for special sequences. Accepts variadic positional arguments separated by the definition separator symbol.\n\n| Parameter      | Type      | Default | Description                                |\n| -------------- | --------- | ------- | ------------------------------------------ |\n| `..body`       | `content` | —       | One or more special sequence descriptions  |\n| `illumination` | `str`     | `none`  | `\"dimmed\"` or `\"highlighted\"`              |\n| `qualifier`    | `str`     | `none`  | `\"opt\"` (?), `\"some\"` (+), or `\"any\"` (\\*) |\n\n```typ\n#special-sequence[any Unicode character]\n#special-sequence[a Unicode scalar value]\n```\n\n## License\n\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnutthead%2Fnutthead-ebnf.typ","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnutthead%2Fnutthead-ebnf.typ","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnutthead%2Fnutthead-ebnf.typ/lists"}