Skip to main content

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

PackageNPMPlatformModule Type
markuplintnpm versionNode.jsESM
@markuplint/html-parsernpm versionUniversalESM
@markuplint/html-specnpm versionUniversalCommonJS
@markuplint/i18nnpm versionUniversalHybrid
@markuplint/ml-astnpm versionUniversalESM
@markuplint/ml-confignpm versionUniversalESM
@markuplint/ml-corenpm versionUniversalESM
@markuplint/ml-specnpm versionUniversalESM
@markuplint/parser-utilsnpm versionUniversalESM
@markuplint/rulesnpm versionUniversalESM
@markuplint/typesnpm versionUniversalESM

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.