{"id":17703418,"url":"https://github.com/randoragon/groffhl","last_synced_at":"2025-03-13T06:32:01.287Z","repository":{"id":176069840,"uuid":"347442811","full_name":"randoragon/groffhl","owner":"randoragon","description":"Groff Code Syntax Highlighting","archived":false,"fork":false,"pushed_at":"2021-04-16T12:25:48.000Z","size":54,"stargazers_count":8,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-02-10T11:11:17.396Z","etag":null,"topics":["groff","linux","syntax-highlighting"],"latest_commit_sha":null,"homepage":"","language":"C","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/randoragon.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":"2021-03-13T18:03:40.000Z","updated_at":"2023-08-27T22:35:18.000Z","dependencies_parsed_at":null,"dependency_job_id":"b4765d7d-318c-4feb-9b46-3bc2cf4c260b","html_url":"https://github.com/randoragon/groffhl","commit_stats":null,"previous_names":["randoragon/groffhl"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/randoragon%2Fgroffhl","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/randoragon%2Fgroffhl/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/randoragon%2Fgroffhl/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/randoragon%2Fgroffhl/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/randoragon","download_url":"https://codeload.github.com/randoragon/groffhl/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243357737,"owners_count":20277988,"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":["groff","linux","syntax-highlighting"],"created_at":"2024-10-24T20:22:57.141Z","updated_at":"2025-03-13T06:32:01.279Z","avatar_url":"https://github.com/randoragon.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"# groffhl - a simple groff highlighter\n\ngroffhl is a small program for converting Linux \"truecolor\" escape sequences into native groff format.\nYou can then take the output and paste it into another groff document.\n\n## How it works\n\ngroffhl intakes a file with colors encoded as 24-bit \"truecolor\" escape sequences (e.g. `\\033[38;2;255;0;0m  *red* \\033[m`).\nIt scans the whole file, remembers every distinct color and substitutes it to groff format (e.g. `\\m[red] *red* \\m[]`) and\nfinally prints a header including all color declarations, followed by the formatted code.\n\n## Example\n\nLet's say we want to colorize this code snippet in groff:\n\n![example1](https://raw.githubusercontent.com/Randoragon/groffhl/master/example-1.png)\n\n1. First, we need it as a plaintext file, let's call it \"hello.c\".\n2. Next we can use a tool like [highlight](http://www.andre-simon.de/doku/highlight/en/highlight.php) to do the highlighting:\n\n![example2](https://raw.githubusercontent.com/Randoragon/groffhl/master/example-2.png)\n\n3. Next, we feed this new \"highlighted.txt\" file to groffhl:\n\n```sh\n$ groffhl highlighted.txt \u003ehighlighted.groff\n```\n\nThe resulting `highlighted.groff` file looks like this:\n\n```groff\n.defcolor groffhl_0 rgb 0.058824f 0.576471f 0.058824f\n.defcolor groffhl_1 rgb 0.325490f 0.988235f 0.988235f\n.defcolor groffhl_2 rgb 0.411765f 0.780392f 0.537255f\n.defcolor groffhl_3 rgb 1.000000f 1.000000f 1.000000f\n.defcolor groffhl_4 rgb 0.776471f 0.254902f 0.776471f\n.defcolor groffhl_5 rgb 0.972549f 0.819608f 0.819608f\n.defcolor groffhl_6 rgb 0.815686f 0.815686f 0.270588f\n.defcolor groffhl_7 rgb 0.901961f 0.298039f 0.901961f\n\n\\m[groffhl_0]\\m[]\\m[groffhl_1]#include \u003cstdio.h\u003e\\m[]\n\\m[groffhl_0]\\m[]\n\\m[groffhl_0]\\m[]\\m[groffhl_2]int\\m[] \\m[groffhl_0]\\m[]\\m[groffhl_3]main\\m[]\\m[groffhl_0]\\m[]\\m[groffhl_3](\\m[]\\m[groffhl_0]\\m[]\\m[groffhl_2]int\\m[] \\m[groffhl_0]argc\\m[]\\m[groffhl_3],\\m[] \\m[groffhl_0]\\m[]\\m[groffhl_2]char\\m[] \\m[groffhl_0]\\m[]\\m[groffhl_3]**\\m[]\\m[groffhl_0]argv\\m[]\\m[groffhl_3])\\m[]\n\\m[groffhl_0]\\m[]\\m[groffhl_3]{\\m[]\n\\m[groffhl_0]\\m[]    \\m[groffhl_3]printf\\m[]\\m[groffhl_0]\\m[]\\m[groffhl_3](\\m[]\\m[groffhl_0]\\m[]\\m[groffhl_4]\"Hello, world!\\m[]\\m[groffhl_5]\\en\\m[]\\m[groffhl_4]\"\\m[]\\m[groffhl_0]\\m[]\\m[groffhl_3]);\\m[]\n\\m[groffhl_0]\\m[]    \\m[groffhl_6]return\\m[] \\m[groffhl_0]\\m[]\\m[groffhl_7]0\\m[]\\m[groffhl_0]\\m[]\\m[groffhl_3];\\m[]\n\\m[groffhl_0]\\m[]\\m[groffhl_3]}\\m[]\\m[groffhl_0]\\m[]\n```\nAs you can see, groffhl keeps track of all colors and neatly organizes them in a simple declaration block. Also, be wary that `highlight`\nproduces output intended for terminal emulators which typically have a black background. Meanwhile, groff documents tend to print text\non white pages, so you will likely need to tweak some of the color definitions to suit your needs. For example, in the above file you'll\nnotice that `groffhl_3` has an RGB value of (1, 1, 1), which is pitch white. On a white page, all code written in this color would\nappear invisible, so usually you want to change it manually to black instead.\n\nHere is the final result, after a few small manual tweaks to the color definitions:\n\n![example3](https://raw.githubusercontent.com/Randoragon/groffhl/master/example-3.png)\n\n## Installing\n\nArch Linux users can install the [groffhl-git](https://aur.archlinux.org/packages/groffhl-git/) package from the AUR.\n\n---\n\nClone the repo and run the following (if necessary, as root):\n\n    make install\n\nThe executable will be installed to `/usr/local/bin/groffhl`.\n\nYou can uninstall in the same way with\n\n    make uninstall\n\n## TODO\n\n- [ ] Support for bold/italic sequences (`\\033[1;38;2;r;g;bm`, `\\033[3;38;2;r;g;bm`)\n- [ ] Ignoring unsupported sequences (see full list [here](https://en.wikipedia.org/wiki/ANSI_escape_code#SGR_(Select_Graphic_Rendition)_parameters))\n- [x] man page\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frandoragon%2Fgroffhl","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frandoragon%2Fgroffhl","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frandoragon%2Fgroffhl/lists"}