{"id":23038447,"url":"https://github.com/tdjsnelling/microtype","last_synced_at":"2025-10-25T18:35:21.277Z","repository":{"id":245148736,"uuid":"774889442","full_name":"tdjsnelling/microtype","owner":"tdjsnelling","description":"A JavaScript package that implements LaTeX-like text justification, hyphenation, and other micro-typographic adjustments","archived":false,"fork":false,"pushed_at":"2024-06-19T16:34:22.000Z","size":230,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2024-11-15T10:30:42.618Z","etag":null,"topics":["html","javascript","justification","latex","microtype","microtypography","typescript","typography"],"latest_commit_sha":null,"homepage":"","language":"HTML","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/tdjsnelling.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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":"2024-03-20T11:35:06.000Z","updated_at":"2024-06-19T16:34:25.000Z","dependencies_parsed_at":"2024-06-20T04:44:57.220Z","dependency_job_id":"3f9d6ca3-2bb2-4469-9c5f-763c6f6aa16e","html_url":"https://github.com/tdjsnelling/microtype","commit_stats":null,"previous_names":["tdjsnelling/microtype"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tdjsnelling%2Fmicrotype","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tdjsnelling%2Fmicrotype/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tdjsnelling%2Fmicrotype/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tdjsnelling%2Fmicrotype/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tdjsnelling","download_url":"https://codeload.github.com/tdjsnelling/microtype/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":229856355,"owners_count":18134872,"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":["html","javascript","justification","latex","microtype","microtypography","typescript","typography"],"created_at":"2024-12-15T18:18:51.500Z","updated_at":"2025-10-25T18:35:16.258Z","avatar_url":"https://github.com/tdjsnelling.png","language":"HTML","funding_links":[],"categories":[],"sub_categories":[],"readme":"# microtype\n\nA JavaScript package that implements LaTeX-like text justification, hyphenation, and other micro-typographic adjustments. The name of course is borrowed from the [microtype LaTeX package](https://eu.mirrors.cicku.me/ctan/macros/latex/contrib/microtype/microtype.pdf).\n\n## Usage\n\nThe package can be installed via npm, and imported as an ES module:\n\n```\nnpm install microtypejs\n```\n\n```js\nimport microtype from \"microtypejs\";\n```\n\nOr loaded directly via a CDN:\n\n```html\n\u003cscript src=\"https://unpkg.com/microtypejs/dist/microtype.js\"\u003e\u003c/script\u003e\n```\n\nOnce the package is loaded, the most basic usage is just to call the `microtype` function with an array of elements you want to format.\n\nAt present, the elements you want to format **must contain nothing but text**. Paragraphs containing inline elements are not supported. This is something I want to improve in the future.\n\n```js\nmicrotype({\n  elements: document.querySelectorAll(\"p\")\n});\n```\n\nMore on other configuration options below.\n\n## Options\n\nThe full list of available options and their defaults are as follows:\n\n```ts\ntype MicrotypeOptions = {\n  elements: HTMLElement[];\n  maxSpaceShrink: number;\n  maxSpaceGrow: number;\n  maxTrackingShrink: number;\n  maxTrackingGrow: number;\n  protrusion: { [key: string]: number };\n  hyphenate: boolean;\n  showFrame: boolean;\n};\n\nconst defaultOptions: MicrotypeOptions = {\n  elements: [], // The array of elements to format\n  maxSpaceShrink: 0.15, // How much space characters can shrink (em)\n  maxSpaceGrow: 0.25, // How much space characters can grow (em)\n  maxTrackingShrink: 0.01, // How much letter spacing can shrink (em)\n  maxTrackingGrow: 0.01, // How much letter spacing can grow (em)\n  protrusion: {\n    // How much certain characters may protrude from the right margin (em)\n    \",\": 0.1,\n    \".\": 0.15,\n    \"!\": 0.1,\n    \"-\": 0.2,\n  },\n  hyphenate: true, // Whether or not words may hyphenate across lines\n  showFrame: false, // Whether or not to show the target frame for formatted elements (for debugging)\n};\n```\n\n## Demo\n\nVisit [tdjsnelling.github.io/microtype](https://tdjsnelling.github.io/microtype/test/from-cdn/) for a live demo.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftdjsnelling%2Fmicrotype","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftdjsnelling%2Fmicrotype","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftdjsnelling%2Fmicrotype/lists"}