{"id":26000036,"url":"https://github.com/Dherse/codly","last_synced_at":"2025-03-05T18:42:50.186Z","repository":{"id":205453570,"uuid":"714276112","full_name":"Dherse/codly","owner":"Dherse","description":"A Typst package for even better code blocks","archived":false,"fork":false,"pushed_at":"2025-02-27T12:46:55.000Z","size":32629,"stargazers_count":175,"open_issues_count":7,"forks_count":17,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-03-01T23:54:40.967Z","etag":null,"topics":["code","highlight","highlighting","typst","typst-package"],"latest_commit_sha":null,"homepage":"https://typst.app/universe/package/codly","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/Dherse.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}},"created_at":"2023-11-04T12:43:17.000Z","updated_at":"2025-03-01T20:47:05.000Z","dependencies_parsed_at":"2024-10-28T20:41:08.187Z","dependency_job_id":"0f900c9e-2114-4758-8043-5220d618239b","html_url":"https://github.com/Dherse/codly","commit_stats":null,"previous_names":["dherse/codly"],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Dherse%2Fcodly","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Dherse%2Fcodly/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Dherse%2Fcodly/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Dherse%2Fcodly/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Dherse","download_url":"https://codeload.github.com/Dherse/codly/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":242083345,"owners_count":20069271,"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":["code","highlight","highlighting","typst","typst-package"],"created_at":"2025-03-05T18:40:53.293Z","updated_at":"2025-03-05T18:42:50.176Z","avatar_url":"https://github.com/Dherse.png","language":"Typst","funding_links":[],"categories":["Typst"],"sub_categories":[],"readme":"# Codly: simple yet beautiful and powerful code blocks\n\n\u003cp align=\"center\"\u003e\n  \u003ca href=\"https://github.com/Dherse/codly/blob/main/docs.pdf\"\u003e\n    \u003cimg alt=\"Documentation\" src=\"https://img.shields.io/website?down_message=offline\u0026label=manual\u0026up_color=007aff\u0026up_message=online\u0026url=https%3A%2F%2Fgithub.com%2FDherse%2Fcodly%2Fblob%2Fmain%2Fdocs.pdf\" /\u003e\n  \u003c/a\u003e\n  \u003ca href=\"https://github.com/Dherse/codly/blob/main/LICENSE\"\u003e\n    \u003cimg alt=\"MIT License\" src=\"https://img.shields.io/badge/license-MIT-brightgreen\"\u003e\n  \u003c/a\u003e\n  \u003cimg src=\"https://github.com/Dherse/codly/actions/workflows/test.yml/badge.svg\" /\u003e\n\u003c/p\u003e\n\nCodly superchargescode blocks for your Typst documents. It allows you to add annotations, skip lines, customize numberings, add language icons, and much more. Codly is even better with its companion package [`codly-languages`](https://typst.app/universe/package/codly-languages) which provides a wide range of language icons and colors to choose from.\n\nA full set of documentation can be found [in the repo](https://raw.githubusercontent.com/Dherse/codly/main/docs.pdf).\n\n![Example](./assets/demo.png)\n\n````typ\n#import \"@preview/codly:1.3.0\": *\n#import \"@preview/codly-languages:0.1.1\": *\n#show: codly-init.with()\n\n#codly(languages: codly-languages)\n```rust\npub fn main() {\n    println!(\"Hello, world!\");\n}\n```\n````\n\n### Setup\n\nTo start using codly, you need to initialize codly using a show rule, this need only be done once per document:\n\n```typ\n#show: codly-init.with()\n```\n\nThen you *can* configure codly with your parameters:\n\n```typ\n#codly(\n  languages: (\n    rust: (name: \"Rust\", icon: \"🦀\", color: rgb(\"#CE412B\")),\n  )\n)\n```\n\n---\n**Note**: Any parameter that you leave blank will use the previous values (or the default value if never set) similar to a `set` rule in regular typst. But the changes are always global unless you use the provided `codly.local` function. To get a full list of all settings, see the [documentation](https://raw.githubusercontent.com/Dherse/codly/main/docs.pdf).\n\n---\n\nThen you just need to add a code block and it will be automatically displayed correctly:\n\n````\n```rust\npub fn main() {\n    println!(\"Hello, world!\");\n}\n```\n````\n\n![Crab](./assets/crab.png)\n\n### Disabling \u0026 Enabling\n\nTo locally disable codly, you can just do the following, you can then later re-enable it using the `codly` configuration function.\n\n```typ\n#codly-disable()\n```\n\n![codly-disable](./assets/codly-disable.png)\n\nAlternatively, you can use the `no-codly` function to achieve the same effect locally:\n\n````typ\n#no-codly[\n  ```typ\n  I will be displayed using the normal raw blocks.\n  ```\n]\n````\n\n### Smart indentation\n\nBy default Codly ships with `smart-indent` enabled, this means that Codly will automatically detect the indentation of your code block and adjust the horizontal offset on line wrapping accordingly. This can be disabled using the `smart-indent` parameter.\n\n```typ\n#codly(smart-indent: false)\n```\n\n![smart-ident](./assets/smart-indent.png)\n\n### Referencing code blocks\n\nCodly offers a wide range of features for referencing code blocks, lines, highlights, and annotations. This is done using:\n- the line shorthand `@\u003clabel\u003e:\u003cline\u003e`\n- the highlight or annotation label `@\u003chighlight\u003e`\n\n![line-ref](./assets/line-ref.png)\n\n![highlight-ref](./assets/highlight-ref.png)\n\n### Setting an offset\n\nIf you wish to add an offset to your code block, but without selecting a subset of lines, you can use the `codly-offset` function:\n\n```typ\n// Sets a 5 line offset\n#codly-offset(5)\n```\n\n![codly-offset](./assets/codly-offset.png)\n\n### Setting an offset relative to another code block\n\nThis is done by using the `offset-from` argument and by specifying a Typst `label` to the \"parent\" code block:\n\n````typ\n#codly(offset-from: \u003cparent\u003e)\n````\n\n![offset-from](./assets/offset-from.png)\n\n### Selecting a subset of lines\n\nIf you wish to select a subset of lines, you can use the `codly-range` function. By setting the start to 1 and the end to `none` you can select all lines from the start to the end of the code block.\n\n```typ\n#codly-range(start: 5, end: 10)\n```\n\n![codly-range](./assets/codly-range.png)\n\n### Adding a \"skip\"\n\nYou can add a \"fake\" skip between lines using the `skips` parameters:\n\n```typ\n// Before the 5th line (indexing start at 0), insert a 32 line jump.\n#codly(skips: ((5, 32), ))\n```\nThe code inside your block will be the same (except for the added line containing the … character), but the line numbers will be adjusted to reflect the skip. \n\nThis can be customized using the `skip-line` and `skip-number` to customize what it looks like.\n\n### Adding highlights\n\nYou can highlight part of lines using the `highlights` parameters:\n\n````typ\n#codly(highlights: (\n  (line: 4, start: 2, end: none, fill: red),\n  (line: 5, start: 13, end: 19, fill: green, tag: \"(a)\"),\n  (line: 5, start: 26, fill: blue, tag: \"(b)\"),\n))\n```py\ndef fib(n):\n  if n \u003c= 1:\n    return n\n  else:\n    return fib(n - 1) + fib(n - 2)\nprint(fib(25))\n```\n````\n\n![highlights](./assets/highlights.png)\n\n### Adding annotations\n\nYou can annotate a line/group of lines using the `annotations` parameters :\n\n```typ\n// Add an annotation from the second line (0 indexing) to the 5th line included.\n#codly(\n  annotations: (\n    (\n      start: 2,\n      end: 4,\n      content: block(\n        width: 2em,\n        // Rotate the element to make it look nice\n        rotate(\n          -90deg,\n          align(center, box(width: 100pt)[Function body])\n        )\n      )\n    ), \n  )\n)\n```\n\n![annotations](./assets/annotations.png)\n\n### Disabling line numbers\n\nYou can configure this with the `codly` function:\n\n```typ\n#codly(number-format: none)\n```\n\n### Disabling zebra striping\n\nYou disable zebra striping by setting the `zebra-fill` to white or none.\n\n```typ\n#codly(zebra-fill: none)\n```\n\n### Customize the stroke\n\nYou can customize the stroke surrounding the figure using the `stroke` parameter of the `codly` function:\n\n```typ\n#codly(stroke: 1pt + red)\n```\n\n### Misc\n\nYou can also disable the icon by setting the `display-icon` parameter to `false`:\n\n```typ\n#codly(display-icon: false)\n```\n\nThis applies to:\n- the name\n- the radius\n- whether the block is breakable\n- the padding\n- the width of the numbers columns \n\nand so many more.\n\nFor more detailed information check out the [documentation](https://raw.githubusercontent.com/Dherse/codly/main/docs.pdf).","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FDherse%2Fcodly","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FDherse%2Fcodly","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FDherse%2Fcodly/lists"}