Skip to content

Commit

Permalink
Merge branch 'v6.0.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
drudru committed Aug 15, 2023
2 parents a30bb48 + 803e79a commit 64a8a82
Show file tree
Hide file tree
Showing 17 changed files with 1,073 additions and 1,225 deletions.
28 changes: 0 additions & 28 deletions .vscode/launch.json

This file was deleted.

9 changes: 0 additions & 9 deletions .vscode/tasks.json

This file was deleted.

9 changes: 3 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@

SOURCE = *.ts
TESTS = test/*.js
SOURCE = *.ts
TESTS = test/*.js
REPORTER = dot

typescript:
./node_modules/.bin/tsc -p .
cat ./umd.header ./dist/ansi_up.js ./umd.footer > ansi_up.js
mv ./dist/ansi_up.js ./dist/ansi_up.js.include
node ./scripts/fix-typings.js


test:
@NODE_ENV=test ./node_modules/.bin/mocha \
--require should \
Expand Down
34 changes: 21 additions & 13 deletions Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
__ansi_up__ is an easy to use library that transforms text containing
[ANSI color escape codes](http://en.wikipedia.org/wiki/ANSI_escape_code#Colors) into HTML.

This module is a single Javascript file with no dependencies.
This module is a single ES6 Javascript file with no dependencies.
It is "isomorphic" javascript. This is just another way of saying that
the ansi_up.js file will work in both the browser or node.js.
The js library is compiled from TypeScript and its type description ships with the NPM.
Expand All @@ -25,12 +25,13 @@ For example, turn this terminal output:
## Browser Example

```HTML
<script src="ansi_up.js" type="text/javascript"></script>
<script type="text/javascript">

<script type="module" type="text/javascript">
var txt = "\n\n\033[1;33;40m 33;40 \033[1;33;41m 33;41 \033[1;33;42m 33;42 \033[1;33;43m 33;43 \033[1;33;44m 33;44 \033[1;33;45m 33;45 \033[1;33;46m 33;46 \033[1m\033[0\n\n\033[1;33;42m >> Tests OK\n\n"
var ansi_up = new AnsiUp;
import { AnsiUp } from './ansi_up.js'
var ansi_up = new AnsiUp();
var html = ansi_up.ansi_to_html(txt);
Expand All @@ -44,8 +45,8 @@ For example, turn this terminal output:
## Node Example

```JavaScript
var AU = require('ansi_up');
var ansi_up = new AU.default;
import { AnsiUp } from './ansi_up.js'
var ansi_up = new AnsiUp();

var txt = "\n\n\033[1;33;40m 33;40 \033[1;33;41m 33;41 \033[1;33;42m 33;42 \033[1;33;43m 33;43 \033[1;33;44m 33;44 \033[1;33;45m 33;45 \033[1;33;46m 33;46 \033[1m\033[0\n\n\033[1;33;42m >> Tests OK\n\n"

Expand All @@ -57,10 +58,7 @@ More examples are in the 'examples' directory in the repo.
## Typescript Example

```TypeScript
import {
default as AnsiUp
} from 'ansi_up';

import { AnsiUp } from './ansi_up.js'
const ansi_up = new AnsiUp();

const txt = "\n\n\x1B[1;33;40m 33;40 \x1B[1;33;41m 33;41 \x1B[1;33;42m 33;42 \x1B[1;33;43m 33;43 \x1B[1;33;44m 33;44 \x1B[1;33;45m 33;45 \x1B[1;33;46m 33;46 \x1B[1m\x1B[0\n\n\x1B[1;33;42m >> Tests OK\n\n"
Expand All @@ -73,6 +71,7 @@ More examples are in the 'examples' directory in the repo.
$ npm install ansi_up

## Versions
* Version 6.0 - Switch to ES6 module. Add faint styles. Style css configurable.
* Version 5.1 - Add italic and underline styles (@DaoDaoNoCode)
* Version 5.0 - Security fix for OSC URLs
* Version 4.0 - Re-architect code to support [terminal URL codes](https://gist.github.com/egmontkob/eb114294efbcd5adb1944c9f3cb5feda).
Expand Down Expand Up @@ -131,10 +130,19 @@ By default, HTML's reserved characters `& < > " '` are replaced with <a href="ht
This causes the SPAN tags to use classes to style the SPAN tags instead
of specified RGB values.

#### url_whitelist
(default: { 'http':1, 'https':1 };
#### url_acceptlist
(default: { 'http':1, 'https':1 })

This mapping is an 'accept' list of URI schemes that will be allowed to render HTML anchor tags.

This mapping is a whitelist of URI schemes that will be allowed to render HTML anchor tags.
#### boldStyle
(default: 'font-weight:bold')
#### faintStyle
(default: 'opacity:0.7')
#### italicStyle
(default: 'font-style:italic')
#### underlineStyle
(default: 'text-decoration:underline')

## Buffering

Expand Down
1 change: 0 additions & 1 deletion VERSION

This file was deleted.

59 changes: 26 additions & 33 deletions ansi_up.d.ts
Original file line number Diff line number Diff line change
@@ -1,53 +1,46 @@
interface AU_Color {
rgb: number[];
class_name: string;
}
interface TextWithAttr {
fg: AU_Color;
bg: AU_Color;
bold: boolean;
text: string;
}
declare enum PacketKind {
EOS = 0,
Text = 1,
Incomplete = 2,
ESC = 3,
Unknown = 4,
SGR = 5,
OSCURL = 6
}
interface TextPacket {
kind: PacketKind;
text: string;
url: string;
}
export declare class AnsiUp {
VERSION: string;
private ansi_colors;
private palette_256;
private fg;
private bg;
private bold;
private faint;
private italic;
private underline;
private _use_classes;
private _escape_for_html;
private _csi_regex;
private _osc_st;
private _osc_regex;
private _url_whitelist;
private _url_acceptlist;
private _escape_html;
private _buffer;
private _boldStyle;
private _faintStyle;
private _italicStyle;
private _underlineStyle;
constructor();
use_classes: boolean;
escape_for_html: boolean;
url_whitelist: {};
set use_classes(arg: boolean);
get use_classes(): boolean;
set url_acceptlist(arg: {});
get url_acceptlist(): {};
set escape_html(arg: boolean);
get escape_html(): boolean;
set boldStyle(arg: string);
get boldStyle(): string;
set faintStyle(arg: string);
get faintStyle(): string;
set italicStyle(arg: string);
get italicStyle(): string;
set underlineStyle(arg: string);
get underlineStyle(): string;
private setup_palettes;
private escape_txt_for_html;
append_buffer(txt: string): void;
get_next_packet(): TextPacket;
private append_buffer;
private get_next_packet;
ansi_to_html(txt: string): string;
private with_state;
private process_ansi;
transform_to_html(fragment: TextWithAttr): string;
private transform_to_html;
private process_hyperlink;
}
export {};

0 comments on commit 64a8a82

Please sign in to comment.