md-verify
TypeScript icon, indicating that this package has built-in type declarations

1.0.0 • Public • Published

Get Started | md-verify

Verify markdown with rules.

example usage

Code Style: Prettier Github Actions: Build Passing TypeScript: Strict

Table of contents

What is md-verify?

md-verify matches a markdown input against defined rules. Fun fact: Rules are written in markdown.

Benefits / Usage of md-verify

You can verify pull request bodies if they match the defined template in your PULL_REQUEST_TEMPLATE.md file, etc.

Installation

For cli usage

npm install -g md-verify

For nodejs/browser usage.

npm install --save md-verify

CLI

The source is expected to be piped into the md-verify command.

  • From a file

      cat /path/to/file.md | npx md-verify@latest \
      --rule="# Heading" \
      -- rule="## H2 Heading" \
      -- rule="- List item"
  • From a string

      echo '# md file content...' | npx md-verify@latest \
      --rule="# Heading" \
      -- rule="## H2 Heading" \
      -- rule="- List item"

API

import fs from "fs";
import mdVerify, { VerifyError } from "md-verify";

try {
  let source = fs.readFileSync("/path/to/md/file").toString("binary");
  let rules = [
    "## PR Checklist",
    "# Get Started",
    "## Overview",
    "- Fish",
    "- [CONTRIBUTING.md](/link/to/contributing.md)",
  ];

  mdVerify(source, rules);
  // if no error - means the markdown matches the rules.
} catch (e: any) {
  console.log((e as VerifyError).errors);
}

Contributing

PRs are greatly appreciated.

  1. Create a fork
  2. Create your feature branch: git checkout -b my-feature
  3. Commit your changes: git commit -am 'Add some feature'
  4. Push to the branch: git push origin my-new-feature
  5. Submit a pull request 🚀

Issues

If you find a bug, please file an issue on the issue tracker.

Package Sidebar

Install

npm i md-verify

Weekly Downloads

1

Version

1.0.0

License

MIT

Unpacked Size

12.9 kB

Total Files

9

Last publish

Collaborators

  • fuadop