diff --git a/DOCUMENTATION.md b/DOCUMENTATION.md index f42dcc7..845a333 100644 --- a/DOCUMENTATION.md +++ b/DOCUMENTATION.md @@ -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 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). diff --git a/README.md b/README.md index 07e5a3c..cd8c749 100644 --- a/README.md +++ b/README.md @@ -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 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). @@ -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` @@ -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` @@ -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` @@ -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` @@ -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` @@ -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` diff --git a/package-lock.json b/package-lock.json index bf31e65..9e30c3b 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "anser", - "version": "2.2.0", + "version": "2.3.0", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "anser", - "version": "2.2.0", + "version": "2.3.0", "license": "MIT", "devDependencies": { "jshint": "*",