Giter Club home page Giter Club logo

code-blocks's Introduction

@code-blocks

Use markdown code blocks to render:

and highlight code.

@code-blocks can be used either as a rehype transform or as an eleventy plugin.

Example

A code block with music-abc as language and the following content:

DDAA|BBA2|

will be rendered as:

Music sheet example

Usage with rehype

Install the transform:

npm install @code-blocks/rehype-transform --save

Install the renderers you need, for example:

npm install @code-blocks/charts --save

An use it:

const unified = require('unified')
const stream = require('unified-stream')
const markdown = require('remark-parse')
const remark2rehype = require('remark-rehype')
const html = require('rehype-stringify')

// the rehype transform
const codeblocks = require('@code-blocks/rehype-transform')

// some renderers
const charts = require('@code-blocks/charts')
const graphviz = require('@code-blocks/graphviz')

const processor = unified()
  .use(markdown)
  .use(remark2rehype)
  // add the transform and the renderers in an array as options
  .use(codeblocks, [charts, graphviz])
  .use(html)

process.stdin.pipe(stream(processor)).pipe(process.stdout)

Usage with eleventy

Install the plugin:

npm install @code-blocks/eleventy-plugin --save

Install the renderers you need, for example:

npm install @code-blocks/music --save

In the .eleventy.js configuration file:

// the plugin
const codeblocks = require('@code-blocks/eleventy-plugin')

// some renderers
const math = require('@code-blocks/math')
const music = require('@code-blocks/music')

module.exports = function(eleventyConfig) {
  // pass the renderers to the plugin
  eleventyConfig.addPlugin(codeblocks([
    math,
    music,
  ]))
}

code-blocks's People

Contributors

dependabot[bot] avatar idris-maps avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

alangreene

code-blocks's Issues

Trying to use it in markdown.

So I have installed it as said in the readme.md but I don't understand what syntax is meant to be used in the markdown files.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.