{"id":13523401,"url":"https://github.com/actsasflinn/typst-rb","last_synced_at":"2025-04-01T00:31:42.454Z","repository":{"id":208940120,"uuid":"722832140","full_name":"actsasflinn/typst-rb","owner":"actsasflinn","description":"Ruby binding to typst, a new markup-based typesetting system that is powerful and easy to learn.","archived":false,"fork":false,"pushed_at":"2024-04-09T00:09:35.000Z","size":5159,"stargazers_count":5,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-08-09T13:44:29.832Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/actsasflinn.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}},"created_at":"2023-11-24T04:00:09.000Z","updated_at":"2024-07-09T01:07:17.000Z","dependencies_parsed_at":"2024-01-13T22:25:28.085Z","dependency_job_id":"bf2e37b3-5536-41d7-89ca-f52a2e7190e4","html_url":"https://github.com/actsasflinn/typst-rb","commit_stats":null,"previous_names":["actsasflinn/typst-rb"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/actsasflinn%2Ftypst-rb","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/actsasflinn%2Ftypst-rb/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/actsasflinn%2Ftypst-rb/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/actsasflinn%2Ftypst-rb/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/actsasflinn","download_url":"https://codeload.github.com/actsasflinn/typst-rb/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":222688173,"owners_count":17023297,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":[],"created_at":"2024-08-01T06:00:59.720Z","updated_at":"2025-04-01T00:31:42.446Z","avatar_url":"https://github.com/actsasflinn.png","language":"Rust","funding_links":[],"categories":["Integrations \u0026 Tools"],"sub_categories":["Programming"],"readme":"# typst-rb\n\nRuby binding to [typst](https://github.com/typst/typst),\na new markup-based typesetting system that is powerful and easy to learn.\n\n## Installation\n\n```bash\ngem install typst\n```\n\n## Usage\n\n```ruby\nrequire \"typst\"\n\n# Compile `readme.typ` to PDF and save as `readme.pdf`\nTypst::Pdf.new(\"readme.typ\").write(\"readme.pdf\")\n\n# Or return PDF content as an array of bytes\npdf_bytes = Typst::Pdf.new(\"readme.typ\").bytes\n# =\u003e [37, 80, 68, 70, 45, 49, 46, 55, 10, 37, 128 ...] \n\n# Or return PDF content as a string of bytes\ndocument = Typst::Pdf.new(\"readme.typ\").document\n# =\u003e \"%PDF-1.7\\n%\\x80\\x80\\x80\\x80\\n\\n4 0 obj\\n\u003c\u003c\\n  /Type /Font\\n  /Subtype ...\" \n\n# Compile `readme.typ` to SVG and save as `readme_0.svg`, `readme_1.svg`\nTypst::Svg.new(\"readme.typ\").write(\"readme.svg\")\n\n# Or return SVG content as an array of pages\npages = Typst::Svg.new(\"readme.typ\").pages\n# =\u003e [\"\u003csvg class=\\\"typst-doc\\\" viewBox=\\\"0 0 595.2764999999999 841.89105\\\" ...\"\n\n# Compile `readme.typ` to PNG and save as `readme_0.png`, `readme_1.png`\nTypst::Png.new(\"readme.typ\").write(\"readme.png\")\n\n# Or return PNG content as an array of pages\npages = Typst::Png.new(\"readme.typ\").pages\n# =\u003e [\"\\x89PNG\\r\\n\\x1A\\n\\x00\\x00\\x00\\rIHDR\\x00\\x00\\x04\\xA7\\x00\\x00\\x06\\x94\\b\\ ...\n\n# Compile `readme.typ` to SVG and save as `readme.html`\nTypst::Html.new(\"readme.typ\", title: \"README\").write(\"readme.html\")\n\n# Or return HTML content\nmarkup = Typst::Html.new(\"readme.typ\", title: \"README\").document\n# =\u003e \"\\n\u003c!DOCTYPE html\u003e\\n\u003chtml\u003e\\n\u003chead\u003e\\n\u003ctitle\u003eREADME\u003c/title\u003e\\n\u003c/head\u003e\\n\u003cbo...\"\n\n# Use native Typst experimental HTML feature to write single frame HTML file\nTypst::HtmlExperimental.new(\"readme.typ\").write(\"readme.html\")\n\n# Or return single frame HTML content (using native Typst experimental HTML feature)\nmarkup = Typst::HtmlExperimental.new(\"readme.typ\").document\n# =\u003e \"\u003c!DOCTYPE html\u003e\\n\u003chtml\u003e\\n  \u003chead\u003e\\n    \u003cmeta charset=\\\"utf-8\\\"\u003e\\n...\"\n\n# Compile from a string to PDF\nt = Typst::Pdf.from_s(%{hello world})\n\n# Compile from a string to SVG\nt = Typst::Svg.from_s(%{hello world})\n\n# Compile from a string to PNG\nt = Typst::Png.from_s(%{hello world})\n\n# Compile from a string to SVG multi-frame/pages wrapped in HTML (non-native Typst)\nt = Typst::Html.from_s(%{hello world})\n\n# Compile from a string to single frame HTML (native Typst experimental feature)\nt = Typst::HtmlExperimental.from_s(%{hello world})\n\n# A more complex example of compiling from string\nmain = %{\n#import \"template.typ\": *\n\n#show: template.with()\n\n#lorem(50)\n\n#image(\"icon.svg\")\n}\n\ntemplate = %{\n#let template(body) = {\n  set text(12pt, font: \"Example\")\n  body\n}\n}\n\nicon = File.read(\"icon.svg\")\nfont_bytes = File.read(\"Example.ttf\")\n\nt = Typst::Pdf.from_s(main, dependencies: { \"template.typ\" =\u003e template, \"icon.svg\" =\u003e icon }, fonts: { \"Example.ttf\" =\u003e font_bytes })\n\n# From a zip file that includes a main.typ\n# zip file include flat dependencies included and a fonts directory\nTypst::Pdf::from_zip(\"working_directory.zip\")\n\n# From a zip with a named main typst file\nTypst::Pdf::from_zip(\"working_directory.zip\", \"hello.typ\")\n\nTypst::Query.new(\"heading\", \"readme.typ\").result\n# =\u003e \n# [{\"func\" =\u003e \"heading\",\n#   \"level\" =\u003e 1,\n#   \"depth\" =\u003e 1,\n# ...\n\nTypst::Query.new(\"heading\", \"readme.typ\", format: \"json\").result(raw: true)\n# =\u003e \"[\\n  {\\n    \\\"func\\\": \\\"heading\\\",\\n    \\\"level\\\": 1,\\n    \\\"depth\\\": ...\"\n\nTypst::Query.new(\"heading\", \"readme.typ\", format: \"yaml\").result(raw: true)\n# =\u003e \"- func: heading\\n  level: 1\\n  depth: 1\\n  offset: 0\\n  numbering: ...\"\n\n```\n\n## Contributors \u0026 Acknowledgements\ntypst-rb is based on [typst-py](https://github.com/messense/typst-py) by [messense](https://github.com/messense)\n\n## License\n\nThis work is released under the Apache-2.0 license. A copy of the license is provided in the [LICENSE](./LICENSE) file.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Factsasflinn%2Ftypst-rb","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Factsasflinn%2Ftypst-rb","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Factsasflinn%2Ftypst-rb/lists"}