Skip to content

marked.js plugin to extend the code blocks with attributes and render the execution results

Notifications You must be signed in to change notification settings

murabi-io/marked-code-chunks

Repository files navigation

marked-code-chunks

Make your Markdown code blocks executable

marked-code-chunks Coverage Status

Marked extension to add code chunk metadata to the markdown fenced code blocks. e.g.

~~~bash {osx bin=/bin/bash}
ls -l ./
~~~
  • tokenizer will extract attributes osx=true and bin="/bin/bash""
  • renderer will render the code block with attributes: data-osx="true" and data-bin="/bin/bash"

Development & Contribution

Check out our Contributing Guidelines and Code of Conduct.

Getting started

  1. git clone git@github.com:murabi-io/marked-code-chunks.git
  2. cd my-project
  3. npm install
  4. npm run setup

Features

Node.js, npm version

Repository relies on volta to ensure node version to be consistent across developers. It's also used in the GitHub workflow file.

Typescript

Leverages esbuild for blazing fast builds, but keeps tsc to generate .d.ts files. Generates two builds to support both ESM and CJS.

Commands:

  • build: runs typechecking then generates CJS, ESM and d.ts files in the build/ directory
  • clean: removes the build/ directory
  • type:dts: only generates d.ts
  • type:check: only run typechecking
  • type:build: only generates CJS and ESM

Tests

We use jest.

Commands:

  • test: runs jest test runner
  • test:watch: runs jest test runner in watch mode
  • test:coverage: runs jest test runner and generates coverage reports

Format & lint

This template relies on the combination of eslint — through typescript-eslint for linting and prettier for formatting. It also uses cspell to ensure spelling

Commands:

  • format: runs prettier with automatic fixing
  • format:check: runs prettier without automatic fixing (used in CI)
  • lint: runs eslint with automatic fixing
  • lint:check: runs eslint without automatic fixing (used in CI)
  • spell:check: runs spellchecking

Releasing

Under the hood, this library uses semantic-release and commitizen. The goal is to avoid manual release process. Using semantic-release will automatically create a github release (hence tags) as well as an npm release. Based on your commit history, semantic-release will automatically create a patch, feature or breaking release.

Commands:

  • cz: interactive CLI that helps you generate a proper git commit message, using commitizen
  • semantic-release: triggers a release (used in CI)

About

marked.js plugin to extend the code blocks with attributes and render the execution results

Topics

Resources

Code of conduct

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published