simple-code-frame

A tiny utility to create code frames

MIT 5 个版本
安装
npm install simple-code-frame
yarn add simple-code-frame
pnpm add simple-code-frame
bun add simple-code-frame
README

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.

版本列表
1.3.0 2023-01-25
1.2.0 2021-09-05
1.1.1 2021-04-01
1.1.0 2021-04-01
1.0.0 2020-07-04