API
Basic Usage
import { MLEngine } from 'markuplint';
const file = await MLEngine.toMLFile('./path/to/page.html');
const engine = new MLEngine(file, {
configFile: './path/to/.markuplintrc',
});
engine.on('log', (id, message) => {
console.log(id, message);
});
const result = await engine.exec();
console.log(result.violations);
Packages
Package | NPM | Platform | Module Type |
---|---|---|---|
markuplint | Node.js | ESM | |
@markuplint/html-parser | Universal | ESM | |
@markuplint/html-spec | Universal | CommonJS | |
@markuplint/i18n | Universal | Hybrid | |
@markuplint/ml-ast | Universal | ESM | |
@markuplint/ml-config | Universal | ESM | |
@markuplint/ml-core | Universal | ESM | |
@markuplint/ml-spec | Universal | ESM | |
@markuplint/parser-utils | Universal | ESM | |
@markuplint/rules | Universal | ESM | |
@markuplint/types | Universal | ESM |
Using with CommonJS
markuplint
is an ESM (ECMAScript Module). Normally, it can't be used in a CommonJS ecosystem. To use the API from CommonJS, you use @markuplint/esm-adapter.
const { MLEngine } = require('@markuplint/esm-adapter');
const result = await MLEngine.fromCode(htmlCode);
console.log(result);
info
@markuplint/esm-adapter
was created specifically for VS Code extensions that do not support ESM. Because of this, the implemented APIs are extremely limited if you are not using them within an extension.
Additionally, it internally uses Worker threads, so it only works on the Node.js platform.
warning
@markuplint/esm-adapter
is supported only on Node.js versions below 22.