markuplint
Version:
A Linter for All Markup Languages.
36 lines (35 loc) • 1.24 kB
JavaScript
;
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.invisibleSpace = exports.space = exports.w = exports.p = exports.markuplint = void 0;
const cli_color_1 = __importDefault(require("cli-color"));
// @ts-ignore
const eastasianwidth_1 = __importDefault(require("eastasianwidth"));
exports.markuplint = `markup${cli_color_1.default.xterm(39)('lint')}`;
const eaw = eastasianwidth_1.default;
function p(s, pad, start = false) {
const l = w(`${s}`.trim());
const d = pad - l;
const _ = ' '.repeat(d < 0 ? 0 : d);
return start ? `${_}${s}` : `${s}${_}`;
}
exports.p = p;
function w(s) {
return s.replace(/./g, _ => '0'.repeat(eaw.characterLength(_))).length;
}
exports.w = w;
function space(str) {
return str
.replace(/\s+/g, $0 => {
return cli_color_1.default.xterm(8)($0);
})
.replace(/ /g, $0 => '•')
.replace(/\t/g, $0 => '→ ');
}
exports.space = space;
function invisibleSpace(str) {
return str.replace(/\t/g, $0 => ' ').replace(/./g, $0 => ' ');
}
exports.invisibleSpace = invisibleSpace;