🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
Book a DemoInstallSign in
Socket

@builds-dev/gfmjs

Package Overview
Dependencies
Maintainers
2
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@builds-dev/gfmjs

JavaScript test runner for GitHub Flavored Markdown files

2.0.0
latest
Source
npm
Version published
Maintainers
2
Created
Source

gfmjs

gfmjs is a JavaScript test runner for GitHub Flavored Markdown files. It extracts JavaScript code blocks, transforms // => expected style comments into actual assertions, and executes the code, reporting syntax errors, runtime errors, and failed assertions.

Inspired by jsmd.

features

Single-line // => expected and Block/Multi-line comments /* => expected */. are supported. Newlines, extra lines, and spaces are fine.

const x = 123

x // => 123

x
// => 123

x
/*
	=>
		123
*/

Any expression should work as an expected value.

const expected = [ 1, 2, 3 ]
const foo = value => {
	value // => expected.shift()
}
foo(1)
foo(2)
foo(3)

It has a sourcemap back to the original markdown file so errors should include the original location.

As of v2, code will be interpreted as an ES module entrypoint, so use import rather than require. Use createRequire if needed.

usage

$ gfmjs ./README.md
# write the javascript bundle to a file
$ gfmjs -o ./build/README.js ./README.md

Code blocks that are tagged as js or javascript will be evaluated.

```js
	// code here
```
```javascript
	// code here
```

You can also make hidden code blocks that will be evaluated by using html comments tagged in the same manner:

<!--js
	// code here
-->

If you want to write visible javascript code blocks that won't be evaluated but will be styled, tag them as node:

```node
	// code here
```

Keywords

readme

FAQs

Package last updated on 13 Jun 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts