{"id":20533067,"url":"https://github.com/refreezed/luacss","last_synced_at":"2026-05-05T01:35:02.280Z","repository":{"id":111111816,"uuid":"141059972","full_name":"ReFreezed/LuaCss","owner":"ReFreezed","description":"CSS tokenizing/minimizing library for Lua.","archived":false,"fork":false,"pushed_at":"2018-08-15T17:28:10.000Z","size":194,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-03-06T02:50:01.760Z","etag":null,"topics":["css","css-minification","css-parsing","lua","minify","pure-lua","tokenizer"],"latest_commit_sha":null,"homepage":null,"language":"Lua","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/ReFreezed.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","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":"2018-07-15T21:34:10.000Z","updated_at":"2020-04-07T22:00:21.000Z","dependencies_parsed_at":"2023-04-20T17:02:05.100Z","dependency_job_id":null,"html_url":"https://github.com/ReFreezed/LuaCss","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/ReFreezed/LuaCss","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ReFreezed%2FLuaCss","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ReFreezed%2FLuaCss/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ReFreezed%2FLuaCss/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ReFreezed%2FLuaCss/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ReFreezed","download_url":"https://codeload.github.com/ReFreezed/LuaCss/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ReFreezed%2FLuaCss/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32632287,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-04T10:08:07.713Z","status":"ssl_error","status_checked_at":"2026-05-04T10:08:02.005Z","response_time":58,"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":["css","css-minification","css-parsing","lua","minify","pure-lua","tokenizer"],"created_at":"2024-11-16T00:18:32.596Z","updated_at":"2026-05-05T01:35:02.264Z","avatar_url":"https://github.com/ReFreezed.png","language":"Lua","funding_links":[],"categories":[],"sub_categories":[],"readme":"# LuaCss\n\n![version 1.0](https://img.shields.io/badge/version-1.0-green.svg)\n\nCSS tokenizing and minimizing library for Lua 5.1.\nNo external dependencies - only pure Lua.\nThe library tries to closely follow the [CSS3 specification](https://www.w3.org/TR/css-syntax-3/).\n\n- [Usage](#usage)\n- [API](#api)\n- [Options](#options)\n- [Token Format](#token-format)\n\t- [Token Types](#token-types)\n\n\n\n## Usage\n`css.lua` is the library. `utf8.lua` is used by the library. Those are the only files you need.\n\n```lua\nlocal css = [[\ndiv {\n\tcolor: blue;\n\t/* Blah. */\n\tbackground-color: #36B !important;\n}\n\n@media (min-width: 800px) {\n\t.box a:hover { text-decoration: underline; }\n}\n]]\n\nlocal cssLib = require(\"css\")\nlocal minimizedCss = cssLib.minimize(css)\n\n-- minimizedCss is:\n-- div{color:blue;background-color:#36B!important}@media(min-width:800px){.box a:hover{text-decoration:underline}}\n```\n\n\n\n## API\n\n\n### minimize\n`cssString = minimize( cssString [, options ] )`\u003cbr\u003e\n`tokens = minimize( tokens [, options ] )`\n\nMinimize a CSS string or a token array.\nIn the case of tokens, the original array is unchanged and a new array is returned.\nSee available [options](#options).\n\n\n### serialize\n`cssString = serialize( tokens [, options ] )`\n\nConvert a token array to CSS string.\nSee available [options](#options).\n\n\n### serializeAndMinimize\n`cssString = serializeAndMinimize( tokens [, options ] )`\n\nConvert a token array to minimized CSS string.\nSee available [options](#options).\n\n\n### tokenize\n`tokens = tokenize( cssString )`\n\nConvert a CSS string to tokens.\n\n```lua\nlocal tokens = cssLib.tokenize(css)\n\nfor i, token in ipairs(tokens) do\n\tprint(i, token.type, token.value, token.unit)\nend\n```\n\nNote that all instances of U+0000 (NULL) code points are converted to U+FFFD (replacement character) per the specification.\n\n\n### _VERSION\n`version = _VERSION`\n\nNot a function! Get the version of the library, i.e. `\"1.0.2\"`.\n\n\n\n## Options\n`options` is a table that can have any of these fields:\n\n### autoZero\nEnable automatic conversion of *zero* values (e.g. `0px` or `0%`) to become simply `0` during minification.\nThe default value is `true`.\n\n### strict\nTrigger an error if a `badString` or `badUrl` token is encountered during minification.\nOtherwise, the error message is only printed.\nThe default value is `false`.\n\n\n\n## Token Format\n```lua\ntoken = {\n\t-- Always present:\n\ttype           = tokenType,\n\n\t-- Present in some token types:\n\tvalue          = tokenValue,\n\tfrom           = unicodeRangeStart,\n\tidType         = hashTokenIdentifierType,\n\tnumberType     = numberType,\n\tquoteCharacter = stringQuoteCharacter,\n\trepresentation = originalNumberRepresentation,\n\tto             = unicodeRangeEnd,\n\tunit           = dimensionUnit,\n}\n```\n\n### Token Types\n\n| Type               | Value | Description |\n| ------------------ | ----- |------------ |\n| `\"atKeyword\"`      | The name, e.g. `\"media\"`. | `@whatever` |\n| `\"badString\"`      | nothing | Malformed string. |\n| `\"badUrl\"`         | nothing | Malformed `url()`. |\n| `\"cdo\"`\u003cbr\u003e`\"cdc\"` | nothing | Long ago people used to wrap embedded CSS code inside HTML comments, thus these tokens (`\"\u003c!--\"` and `\"--\u003e\"`, respectively). |\n| `\"colon\"`          | nothing | `:` |\n| `\"columnMatch\"`    | nothing | Token that exists to help with parsing: \u003ccode\u003e\u0026vert;\u0026vert;\u003c/code\u003e. |\n| `\"comma\"`          | nothing | `,` |\n| `\"comment\"`        | The contents of the comment. | `/* Blah. */`\u003cbr\u003eNote that comments starting with `!` are preserved during minification, e.g. `/*! Copyright info. */`. |\n| `\"dashMatch\"`      | nothing | \u003ccode\u003e\u0026vert;=\u003c/code\u003e |\n| `\"dimension\"`      | The number. | Numeric value with a unit.\u003cbr\u003eThis token has a `unit` field, e.g. with the value `\"px\"`.\u003cbr\u003eThis token also has the extra fields that the `number` type has. |\n| `\"function\"`       | The name of the function, e.g. `\"calc\"`. | An identifier followed by a `(`. |\n| `\"hash\"`           | The name, e.g. `\"commentBox\"` or `\"A0FF5C\"`. | Matches include ID selectors and color values.\u003cbr\u003eThis token also has an `idType` field with the value `\"id\"` or `\"unrestricted\"` (the latter *generally* meaning the value is a color starting with a number, e.g. `#2FBBAA`). |\n| `\"ident\"`          | The name, e.g. `\"div\"` or `\"font-size\"`. | Any isolated identifier. |\n| `\"includeMatch\"`   | nothing | `~=` |\n| `\"number\"`         | The number. | Plain numeric value.\u003cbr\u003eThis token also has a `numberType` and `representation` field. `numberType` can be either `\"integer\"` or `\"number\"`. |\n| `\"percentage\"`     | The number. | Numeric percentage value.\u003cbr\u003eThis token also has the extra fields that the `number` type has. |\n| `\"prefixMatch\"`    | nothing | `^=` |\n| `\"semicolon\"`      | nothing | `;` |\n| `\"string\"`         | The contents of the string. | This token also has a `quoteCharacter` field whose value is either `\"` (quote) or `'` (apostrophe).\u003cbr\u003eAlso see `badString`. |\n| `\"substringMatch\"` | nothing | `*=` |\n| `\"suffixMatch\"`    | nothing | `$=` |\n| `\"unicodeRange\"`   | nothing | Unicode ranges has a `from` and a `to` field with Unicode code points. |\n| `\"url\"`            | The URL. | This token also has a `quoteCharacter` field whose value is either `\"` (quote), `'` (apostrophe) or an empty string.\u003cbr\u003eAlso see `badUrl`. |\n| `\"whitespace\"`     | The contents of the whitespace sequence. | Whitespace characters are **space**, **horizontal tab** and **newline**. Note that all line endings are normalized into **newlines**. |\n| `\"(\"`, `\")\"`       | nothing | `(` and `)`, respectively. |\n| `\"[\"`, `\"]\"`       | nothing | `[` and `]`, respectively. |\n| `\"{\"`, `\"}\"`       | nothing | `{` and `}`, respectively. |\n| `\"delim\"`          | The delimiter. | Any other isolated punctuation character, e.g. `\".\"` or `\"+\"`. |\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frefreezed%2Fluacss","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frefreezed%2Fluacss","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frefreezed%2Fluacss/lists"}