Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

anser 2.1.1 #71

Merged
merged 4 commits into from
Feb 2, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
91 changes: 0 additions & 91 deletions DOCUMENTATION.md
Original file line number Diff line number Diff line change
Expand Up @@ -96,94 +96,3 @@ Escapes the input text.
#### Return
- **String** The escpaed HTML output.

### `linkify(txt)`
Adds HTML link elements.

#### Params

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

#### Return
- **String** The HTML output containing link elements.

### `ansiToHtml(txt, options)`
Converts ANSI input into HTML output.

#### Params

- **String** `txt`: The input text.
- **Object** `options`: The options passed ot the `process` method.

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

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

#### Params

- **String** `txt`: The input text.
- **Object** `options`: The options passed ot the `process` method.

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

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

#### Params

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

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

### `process(txt, options, markup)`
Processes the input.

#### Params

- **String** `txt`: The input text.
- **Object** `options`: An object passed to `processChunk` method, extended with:
- `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`:

### `processChunkJson(text, options, markup)`
Processes the current chunk into json output.

#### Params

- **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
- **Object** The result object:
- `content` (String): The text.
- `fg` (String|null): The foreground color.
- `bg` (String|null): The background color.
- `fg_truecolor` (String|null): The foreground true color (if 16m color is enabled).
- `bg_truecolor` (String|null): The background true color (if 16m color is enabled).
- `clearLine` (Boolean): `true` if a carriageReturn \r was fount at end of line.
- `was_processed` (Bolean): `true` if the colors were processed, `false` otherwise.
- `isEmpty` (Function): A function returning `true` if the content is empty, or `false` otherwise.

Add several widely used style codes

### `processChunk(text, options, markup)`
Processes the current chunk of text.

#### Params

- **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
- **Object|String** The result (object if `json` is wanted back or string otherwise).

2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
The MIT License (MIT)

