npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

markcheck

v1.0.0

Published

* Markcheck tests Markdown code blocks – to prevent errors in documentation (readmes, blogs, books, etc.). * Name of npm package: [`markcheck`](https://www.npmjs.com/package/markcheck)

Downloads

34

Readme

Markcheck

  • Markcheck tests Markdown code blocks – to prevent errors in documentation (readmes, blogs, books, etc.).
  • Name of npm package: markcheck

Why Markcheck?

Highlights:

  • Uses normal Markdown syntax – not a custom version of it: Everything custom happens inside Markdown comments.

  • No external files: The Markdown file contains all the information that is needed to run it: Configuration files, demo text files, etc. can all be embedded in Markdown.

    • Exception: Some data remains external – e.g. npm packages used by JavaScript code.
  • Works for most programming languages: The only requirement is that there is a shell command that runs text files with the language’s code. See demo/demo-bash.md for an example of testing a programming language that Markcheck has no built-in support for.

  • Successfully used in a big project: I tested almost all of the code shown in my book “JavaScript for impatient programmers”. Its PDF has 639 pages.

  • Provides versatile tools for checking code: Human readers of the published Markdown never see the complexity that is occasionally needed to make code blocks testable. These are some of the tools at our disposal – they can all be used from within Markdown files:

    • Check stderr and/or stdout.
    • Concatenate code blocks in any order.
    • Use code hidden from readers.
    • Write arbitrary text files to disk (example files, config files, etc.).
    • Etc.

Checking JavaScript is reasonably fast:

  • Checking all the examples in “JavaScript for impatient programmers” takes 50 seconds on a MacBook Pro with an M1 Pro processor. There is a lot of code in this book.
  • Checking one of the longer chapters takes 5 seconds.

Caveats:

  • Only tested on macOS. I used cross-platform mechanisms where I could but I don’t know if Markcheck works on Windows. Please let me know either way.
  • ⚠️ There is currently no sandboxing of any kind: Only use Markcheck with files you trust.
  • Checking TypeScript code:
    • Downside: slow
    • Upside: You can write very expressive code that works well for explaining language mechanisms. See demo/demo-typescript.md for more information.

What does Markcheck’s syntax look like?

The following subsections contain three examples. For more examples, see the quick start part of Markcheck’s manual.

Checking basic code blocks

```js
assert.equal(
  'abc' + 'abc',
  'abcabc'
);
```

No additional configuration is needed: The Node.js assert.* methods are available by default.

Checking standard output via stdout

<!--markcheck stdout="stdout-hello"-->
```js
console.log('Hello!');
```

<!--markcheck id="stdout-hello"-->
```
Hello!
```

Hiding code via before:

<!--markcheck before:
function functionThatShouldThrow() {
  throw new Error();
}
-->
```js
try {
  functionThatShouldThrow();
  assert.fail();
} catch (_) {
  // Success
}
```

More information on Markcheck

Donations

I have rewritten Markcheck several times over the years, until I arrived at the current version. If you find this tool or any of my other free work useful, I would appreciate a donation: