{"id":20513840,"url":"https://github.com/webreflection/console-strings","last_synced_at":"2025-04-14T00:01:31.025Z","repository":{"id":257071488,"uuid":"857122454","full_name":"WebReflection/console-strings","owner":"WebReflection","description":"String utilities that understand terminal escape sequences.","archived":false,"fork":false,"pushed_at":"2025-01-17T17:33:34.000Z","size":148,"stargazers_count":24,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-24T08:06:58.290Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"JavaScript","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/WebReflection.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":"2024-09-13T21:08:43.000Z","updated_at":"2025-02-22T04:51:17.000Z","dependencies_parsed_at":"2024-09-14T18:13:01.510Z","dependency_job_id":null,"html_url":"https://github.com/WebReflection/console-strings","commit_stats":null,"previous_names":["webreflection/console-strings"],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/WebReflection%2Fconsole-strings","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/WebReflection%2Fconsole-strings/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/WebReflection%2Fconsole-strings/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/WebReflection%2Fconsole-strings/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/WebReflection","download_url":"https://codeload.github.com/WebReflection/console-strings/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248799931,"owners_count":21163403,"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":[],"created_at":"2024-11-15T21:13:29.676Z","updated_at":"2025-04-14T00:01:30.971Z","avatar_url":"https://github.com/WebReflection.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# console-strings\n\n[![Coverage Status](https://coveralls.io/repos/github/WebReflection/console-strings/badge.svg?branch=main)](https://coveralls.io/github/WebReflection/console-strings?branch=main) \n\n\u003csup\u003e**Social Media Photo by [Dominik Scythe](https://unsplash.com/@drscythe) on [Unsplash](https://unsplash.com/)**\u003c/sup\u003e\n\n\nA dual module that can be used via `import`, `require`, or directly via `https://esm.run/console-strings`, to automatically wrap `\\x1b[...` escape chars around strings in a terminal or devtools compatible way.\n\n```js\nimport {\n  bold,       // show bold text\n  light,      // show a lighter text - alias: dim\n  italic,     // show italic text\n  underline,  // show underlined text\n  strike,     // show a strike-through text\n  overline,   // show an overline (not in devtools)\n  foreground, // use a specific text color\n  background, // use a specific background color\n  reset,      // reset any broken output (not needed but handy)\n} from 'console-strings';\n\n// ⚠️ needed only for x-browser compatibility\n// not needed at all in Bun, NodeJS or Chrome/ium browsers\nimport * as console from 'console-strings/browser';\n// exported: error, info, log, warn\n\nconsole.log(`\n  This is ${bold('bold')} text\n  while this should be ${light('light')}.\n  An ${italic('italic')} text is allowed\n  and so it should be ${underline('underlined')}.\n  A ${strike('strike')} would work too but\n  an ${overline('overline')} might not.\n  Combine ${underline(bold(italic('underlined bold italic')))}\n  or any other variant or add some ${foreground('color', 32)} and\n  ${background(foreground('background', 30), 42)} color too. ${reset()}\n`);\n```\n\n**[Live Demo](https://webreflection.github.io/console-strings/test/browser/)**\n\n![visual terminal example](./test/index.png)\n\n## Markdown\n\nThe `console-strings/md` default export converts:\n\n  * **bold** via `**double**` stars\n  * **underline** via `__double__` underlines\n  * **light** or **dim** via `-single-` or `--double--` dashes\n  * **strike** via `~single~` or `~~double~~` dashes\n  * **italic** via single `*star*` or single `_underlined_` only\n  * **foreground** via `f#32#color value#` or `f#R;G;B#rgb value#`\n  * **background** via `b#42#color value#` or `b#R;G;B#rgb value#`\n\n```js\nimport md from 'console-strings/md';\n\nconsole.log(md('Hello **World**!'));\n```\n\nFor anything more complex please see [consolemd](https://github.com/WebReflection/consolemd/tree/master#readme).\n\n**[Live Demo](https://webreflection.github.io/console-strings/test/md/)**\n\n### Colors\n\nAll colors compatible with devtools are described [in here](https://developer.chrome.com/docs/devtools/console/format-style) and this is a summary:\n\n| Name           | Foreground | Background | Light theme | Dark theme  |\n| :------------- | :--------- | :--------- | :---------- | :---------- |\n| Black          | `30`       | `40`       | #000000     | #000000     |\n| Red            | `31`       | `41`       | #AA0000     | #ED4E4C     |\n| Green          | `32`       | `42`       | #00AA00     | #01C800     |\n| Yellow         | `33`       | `43`       | #AA5500     | #D2C057     |\n| Blue           | `34`       | `44`       | #0000AA     | #2774F0     |\n| Magenta        | `35`       | `45`       | #AA00AA     | #A142F4     |\n| Cyan           | `36`       | `46`       | #00AAAA     | #12B5CB     |\n| White          | `37`       | `47`       | #AAAAAA     | #CFD0D0     |\n| Bright Black   | `90`       | `100`      | #555555     | #898989     |\n| Bright Red     | `91`       | `101`      | #FF5555     | #F28B82     |\n| Bright Green   | `92`       | `102`      | #55FF55     | #01C801     |\n| Bright Yellow  | `93`       | `103`      | #FFFF55     | #DDFB55     |\n| Bright Blue    | `94`       | `104`      | #5555FF     | #669DF6     |\n| Bright Magenta | `95`       | `105`      | #FF55FF     | #D670D6     |\n| Bright Cyan    | `96`       | `106`      | #55FFFF     | #84F0FF     |\n| Bright White   | `97`       | `107`      | #FFFFFF     | #FFFFFF     |\n\nIf a foreground value for a `background(content, value)` is passed along, or vice-versa, a `⚠` char would prefix the error without throwing while outputting.\n\nThe `browser` variant color is chosen after a one-off `matchMedia('(prefers-color-scheme:dark)')` check.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwebreflection%2Fconsole-strings","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwebreflection%2Fconsole-strings","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwebreflection%2Fconsole-strings/lists"}