diff --git a/README.md b/README.md index 01797a119..8b0c90c9a 100644 --- a/README.md +++ b/README.md @@ -804,6 +804,31 @@ const results = lintSync({ "strings": { "content": original } }); const fixed = applyFixes(original, results.content); ``` +### Miscellaneous + +To get the [semantic version][semver] of the library, the `getVersion` method +can be used: + +```javascript +/** + * Gets the (semantic) version of the library. + * + * @returns {string} SemVer string. + */ +function getVersion() { ... } +``` + +Invoking `getVersion` is simple: + +```javascript +import { getVersion } from "markdownlint"; + +// Displays the library version +console.log(getVersion()); +``` + +[semver]: https://semver.org + ## Usage Invoke `lint` and use the `result` object's `toString` method: diff --git a/example/standalone.mjs b/example/standalone.mjs index a1eed89c1..2614e14bd 100644 --- a/example/standalone.mjs +++ b/example/standalone.mjs @@ -1,10 +1,13 @@ // @ts-check -import { applyFixes } from "markdownlint"; +import { applyFixes, getVersion } from "markdownlint"; import { lint as lintAsync } from "markdownlint/async"; import { lint as lintPromise } from "markdownlint/promise"; import { lint as lintSync } from "markdownlint/sync"; +// Displays the library version +console.log(getVersion()); + const options = { "files": [ "good.md", "bad.md" ], "strings": { diff --git a/test/markdownlint-test.mjs b/test/markdownlint-test.mjs index d37d9b4a6..96e0d49fd 100644 --- a/test/markdownlint-test.mjs +++ b/test/markdownlint-test.mjs @@ -692,6 +692,7 @@ test("readmeHeadings", (t) => new Promise((resolve) => { "#### callback", "#### result", "### Fixing", + "### Miscellaneous", "## Usage", "## Browser", "## Examples",