Skip to content

Commit

Permalink
Updated docs
Browse files Browse the repository at this point in the history
  • Loading branch information
IonicaBizau committed Sep 26, 2024
1 parent ad5af38 commit eeb1b7f
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 178 deletions.
96 changes: 9 additions & 87 deletions DOCUMENTATION.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,97 +2,19 @@

You can see below the API reference of this module.

### `Anser.escapeForHtml(txt)`
Escape the input HTML.
Add several widely used style codes

This does the minimum escaping of text to make it compliant with HTML.
In particular, the '&','<', and '>' characters are escaped. This should
be run prior to `ansiToHtml`.
### `processChunk(text, options, markup)`
Processes the current chunk of text.

#### Params

- **String** `txt`: The input text (containing the ANSI snippets).
- **String** `text`: The input text.
- **Object** `options`: An object containing the following fields:
- `json` (Boolean): If `true`, the result will be an object.
- `use_classes` (Boolean): If `true`, HTML classes will be appended to the HTML output.
- **Boolean** `markup`: If false, the colors will not be parsed.

#### Return
- **String** The escaped html.

### `Anser.linkify(txt)`
Adds the links in the HTML.

This replaces any links in the text with anchor tags that display the
link. The links should have at least one whitespace character
surrounding it. Also, you should apply this after you have run
`ansiToHtml` on the text.

#### Params

- **String** `txt`: The input text.

#### Return
- **String** The HTML containing the <a> tags (unescaped).

### `Anser.ansiToHtml(txt, options)`
This replaces ANSI terminal escape codes with SPAN tags that wrap the
content.

This function only interprets ANSI SGR (Select Graphic Rendition) codes
that can be represented in HTML.
For example, cursor movement codes are ignored and hidden from output.
The default style uses colors that are very close to the prescribed
standard. The standard assumes that the text will have a black
background. These colors are set as inline styles on the SPAN tags.

Another option is to set `use_classes: true` in the options argument.
This will instead set classes on the spans so the colors can be set via
CSS. The class names used are of the format `ansi-*-fg/bg` and
`ansi-bright-*-fg/bg` where `*` is the color name,
i.e black/red/green/yellow/blue/magenta/cyan/white.

#### Params

- **String** `txt`: The input text.
- **Object** `options`: The options passed to the ansiToHTML method.

#### Return
- **String** The HTML output.

### `Anser.ansiToJson(txt, options)`
Converts ANSI input into JSON output.

#### Params

- **String** `txt`: The input text.
- **Object** `options`: The options passed to the ansiToHTML method.

#### Return
- **String** The HTML output.

### `Anser.ansiToText(txt)`
Converts ANSI input into text output.

#### Params

- **String** `txt`: The input text.

#### Return
- **String** The text output.

### `Anser()`
The `Anser` class.

#### Return
- **Anser**

### `setupPalette()`
Sets up the palette.

### `escapeForHtml(txt)`
Escapes the input text.

#### Params

- **String** `txt`: The input text.

#### Return
- **String** The escpaed HTML output.
- **Object|String** The result (object if `json` is wanted back or string otherwise).

103 changes: 14 additions & 89 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -189,99 +189,21 @@ There are few ways to get help:
## :memo: Documentation


### `Anser.escapeForHtml(txt)`
Escape the input HTML.
Add several widely used style codes

This does the minimum escaping of text to make it compliant with HTML.
In particular, the '&','<', and '>' characters are escaped. This should
be run prior to `ansiToHtml`.
### `processChunk(text, options, markup)`
Processes the current chunk of text.

#### Params

- **String** `txt`: The input text (containing the ANSI snippets).
- **String** `text`: The input text.
- **Object** `options`: An object containing the following fields:
- `json` (Boolean): If `true`, the result will be an object.
- `use_classes` (Boolean): If `true`, HTML classes will be appended to the HTML output.
- **Boolean** `markup`: If false, the colors will not be parsed.

#### Return
- **String** The escaped html.

### `Anser.linkify(txt)`
Adds the links in the HTML.

This replaces any links in the text with anchor tags that display the
link. The links should have at least one whitespace character
surrounding it. Also, you should apply this after you have run
`ansiToHtml` on the text.

#### Params

