cli-html
Version:
Render HTML to Terminal
24 lines (20 loc) • 563 B
JavaScript
import ansiAlign from 'ansi-align';
import boxen from 'boxen';
import { blockTag } from '../tag-helpers/block-tag.js';
export const figure = (tag, context) => blockTag(
(value) => {
const valueInBox = boxen(ansiAlign(value, { align: 'center' }), {
padding: {
top: 0,
bottom: 0,
left: 1,
right: 1,
},
borderColor: 'gray',
dimBorder: false,
borderStyle: 'round',
});
return valueInBox;
},
{ marginTop: 1, marginBottom: 1 },
)(tag, { ...context, lineWidth: context.lineWidth - 4 });