{"id":"lupapi/chalk","name":"chalk","scope":"lupapi","platform":"roblox","description":"Rich Text string styling done right | https://github.com/Perthys/chalk ","version":"1.0.4","latest":"1.0.4","versions":["1.0.4"],"license":"MIT","licenseRating":"safe","licenseCaveats":[],"licenseVerified":true,"dependencies":{},"integrity":"45a994dca3a5a6aad9d52620cd5b28dff3ec4fb2af27c1e060c0e491f7a72b33","likes":0,"downloads":0,"install":"forest install lupapi/chalk","url":"https://forest.dev/p/roblox/lupapi/chalk","files":"https://api.forest.dev/ai/package/roblox/lupapi/chalk/files","readme":"<h1 align=\"center\">\r\n\t<br>\r\n\t<br>\r\n\t<img width=\"320\" src=\"media/logo.svg\" alt=\"Chalk\">\r\n\t<br>\r\n\t<br>\r\n\t<br>\r\n</h1>\r\n\r\n<h1 align=\"center\">\r\n    🖍 Rich Text styling done right\r\n    <br>\r\n\t<br>\r\n\t<img width=\"578\" src=\"media/screenshot.png\" alt=\"Chalk\">\r\n\t<br>\r\n    <br>\r\n</h1>\r\n\r\n## Guide\r\n>[Highlights](#Highlights) <br>\r\n>[Install](#Install) <br>\r\n>[Usage](#Usage) <br>\r\n>[API](#API) <br>\r\n>[Styles](#Styles) <br>\r\n>[Comments](#Comments) <br>\r\n>[Maintainers](#Maintainers) <br>\r\n\r\n## Highlights\r\n- Expressive API\r\n- Highly performant\r\n- No dependencies\r\n- Ability to nest styles\r\n- Auto-detects color support\r\n- Clean and focused\r\n- Actively maintained\r\n- Extremely Lightweight (less than ~270 lines)\r\n- Proper Typing for AutoFill\r\n\r\n## Install\r\n\r\n```lua\r\n-- Run in Roblox Studio Console\r\nlocal HttpService = game:GetService(\"HttpService\"); \r\nlocal ReplicatedStorage = game:GetService(\"ReplicatedStorage\");\r\nlocal LastValue = HttpService.HttpEnabled\r\n\r\nHttpService.HttpEnabled = true\r\n\r\nlocal ChalkModule = Instance.new(\"ModuleScript\");\r\nChalkModule.Name = \"Chalk\";\r\nChalkModule.Parent = ReplicatedStorage;\r\n\r\nlocal Request = HttpService:RequestAsync({\r\n    Url = \"https://raw.githubusercontent.com/Perthys/chalk/main/source/main.lua\";\r\n    Method = \"GET\";\r\n});\r\n\r\nHttpService.HttpEnabled = LastValue\r\n\r\nif Request.Success and Request.StatusCode == 200 then\r\n    ChalkModule.Source = Request.Body\r\n\r\n    print(\"Successfully installed Chalk module. At:\", ChalkModule);\r\nelse\r\n    error(\"Failed to install Chalk module.\");\r\nend\r\n```\r\n\r\n## Usage\r\n\r\n**Blue Text Example**\r\n> Chalk has a very simple but powerful API \r\n\r\n```lua\r\nlocal ReplicatedStorage = game:GetService(\"ReplicatedStorage\");\r\nlocal Chalk = require(ReplicatedStorage:WaitForChild(\"Chalk\"));\r\n\r\nlocal TextBox = script.Parent;\r\n\r\nTextBox.Text = Chalk.blue('Hello world!')\r\n```\r\n<h1 align=\"left\">\r\n\t<img width=\"500\" src=\"media/Example1.png\" alt=\"Chalk\">\r\n</h1>\r\n\r\n**Multi String Example**\r\n> Chalk comes with an easy to use composable API where you just chain and nest the styles you want.\r\n\r\n```lua\r\nlocal ReplicatedStorage = game:GetService(\"ReplicatedStorage\");\r\nlocal Chalk = require(ReplicatedStorage:WaitForChild(\"Chalk\"));\r\n\r\nlocal TextBox = script.Parent; TextBox.RichText = true;\r\n\r\nlocal function Update(String) TextBox.Text = String; task.wait(1); end\r\n\r\nUpdate(Chalk.blue(\"Hello\") .. 'World' .. Chalk.red(\"!\"))\r\nUpdate(Chalk.blue.bold(\"Hello world!\"))\r\nUpdate(Chalk.blue(\"Hello\", \"World!\", \"Foo\", \"bar\", \"biz\", \"baz\"))\r\nUpdate(Chalk.red(\"Hello\", Chalk.underline(\"world\") .. \"!\"))\r\nUpdate(Chalk.green(\"I am a green line \" .. Chalk.blue.underline.bold(\"with a blue substring\") .. \" that becomes green again!\"))\r\n\r\nUpdate((\"CPU: %s \\nRAM: %s \\nDISK: %s\"):format(Chalk.red(\"90%\"), Chalk.green(\"40%\"), Chalk.yellow(\"70%\")))\r\n\r\nUpdate(Chalk.color(123, 45, 67).underline(\"Underlined reddish color\"))\r\nUpdate(Chalk.color(\"#DEADED\").bold(\"Bold gray!\"))\r\n```\r\n<h1 align=\"left\">\r\n\t<img width=\"500\" src=\"media/Example2.gif\" alt=\"Chalk\">\r\n</h1>\r\n\r\n**Theme Creation**\r\n> Easily define your own themes\r\n\r\n```lua\r\nlocal ReplicatedStorage = game:GetService(\"ReplicatedStorage\");\r\nlocal Chalk = require(ReplicatedStorage:WaitForChild(\"Chalk\"));\r\n\r\nlocal TextBox = script.Parent; TextBox.RichText = true;\r\n\r\nlocal error = Chalk.bold.red;\r\nlocal warning = Chalk.color(\"#FFA500\");\r\n\r\nlocal function Update(String) TextBox.Text = String; task.wait(1); end\r\n\r\nUpdate(error(\"Error!\")) \r\nUpdate(warning(\"Warning!\"));\r\n```\r\n<h1 align=\"left\">\r\n\t<img width=\"500\" src=\"media/Example3.gif\" alt=\"Chalk\">\r\n</h1>\r\n\r\n\r\nTake advantage of string substitution:\r\n\r\n```lua\r\nlocal ReplicatedStorage = game:GetService(\"ReplicatedStorage\");\r\nlocal Chalk = require(ReplicatedStorage:WaitForChild(\"Chalk\"));\r\n\r\nlocal TextBox = script.Parent; TextBox.RichText = true;\r\n\r\nlocal function Update(String) TextBox.Text = String; task.wait(1); end\r\n\r\nlocal Name = \"Builderman\";\r\nUpdate(Chalk.green((\"Hello %s\"):format(Name)))\r\n```\r\n<h1 align=\"left\">\r\n\t<img width=\"500\" src=\"media/Example4.png\" alt=\"Chalk\">\r\n</h1>\r\n\r\n## API\r\n\r\n### Chalk Syntax and Typing\r\n\r\n**Example:**\r\n```lua\r\nchalk[ ArgumentStyle ] -> (...: StyleArgs) -> chalk(...: string)\r\nchalk.size(40)(\"test\");\r\n\r\nchalk[ ModifierStyle ] -> chalk(...: string)\r\nchalk.bold(\"test\");\r\n\r\nchalk[ ArgumentStyle ] -> (...: StyleArgs) -> chalk[ ArgumentStyle ] -> (...) -> chalk(...: string)\r\nchalk.size(40).color(40,20,30)(\"test\");\r\n\r\nchalk[ ArgumentStyle ] -> (...: StyleArgs) -> chalk[ ModifierStyle ] -> chalk(...: string)\r\nchalk.size(40).bold(\"test\");\r\n\r\nchalk[ ModifierStyle ] -> chalk[ ModifierStyle ] -> chalk(...: string)\r\nchalk.red.bold(\"test\");\r\n\r\nchalk[ ModifierStyle ] -> chalk[ ArgumentStyle ] -> (...: StyleArgs) -> chalk(...: string)\r\nchalk.red.size(40)(\"test\");\r\n```\r\n\r\nChain [styles](#styles) calls the last Style as a method with a string argument.<br />\r\nOrder doesn't matter, and earlier Styles take priority in case of a conflict.<br /> \r\nThis simply means that `chalk.red.yellow.green` is equivalent to `chalk.red`.\r\n\r\n## Styles\r\n\r\n### Modifier Styles\r\n- `Chalk.bold` - Make the text bold\r\n- `Chalk.italic` - Make the text italic\r\n- `Chalk.underline` - Underline the text\r\n- `Chalk.strikethrough` - Strike through the text\r\n- `Chalk.uppercase` - Convert text to uppercase\r\n- `Chalk.smallcaps` - Convert text to small capitals\r\n\r\n### Argument Modifier Style\r\n- `Chalk.color(Hex) | Chalk.color(R, G, B) | Chalk.color(Color3.new())` - Set the color\r\n- `Chalk.size([<Size>])` - Set the size of the text (Number)\r\n- `Chalk.face([<Face>])` - Set the typeface of the text (String)\r\n- `Chalk.family([<rbxasset://>])` - Set the font family from an asset (String)\r\n- `Chalk.weight([<Weight>])` - Set the font weight (String)\r\n- `Chalk.transparency([<Transparency>])` - Set the transparency of the text (Number 0-1)\r\n- `Chalk.stroke({Color = [<Color>], Joins = [<Joins>], Thickness = [<Thickness>], Transparency = [<Transparency>]})` - Define stroke properties: color (Color3), joins (String), thickness (Number), and transparency (Number)\r\n\r\n```lua\r\nChalk.stroke({\r\n    Color = [<Color>], \r\n    Joins = [<Joins>], \r\n    Thickness = [<Thickness>], \r\n    Transparency = [<Transparency>]\r\n})\r\n``` \r\n\r\n### Example Game\r\n[`ExampleGame`](https://github.com/Perthys/chalk/raw/main/ExampleGame.rbxl)\r\n\r\n\r\n### Colors\r\n\r\n- `Chalk[<BrickColorName>]` - Set the color to a BrickColor [`Colors`](https://create.roblox.com/docs/reference/engine/datatypes/BrickColor#r)\r\n- `Chalk.white` - Set the color to white\r\n- `Chalk.black` - Set the color to black\r\n- `Chalk.red` - Set the color to red\r\n- `Chalk.brown` - Set the color to brown\r\n- `Chalk.orange` - Set the color to orange\r\n- `Chalk.yellow` - Set the color to yellow\r\n- `Chalk.lime` - Set the color to lime\r\n- `Chalk.green` - Set the color to green\r\n- `Chalk.blue` - Set the color to blue\r\n- `Chalk.purple` - Set the color to purple\r\n- `Chalk.pink` - Set the color to pink\r\n  \r\n## Color3, 256 RGB, Hex and BrickColor support\r\n\r\nChalk supports Color3, 256 RGB, Hex and BrickColor.\r\n\r\nExamples:\r\n\r\n- `Chalk.color('#DEADED').underline('Hello, world!')`\r\n- `Chalk.color(15, 100, 204)`\r\n- `Chalk.color(Color3.fromRGB(100, 255, 255))`\r\n- `Chalk.nougat`\r\n\r\nThe following color models can be used:\r\n\r\n- [`rgb`](https://en.wikipedia.org/wiki/RGB_color_model) - Example: `chalk.color(255, 136, 0).bold('Orange!')`\r\n- [`hex`](https://en.wikipedia.org/wiki/Web_colors#Hex_triplet) - Example: `chalk.color('#FF8800').bold('Orange!')`\r\n- [`Color3`](https://create.roblox.com/docs/reference/engine/datatypes/Color3) - Example: `chalk.color(Color3.fromRGB(255, 136, 0)).bold(\"Orange\")`\r\n- [`BrickColor`](https://create.roblox.com/docs/reference/engine/datatypes/BrickColor) - Example `chalk[\"Earth orange\"]`\r\n\r\n\r\n## Origin story\r\nI wanted to make the [`npm package`](https://www.npmjs.com/package/chalk) [`chalk`](https://github.com/chalk/chalk) for roblox luau [`richtext`](https://create.roblox.com/docs/ui/rich-text) because I *really* did not want to do styling manually.\r\n\r\n## Comments\r\n- ROBLOX PLEASE ENABLE RICH TEXT TO CONSOLE TEXT OBJECTS, you can make a interface with LogService so print/warn/error can still output raw text.\r\n- If roblox adds support for background text color directly with richtext I will also add support.\r\n- If you have any issues or suggestions best way to contact me would be through discord `Perthys#0`.\r\n\r\n## Maintainers\r\n\r\n- [Perth](https://github.com/Perthys) | `Perthys#0`\r\n","readmeTruncated":false}