包详细信息

simple-code-frame

marvinhagemeister214kMIT1.3.0

A tiny utility to create code frames

自述文件

simple-code-frame

Tiny library for displaying code frames. The main difference to @babel/code-frame is that this library doesn't ship with a parser. It is soley aimed at taking text input and adding column + line markers.

Usage

npm install simple-code-frame
# or via yarn
yarn add simple-code-frame

Usage

import { createCodeFrame } from 'simple-code-frame';

const str = `foo\nbar\nbob`;

const codeFrame = createCodeFrame(str, 1, 2);
console.log(codeFrame);
// Logs:
//   1 | foo
// > 2 | bar
//     |  ^
//   3 | bob

License

MIT, see the license file.

更新日志

simple-code-frame

1.3.0

Minor Changes

  • 7dc1757: - Update design to make it a little more visually pleasing.
    • Add option to override those characters

Patch Changes

  • dd1f262: Update dependencies
  • 1f0a049: Add missing types to export field

1.2.0

Minor Changes

  • c968229: Add support for setting maxWidth to control the width of the code frame. All lines that are longer will have ellipsis applied.