Code Monkey home page Code Monkey logo

markdown-it-checkbox's Introduction

markdown-it-checkbox

NPM version Build Status Coverage Status Dependency Status devDependency Status

Plugin to create checkboxes for markdown-it markdown parser.

This plugin allows to create checkboxes for tasklists as discussed here.

Usage

Install

node.js, browser:

npm install @gerhobbelt/markdown-it-checkbox --save

Use

var md = require('@gerhobbelt/markdown-it')()
            .use(require('@gerhobbelt/markdown-it-checkbox'));

md.render('[ ] unchecked') // =>
// <p>
//  <input type="checkbox" id="checkbox0">
//  <label for="checkbox0">unchecked</label>
// </p>

md.render('[x] checked') // =>
// <p>
//  <input type="checkbox" id="checkbox0" checked="">
//  <label for="checkbox0">checked</label>
// </p>

Differences in browser. If you load script directly into the page, without package system, module will add itself globally as window.markdownitCheckbox.

Options

var md = require('@gerhobbelt/markdown-it')()
            .use(require('@gerhobbelt/markdown-it-checkbox'),{
              divWrap: true,
              divClass: 'cb',
              idPrefix: 'cbx_',
              readonly: true
            });

md.render('[ ] unchecked') // =>
// <p>
//  <div classname="cb">
//    <input type="checkbox" id="cbx_0" readonly="">
//    <label for="cbx_0">unchecked</label>
//  </div>
// </p>

divWrap

  • Type: Boolean
  • Default: false

wrap div arround checkbox. this makes it possible to use it for example with Awesome Bootstrap Checkbox.

divClass

  • Type: String
  • Default: checkbox

classname of div wrapper. will only be used if divWrap is enanbled.

idPrefix

  • Type: String
  • Default: checkbox

the id of the checkboxs input contains the prefix and an incremental number starting with 0. i.e. checkbox1 for the 2nd checkbox.

readonly

  • Type: Boolean
  • Default: false

set the input to be readonly. this ensures that users cannot toggle the checkbox in the browser.

License

MIT License © 2015 Markus Cecot

markdown-it-checkbox's People

Contributors

digitalmoksha avatar felixexter avatar gerhobbelt avatar jlgfmhldf avatar suziwen avatar

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.