- **String** `txt`: The input text.

#### Return
- **String** The HTML containing the <a> tags (unescaped).

### `Anser.ansiToHtml(txt, options)`
This replaces ANSI terminal escape codes with SPAN tags that wrap the
content.

This function only interprets ANSI SGR (Select Graphic Rendition) codes
that can be represented in HTML.
For example, cursor movement codes are ignored and hidden from output.
The default style uses colors that are very close to the prescribed
standard. The standard assumes that the text will have a black
background. These colors are set as inline styles on the SPAN tags.

Another option is to set `use_classes: true` in the options argument.
This will instead set classes on the spans so the colors can be set via
CSS. The class names used are of the format `ansi-*-fg/bg` and
`ansi-bright-*-fg/bg` where `*` is the color name,
i.e black/red/green/yellow/blue/magenta/cyan/white.

#### Params

- **String** `txt`: The input text.
- **Object** `options`: The options passed to the ansiToHTML method.

#### Return
- **String** The HTML output.

### `Anser.ansiToJson(txt, options)`
Converts ANSI input into JSON output.

#### Params

- **String** `txt`: The input text.
- **Object** `options`: The options passed to the ansiToHTML method.

#### Return
- **String** The HTML output.

### `Anser.ansiToText(txt)`
Converts ANSI input into text output.

#### Params

- **String** `txt`: The input text.

#### Return
- **String** The text output.

### `Anser()`
The `Anser` class.

#### Return
- **Anser**

### `setupPalette()`
Sets up the palette.

### `escapeForHtml(txt)`
Escapes the input text.

#### Params

- **String** `txt`: The input text.

#### Return
- **String** The escpaed HTML output.
- **Object|String** The result (object if `json` is wanted back or string otherwise).



Expand Down Expand Up @@ -400,6 +322,7 @@ If you are using this library in one of your projects, add it in this list. :spa
- `@naze/error`
- `@ndjoe/react-native-bluetooth-escpos-printer`
- `@next/react-dev-overlay`
- `@nonfx/flow-log`
- `@npm_fluentco/adflow-react-native-sdk`
- `@office-iss/react-native-win32`
- `@oiti/rn-liveness2d`
Expand All @@ -413,6 +336,7 @@ If you are using this library in one of your projects, add it in this list. :spa
- `@praella/localisationist`
- `@prague-digi/react-error-overlay`
- `@prozilla-os/terminal`
- `@react-native-ui-design/button`
- `@redux-devtools/inspector-monitor-trace-tab`
- `@routebuddies/react-native-mapbox-navigation`
- `@ryfow/react-native-windows`
Expand Down Expand Up @@ -441,6 +365,7 @@ If you are using this library in one of your projects, add it in this list. :spa
- `@theia/console`
- `@thinxviewx/core-rn`
- `@throttleup/gatsby`
- `@tlgeo/react-native-gdal`
- `@trackier/react-native-trackier`
- `@unforgiven/react-native`
- `@viankakrisna/react-dev-utils`
Expand Down Expand Up @@ -473,9 +398,7 @@ If you are using this library in one of your projects, add it in this list. :spa
- `cycle-dev-utils`
- `dogandev-simple-toast`
- `dulcet-error-overlay`
- `emg-api`
- `fawaterak-online-payment`
- `fawatrak-online-payment`
- `fluent.adflow.reactnativesdk`
- `fluent.adflow.reactnativesdk-alpha`
- `fmsl`
Expand Down Expand Up @@ -524,6 +447,7 @@ If you are using this library in one of your projects, add it in this list. :spa
- `react-error-overlay-dangerous`
- `react-ipynb-renderer-katex`
- `react-native`
- `react-native-adarsh_react_native_video_player`
- `react-native-addition`
- `react-native-android-native-view`
- `react-native-android-scoped-storage`
Expand Down Expand Up @@ -561,6 +485,7 @@ If you are using this library in one of your projects, add it in this list. :spa
- `react-native-contact-list`
- `react-native-cplus`
- `react-native-create-video-thumbnail`
- `react-native-ctp-odp`
- `react-native-custom-poccomponent`
- `react-native-custom-poccomponent-next`
- `react-native-datacapture-core`
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit eeb1b7f

Please sign in to comment.