{"id":20119148,"url":"https://github.com/abridoux/lux","last_synced_at":"2025-05-06T14:32:11.714Z","repository":{"id":54149237,"uuid":"254610171","full_name":"ABridoux/lux","owner":"ABridoux","description":"A Swift library with a dedicated command-line tool to highlight plain code (e.g. for terminal output), HTML files code blocks or attributed strings (e.g. for macOS or iOS apps)","archived":false,"fork":false,"pushed_at":"2021-03-07T18:15:56.000Z","size":7090,"stargazers_count":29,"open_issues_count":7,"forks_count":2,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-04-27T19:47:43.588Z","etag":null,"topics":["color","command-line-tool","swift-package"],"latest_commit_sha":null,"homepage":"","language":"Swift","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/ABridoux.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"License","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-04-10T10:43:53.000Z","updated_at":"2025-04-22T21:18:16.000Z","dependencies_parsed_at":"2022-08-13T07:40:23.981Z","dependency_job_id":null,"html_url":"https://github.com/ABridoux/lux","commit_stats":null,"previous_names":[],"tags_count":17,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ABridoux%2Flux","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ABridoux%2Flux/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ABridoux%2Flux/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ABridoux%2Flux/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ABridoux","download_url":"https://codeload.github.com/ABridoux/lux/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252703453,"owners_count":21790887,"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":["color","command-line-tool","swift-package"],"created_at":"2024-11-13T19:14:36.695Z","updated_at":"2025-05-06T14:32:11.151Z","avatar_url":"https://github.com/ABridoux.png","language":"Swift","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cp  align=\"center\"\u003e\n\u003cimg src=\"Resources/Lux.png\" /\u003e\nSwift package\u003cbr\u003e\n    \u003ca href=\"#\"\u003e\n        \u003cimg src=\"https://img.shields.io/badge/Swift-5.1-orange.svg\" /\u003e\n    \u003c/a\u003e\n    \u003ca href=\"https://swift.org/package-manager\"\u003e\n        \u003cimg src=\"https://img.shields.io/badge/swiftpm-compatible-brightgreen.svg?style=flat\" alt=\"Swift Package Manager\" /\u003e\n    \u003c/a\u003e\n    \u003cbr/\u003e\u003cbr/\u003e\nInstall\u003cbr/\u003e\n    \u003ca href=\"#\"\u003e\n        \u003cimg src=\"https://img.shields.io/badge/platforms-mac+linux-brightgreen.svg?style=flat\" alt=\"Mac + Linux\" /\u003e\n    \u003c/a\u003e\n     \u003ca href=\"https://github.com/ABridoux/scout/releases\"\u003e\n        \u003cimg src=\"https://img.shields.io/badge/install-pkg%2Bzip-blue\" /\u003e\n    \u003c/a\u003e\n    \u003cbr/\u003e\n\u003c/p\u003e\n\n# Lux \u003ca href=\"https://github.com/ABridoux/scout/releases\" style=\"vertical-align: center\"\u003e\u003cimg src=\"https://img.shields.io/github/v/release/Abridoux/lux?color=lightgrey\u0026label=latest\" /\u003e\u003c/a\u003e\n\nA Swift library with a dedicated command-line tool to colorise plain code (e.g. for terminal output), HTML files code blocks or attributed strings (e.g. for macOS or iOS apps).\n\nCurrently supported languages:\n- [x] Zsh/Bash\n- [x] Swift (with [Splash](https://github.com/JohnSundell/Splash))\n- [x] Xml\n- [x] Xml enhanced (better visualisation of the tags)\n- [x] Plist\n- [x] Json\n- [x] Yaml\n\nCurrently offered themes:\n- [x] Dracula\n- [x] Xcode light (default)\n- [x] Xcode dark\n\nThemes to be added:\n- [] Obsidian\n- [] Tomorrow\n\nYou can ask for a language support or a theme by [opening an issue](https://github.com/ABridoux/lux/issues). You can also [implement a language](https://github.com/ABridoux/lux/wiki/%5B30%5D-Add-a-new-language) support if you prefer.\nThe following screenshots show the different usages of **Lux**.\n\n\u003cp align=\"center\"\u003e\n\n\u003cimg src=\"Resources/Example-macOS.png\" width=\"800\"/\u003e\n\u003cbr /\u003e\n\u003cem\u003ePlist in macOS app\u003c/em\u003e\u003c/p\u003e\n\u003cbr /\u003e\n\n\u003cp align=\"center\"\u003e\n\u003cimg src=\"Resources/Example-iOS.png\" width=\"500\"/\u003e\n\u003cbr /\u003e\n\u003cem\u003eiOS app with an enhanced XML format\u003c/em\u003e\u003c/p\u003e\n\u003cbr /\u003e\n\n\u003cp align=\"center\"\u003e\n\u003cimg src=\"Resources/Example-html.png\" width=\"800\"/\u003e\n\u003cbr /\u003e\n\u003cem\u003e\u003ca href=\"https://www.octory.io\"\u003eOctory\u003c/a\u003e (new) wiki sample\u003c/em\u003e\u003c/p\u003e\n\u003cbr /\u003e\n\n\u003cp align=\"center\"\u003e\n\u003cimg src=\"Resources/Swift-terminal.png\" width=\"800\"/\u003e\n\u003cbr /\u003e\n\u003cem\u003eSwift in the terminal\u003c/em\u003e\u003c/p\u003e\n\u003cbr /\u003e\n\n\u003cp align=\"center\"\u003e\n\u003cimg src=\"Resources/Zsh-iPad.png\" width=\"800\"/\u003e\n\u003cbr /\u003e\n\u003cem\u003eZsh on iPad. A script from Scripting OSX to \u003ca href=\"https://scriptingosx.com/2019/09/notarize-a-command-line-tool/\"\u003enotarise a command-line tool\u003c/a\u003e.\u003c/em\u003e\u003c/p\u003e\n\u003cbr /\u003e\n\n\u003cp align=\"center\"\u003e\n\u003cimg src=\"Resources/Zsh-terminal.png\" width=\"800\"/\u003e\n\u003cbr /\u003e\n\u003cem\u003eZsh in the terminal\u003c/em\u003e\u003c/p\u003e\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n### Quick example\nWith the following Plist file\n\n```xml\n\u003ckey\u003eproperties\u003c/key\u003e\n\u003cdict\u003e\n    \u003ckey\u003eType\u003c/key\u003e\n    \u003cstring\u003eInput\u003c/string\u003e\n    \u003ckey\u003eInputType\u003c/key\u003e\n    \u003cstring\u003eList\u003c/string\u003e\n    \u003ckey\u003eIsAllowed\u003c/key\u003e\n    \u003ctrue/\u003e\n\u003c/dict\u003e\n```\n\nHere is how the library could inject terminal colors:\n\n```xml\n\\033[38;5;8m\u003ckey\u003e\\033[39m\\033[38;5;161mproperties\\033[39m\\033[38;5;8m\u003c/key\u003e\\033[39m\n\\033[38;5;8m\u003cdict\u003e\\033[39m\n\t\\033[38;5;8m\u003ckey\u003e\\033[39m\\033[38;5;161mType\\033[39m\\033[38;5;8m\u003c/key\u003e\\033[39m\n\t\\033[38;5;8m\u003cstring\u003e\\033[39m\\033[39mInput\\033[39m\\033[38;5;8m\u003c/string\u003e\\033[39m\n\t\\033[38;5;8m\u003ckey\u003e\\033[39m\\033[38;5;161mInputType\\033[39m\\033[38;5;8m\u003c/key\u003e\\033[39m\n\t\\033[38;5;8m\u003cstring\u003e\\033[39m\\033[39mList\\033[39m\\033[38;5;8m\u003c/string\u003e\\033[39m\\\n\t\\033[38;5;8m\u003ckey\u003e\\033[39m\\033[38;5;161mIsAllowed\\033[39m\\033[38;5;8m\u003c/key\u003e\\033[39m\n\\033[38;5;8m\u003ctrue/\u003e\\033[39m\\n\\033[38;5;8m\u003c/dict\u003e\\033[39m\"\n```\n\n Or Css classes:\n\n```html\n\u003cspan class=\"plist-tag\"\u003e\u0026lt;key\u0026gt;\u003c/span\u003e\u003cspan class=\"plist-key-name\"\u003eproperties\u003c/span\u003e\u003cspan class=\"plist-tag\"\u003e\u0026lt;/key\u0026gt;\u003c/span\u003e\n\u003cspan class=\"plist-tag\"\u003e\u0026lt;dict\u0026gt;\u003c/span\u003e\n    \u003cspan class=\"plist-tag\"\u003e\u0026lt;key\u0026gt;\u003c/span\u003e\u003cspan class=\"plist-key-name\"\u003eType\u003c/span\u003e\u003cspan class=\"plist-tag\"\u003e\u0026lt;/key\u0026gt;\u003c/span\u003e\n    \u003cspan class=\"plist-tag\"\u003e\u0026lt;string\u0026gt;\u003c/span\u003e\u003cspan class=\"plist-key-value\"\u003eInput\u003c/span\u003e\u003cspan class=\"plist-tag\"\u003e\u0026lt;/string\u0026gt;\u003c/span\u003e\n    \u003cspan class=\"plist-tag\"\u003e\u0026lt;key\u0026gt;\u003c/span\u003e\u003cspan class=\"plist-key-name\"\u003eInputType\u003c/span\u003e\u003cspan class=\"plist-tag\"\u003e\u0026lt;/key\u0026gt;\u003c/span\u003e\n    \u003cspan class=\"plist-tag\"\u003e\u0026lt;string\u0026gt;\u003c/span\u003e\u003cspan class=\"plist-key-value\"\u003eList\u003c/span\u003e\u003cspan class=\"plist-tag\"\u003e\u0026lt;/string\u0026gt;\u003c/span\u003e\n    \u003cspan class=\"plist-tag\"\u003e\u0026lt;key\u0026gt;\u003c/span\u003e\u003cspan class=\"plist-key-name\"\u003eIsAllowed\u003c/span\u003e\u003cspan class=\"plist-tag\"\u003e\u0026lt;/key\u0026gt;\u003c/span\u003e\n    \u003cspan class=\"plist-tag\"\u003e\u0026lt;true/\u0026gt;\u003c/span\u003e\n\u003cspan class=\"plist-tag\"\u003e\u0026lt;/dict\u0026gt;\u003c/span\u003e\n```\n\nYou can then customise those classes in your CSS file. This [wiki page](https://github.com/ABridoux/lux/wiki/%5B40%5D-CSS-classes) describes each format CSS classes.\n\n\u003cu\u003eNote\u003c/u\u003e: For HTML text, the library will take a **HTML string as input**. In HTML, `\u0026` is specified with `\u0026amp;`, chevrons are written with `\u0026lt;` for `\u003c` and `\u0026gt;` for `\u003e`. Thus, when using a HTML injector, you can call its function `escapingHTML()` if you give it plain text as input. Otherwise, nothing has to be done when the input is already HTML encoded.\n\nFor the command line tool `inject` command, the default behavior is to replace those special characters before injecting colors. You can change this behavior with the `--no-escape-html` flag if you already have a HTML-encoded string as input. To escape those characters, Lux uses the following [extension](https://github.com/JohnSundell/Splash/blob/master/Sources/Splash/Extensions/Strings/String%2BHTMLEntities.swift).\n\n\u003cbr /\u003e\n\n## How to install it\n\n#### Homebrew\n\nUse the following command.\n\n```bash\nbrew install ABridoux/formulae/lux\n```\nIt will **download the notarized executable** from the [latest release](https://github.com/ABridoux/scout/releases/latest/download/lux.zip).\n\n#### Download\n\nYou can download the [latest version of the executable](https://github.com/ABridoux/lux/releases/latest/download/lux.zip) from the [releases](https://github.com/ABridoux/lux/releases). Note that the **executable is notarized**. Also, a notarized [lux package](https://github.com/ABridoux/lux/releases/latest/download/lux.pkg) is provided.\n\nAfter having unzipped the file, you can install it if you want to:\n\n```bash\ninstall lux /usr/local/bin/ \n```\n\nHere is a command which downloads the latest version of the program and install it in */usr/local/bin*. \nRun it to download and install the latest version of the program. It erases the current version you may have.\n\n```bash\ncurl -LO https://github.com/ABridoux/lux/releases/latest/download/lux.zip \u0026\u0026 \\\nunzip lux.zip \u0026\u0026 \\\nrm lux.zip \u0026\u0026 \\\ninstall lux /usr/local/bin \u0026\u0026 \\\nrm lux\n```\n\nLux 0.4.3 and later are compatible with Linux. You can download the `tar` archive \"lux-linux\" in the releases. In case you got an error regarding \"libswiftCore.so\" when executing the binary, you can checkout [this solution](https://stackoverflow.com/questions/48242496/how-to-build-a-swift-executable-for-linux-on-macos).\n\n##### Note\n- To find all lux versions, please browse the [releases](https://github.com/ABridoux/lux/releases) page.\n- When deploying a package (with a MDM for example), it might be useful to add the version to the name. To get lux latest version: simply run `lux version` to get your **installed lux version**.\nAlso, if you are using [scout](https://github.com/ABridoux/scout), you can run ` curl --silent \"https://api.github.com/repos/ABridoux/lux/releases/latest\" | scout tag_name` to get the latest version **available on the Github repository**.\n\n\n### Swift package\n\nStart by importing the package in your file *Packages.swift*.\n```swift\nlet package = Package (\n    ...\n    dependencies: [\n        .package(url: \"https://github.com/ABridoux/lux\", from: \"0.1.0\")\n    ],\n    ...\n)\n```\nYou can then `import Lux` in a file.\n\n\u003cbr /\u003e\n\n\n## How to use it\n\n[Command-line](https://github.com/ABridoux/lux/wiki/%5B20%5D-Usage:-command-line)\n\n[Swift package](https://github.com/ABridoux/lux/wiki/%5B21%5D-Usage:-Swift-package)\n\n## Special thanks\n\nThanks to all the contributors of Lux, especially to [Damien Rivet](https://github.com/Ethenyl) who makes code reviews when he has the time. Also, many thanks to the team behind [swift-argument-parser](https://github.com/apple/swift-argument-parser) who keeps doing an incredible work.\nAlso, many thanks to John Sundell for his several articles regarding an API development, and for the [Splash](https://github.com/JohnSundell/Splash) library as well as all its contributors.\n\n### Acknowlegdments\n\nFont used for the logo: Flashlight by [Bexxtype](https://www.dafont.com/fr/syahputra.d7326)]\n\n\n## Contributing\n\n### Report a bug\nLux  aims to be community project, and anyone is welcome to contribute. As it is still a young project, some bugs may appear, or some text not colorised correctly. If you encounter such problem, please [open a issue](https://github.com/ABridoux/lux/issues) to describe it and try to add a use case to reproduce the bug. Hopefully, it should be resolved in the following release.\n\n### Add a new language or theme\nYou can read [here](https://github.com/ABridoux/lux/wiki/%5B30%5D-Add-a-new-language) how to add a new language to Lux. A wiki page explaining theming will be available soon.\n\n## Miscellaneous\n\n- [Colorize terminal with Swift](https://stackoverflow.com/questions/4842424/list-of-ansi-color-escape-sequences) to colorise the output in the terminal.\n- [Terminal colors list](https://misc.flogisoft.com/bash/tip_colors_and_formatting)\n- [Encode code block to HTML](https://www.opinionatedgeek.com/codecs/htmlencoder)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fabridoux%2Flux","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fabridoux%2Flux","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fabridoux%2Flux/lists"}