Copyright (c) 2012-21 Ionică Bizău <[email protected]> (https://ionicabizau.net)
Copyright (c) 2012-22 Ionică Bizău <[email protected]> (https://ionicabizau.net)

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
116 changes: 16 additions & 100 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -280,97 +280,6 @@ Escapes the input text.
#### Return
- **String** The escpaed HTML output.

### `linkify(txt)`
Adds HTML link elements.

#### Params

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

#### Return
- **String** The HTML output containing link elements.

### `ansiToHtml(txt, options)`
Converts ANSI input into HTML output.

#### Params

- **String** `txt`: The input text.
- **Object** `options`: The options passed ot the `process` method.

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

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

#### Params

- **String** `txt`: The input text.
- **Object** `options`: The options passed ot the `process` method.

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

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

#### Params

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

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

### `process(txt, options, markup)`
Processes the input.

#### Params

- **String** `txt`: The input text.
- **Object** `options`: An object passed to `processChunk` method, extended with:
- `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`:

### `processChunkJson(text, options, markup)`
Processes the current chunk into json output.

#### Params

- **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
- **Object** The result object:
- `content` (String): The text.
- `fg` (String|null): The foreground color.
- `bg` (String|null): The background color.
- `fg_truecolor` (String|null): The foreground true color (if 16m color is enabled).
- `bg_truecolor` (String|null): The background true color (if 16m color is enabled).
- `clearLine` (Boolean): `true` if a carriageReturn \r was fount at end of line.
- `was_processed` (Bolean): `true` if the colors were processed, `false` otherwise.
- `isEmpty` (Function): A function returning `true` if the content is empty, or `false` otherwise.

Add several widely used style codes

### `processChunk(text, options, markup)`
Processes the current chunk of text.

#### Params

- **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
- **Object|String** The result (object if `json` is wanted back or string otherwise).




Expand Down Expand Up @@ -442,19 +351,19 @@ If you are using this library in one of your projects, add it in this list. :spa
- `@viankakrisna/react-dev-utils`
- `ansi-to-json`
- `redux-devtools-trace-monitor`
- `@opensumi/ide-debug`
- `@kui-shell/plugin-client-common`
- `react-webpack-build-helper`
- `timer-react-dev-utils`
- `react-native-macos`
- `@axio/react-dev-utils`
- `react-dev-utils-extra`
- `webpack-isomorphic-dev-middleware`
- `ansi-html-themed`
- `webpack-isomorphic-dev-middleware`
- `react-native-okhttp-fork`
- `uyun-react-dev-utils`
- `ipynb2html-fix`
- `react-dev-utils-sebfl-update`
- `@jjavery/react-error-overlay`
- `lambda-dev-utils`
- `ipynb2html`
- `react-error-overlay-canary`
Expand All @@ -464,7 +373,6 @@ If you are using this library in one of your projects, add it in this list. :spa
- `native-kakao-login`
- `linklog`
- `react-native-ytximkit`
- `@mindinventory/rn-top-navbar`
- `cycle-dev-utils`
- `@viankakrisna/react-error-overlay`
- `callstack-task-react-dev-utils`
Expand All @@ -474,32 +382,38 @@ If you are using this library in one of your projects, add it in this list. :spa
- `@hemith/react-native-tnk`
- `react-native-contact-list`
- `react-native-is7`
- `@nib/e2e-core`
- `react-native-biometric-authenticate`
- `react-native-tvos-nz`
- `@mindinventory/rn-top-navbar`
- `rn-adyen-dropin`
- `@classyllama/code-style`
- `react-native-ansi-view`
- `@corelmax/react-native-my2c2p-sdk`
- `@proteria/react-scripts`
- `@prague-digi/react-error-overlay`
- `native-apple-login`
- `react-ansi`
- `rn-custom-tabview`
- `@felipesimmi/react-native-datalogic-module`
- `@blkmarketco/components-library`
- `@datalogic/react-native-datalogic-module`
- `ansi-to-react-with-options`
- `callstack-task-react-error-overlay`
- `@datalogic/react-native-datalogic-module`
- `@tasumaniadiabori/react-native-draggable-flatlist`
- `react-native-flyy`
- `@prague-digi/react-error-overlay`
- `@geeky-apo/react-native-advanced-clipboard`
- `@apardellass/react-native-audio-stream`
- `kunai`
- `react-native-responsive-size`
- `singularityui-tailer`
- `rn-flatlist-fork`
- `@unforgiven/react-native`
- `ansi-to-react-with-classes`
- `react-native-dsphoto-module`
- `react-native-tvos`
- `react-error-guard`
- `react-native-sayhello-module`
- `@plansys/react-dev-utils`
- `singularityui-tailer`
- `react-native-tvos`
- `@saad27/react-native-bottom-tab-tour`
- `react-native-plugpag-wrapper`
- `react-native-pulsator-native`
- `react-native-hlf-wrapper`
Expand All @@ -510,6 +424,7 @@ If you are using this library in one of your projects, add it in this list. :spa
- `@ehyland-org/react-error-overlay`
- `@naze/error`
- `ada-pack`
- `@jjavery/react-error-overlay`
- `@office-iss/react-native-win32`
- `react-native-sf`
- `native-google-login`
Expand All @@ -521,6 +436,7 @@ If you are using this library in one of your projects, add it in this list. :spa
- `react-native-modal-progress-bar`
- `stack-frame-overlay`
- `@digibear/socket-bridge`
- `userfetch`



Expand Down
3 changes: 2 additions & 1 deletion lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -178,8 +178,9 @@ class Anser {
* @returns {String} The escpaed HTML output.
*/
escapeForHtml (txt) {
return txt.replace(/[&<>]/gm, str =>
return txt.replace(/[&<>\"]/gm, str =>
str == "&" ? "&amp;" :
str == '"' ? "&quot;" :
str == "<" ? "&lt;" :
str == ">" ? "&gt;" : ""
);
Expand Down
Loading