{"id":17309579,"url":"https://github.com/jcubic/ansidec","last_synced_at":"2025-04-14T13:52:42.931Z","repository":{"id":53874290,"uuid":"157618772","full_name":"jcubic/ansidec","owner":"jcubic","description":"Unix formatting transformer in JavaScript","archived":false,"fork":false,"pushed_at":"2024-11-20T00:14:42.000Z","size":80,"stargazers_count":5,"open_issues_count":1,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-05T20:45:02.073Z","etag":null,"topics":["ansi","ansi-art","browser","dos","html","unix"],"latest_commit_sha":null,"homepage":null,"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/jcubic.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":"2018-11-14T22:19:46.000Z","updated_at":"2024-11-20T00:14:46.000Z","dependencies_parsed_at":"2025-03-18T03:06:38.972Z","dependency_job_id":"09ec110c-f998-4652-a3d3-3414fda3eacd","html_url":"https://github.com/jcubic/ansidec","commit_stats":null,"previous_names":[],"tags_count":9,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jcubic%2Fansidec","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jcubic%2Fansidec/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jcubic%2Fansidec/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jcubic%2Fansidec/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jcubic","download_url":"https://codeload.github.com/jcubic/ansidec/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248891312,"owners_count":21178608,"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":["ansi","ansi-art","browser","dos","html","unix"],"created_at":"2024-10-15T12:30:08.793Z","updated_at":"2025-04-14T13:52:42.905Z","avatar_url":"https://github.com/jcubic.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"```\n   ▄████████ ███▄▄▄▄      ▄████████  ▄█  ████████▄     ▄████████  ▄████████\n  ███    ███ ███▀▀▀██▄   ███    ███ ███  ███   ▀███   ███    ███ ███    ███\n  ███    ███ ███   ███   ███    █▀  ███▌ ███    ███   ███    █▀  ███    █▀\n  ███    ███ ███   ███   ███        ███▌ ███    ███  ▄███▄▄▄     ███\n▀███████████ ███   ███ ▀███████████ ███▌ ███    ███ ▀▀███▀▀▀     ███\n  ███    ███ ███   ███          ███ ███  ███    ███   ███    █▄  ███    █▄\n  ███    ███ ███   ███    ▄█    ███ ███  ███   ▄███   ███    ███ ███    ███\n  ███    █▀   ▀█   █▀   ▄████████▀  █▀   ████████▀    ██████████ ████████▀\n```\n\n[![npm](https://img.shields.io/badge/npm-0.3.4-blue.svg)](https://www.npmjs.com/package/ansidec)\n[![travis](https://travis-ci.org/jcubic/ansidec.svg?branch=master)](https://travis-ci.org/jcubic/ansidec)\n[![Coverage Status](https://coveralls.io/repos/github/jcubic/ansidec/badge.svg?branch=master)](https://coveralls.io/github/jcubic/ansidec?branch=master)\n[![MIT badge](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/jcubic/jquery.terminal/blob/master/LICENSE)\n\nANSIDec is a library for handling limited number of ANSI escape sequences for use\nin Browsers. The primary goal of the library is to allow of displaying ANSI and ASCII\nart in Browsers by transforming Unix encoding to html.\nBut it can also be used from Node.js.\n\n## Demo\n\nhttps://jcubic.github.io/ansidec/\n\n## Installation\n\nNpm installation for use with webpack:\n\n```\nnpm install ansidec\n```\n\nBesides npm you can also download that file locally or use\n[unpkg.com](https://unpkg.com/ansidec):\n\n```html\n\u003cscript src=\"https://unpkg.com/ansidec\"\u003e\u003c/script\u003e\n\n```\n\n## Usage\n\n```javascript\n// if you're using webpack or node.js you can use npm\nvar ansi = require('ansidec');\n\nvar format = ansi.format(function(styles, color, background, text) {\n  var style = [];\n  if (color) {\n    style.push('color:' + color);\n  }\n  if (background) {\n    style.push('background:' + background);\n  }\n  if (styles.bold) {\n    style.push('font-weight:bold');\n  }\n  if (styles.italic) {\n    style.push('font-style:italic');\n  }\n  if (styles.underline) {\n    styles.push('text-decoration:underline');\n  }\n  return '\u003cspan style=\"' + style.join(';') + '\"\u003e' + text + '\u003c/span\u003e';\n});\n\ndocument.querySelector('pre').innerHTML = format(text);\n```\n\nformat function can be executed with text as second argument, then it will\nreturn string. If it don't get string as second argument it will return\nfunction. So it's like it was curried.\n\nIf you want just to output html you can use helper:\n\n```javascript\nvar ansi = require('ansidec');\nvar output = document.querySelector('pre');\noutput.innerHTML = ansi.html(text)\n```\n\nand use format only if you need different html or any different output text.\n\n## ANSI art\n\nIf you want to render ANSI art with this library you will need to covert the text from\nANSI art file to UTF-8 to do that you can use iconv-lite library or iconv on a Back-End\nsee how to do that in\n[examples directory](https://github.com/jcubic/ansidec/tree/master/example).\n\nSome ANSI art are 80 characters wide but some have meta data called\n[SAUCE](http://www.acid.org/info/sauce/sauce.htm). You can read those data\nusing `ansi.meta` function:\n\n```javascript\nvar sauce = ansi.meta(text);\nif (sauce) {\n  var chars = sauce.tInfo[0];\n  // note that ch unit don't work properly in IE\n  output.style.width = chars + 'ch';\n}\n```\n\nmeta object have those properties (description in SAUCE specification linked above).\n\n```typescript\n{\n  id: 'SAUCE',\n  version: string,\n  title: string,\n  author: string,\n  group: string,\n  date: string,\n  fileSize: number,\n  tInfo: number[],\n  comments: string,\n  tflags: string,\n  zstring: string\n}\n```\n\n### Changelog\n* 0.3.4 - fix GitHub url in README for npm\n* 0.3.3 - parse zstring from SAUCE + fixes to match unit tests\n* 0.3.2 - proper parsing of SAUCE comments\n* 0.3.1 - alternative SAUCE extraction\n* 0.3.0 - parsing SAUCE meta\n* 0.2.1 - bump up version for npm\n* 0.2.0 - fix 8 bit colors (Denis Ritchie)\n* 0.1.0 - first version\n\n### License\n\nReleased under [MIT](http://opensource.org/licenses/MIT) license\n\nCopyright (c) 2018-2020 [Jakub T. Jankiewicz](https://jcubic.pl/)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjcubic%2Fansidec","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjcubic%2Fansidec","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjcubic%2Fansidec/lists"}