How to use the anser.ansiToJson function in anser

To help you get started, we’ve selected a few anser examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github facebookarchive / atom-ide-ui / modules / nuclide-commons-ui / Ansi.js View on Github external
function ansiToJSON(input, useClasses) {
  const classes = useClasses == null || !useClasses ? false : useClasses;
  return Anser.ansiToJson(escapeCarriageReturn(input), {
    use_classes: classes,
    json: true,
    remove_empty: true,
  });
}
github nteract / nteract / packages / ansi-to-react / src / index.js View on Github external
function ansiToJSON(input) {
  input = escapeCarriageReturn(input);
  return ansiToJson(input, {
    json: true,
    remove_empty: true
  });
}
github expo / expo-cli / packages / dev-tools / components / Log.js View on Github external
renderMessageContent({ msg, level }) {
    if (!hasAnsi(msg)) {
      return (
        <div>
          {msg}
        </div>
      );
    }
    const chunks = ansiToJson(msg, {
      remove_empty: true,
    });
    const content = chunks.map(chunk =&gt; {
      const style = {};
      if (chunk.bg) {
        style.backgroundColor = Constants.ansiColorOverrides[chunk.bg] || `rgb(${chunk.bg})`;
      }
      if (chunk.fg) {
        style.color = Constants.ansiColorOverrides[chunk.fg] || `rgb(${chunk.fg})`;
      }
      return <span style="{style}">{chunk.content}</span>;
    });
    return <div>{content}</div>;
  }
github nteract / nteract / packages / ansi-to-react / src / index.ts View on Github external
function ansiToJSON(input: string, use_classes = false) {
  input = escapeCarriageReturn(input);
  return Anser.ansiToJson(input, {
    json: true,
    remove_empty: true,
    use_classes
  });
}
github goodrain / rainbond-ui / src / components / Ansi / index.ts View on Github external
function ansiToJSON(input: string) {
  input = escapeCarriageReturn(input);
  return ansiToJson(input, {
    json: true,
    remove_empty: true
  });
}
github HubSpot / Singularity / SingularityUI / SingularityTailer / src / selectors / index.js View on Github external
const ansiEnhancer = (line) => {
  return Anser.ansiToJson(
    line.text,
    { use_classes: true }
  ).map((p) => {
    const { content, fg, bg, decoration } = p;
    const classes = classNames({
      [`${fg}`]: !!fg,
      [`${bg}-bg`]: bg,
      [`ansi-${decoration}`]: decoration
    });

    return {
      content,
      classes
    };
  });
};

anser

A low level parser for ANSI sequences.

MIT
Latest version published 1 month ago

Package Health Score

85 / 100
Full package analysis