GithubHelp home page GithubHelp logo

endpass / markdown-it-include Goto Github PK

View Code? Open in Web Editor NEW

This project forked from camelaissani/markdown-it-include

0.0 1.0 0.0 172 KB

Markdown-it plugin which adds the ability to include markdown fragment files

License: MIT License

Makefile 23.72% JavaScript 76.28%

markdown-it-include's Introduction

markdown-it-include

Build Status Coverage Status

NPM

Markdown-it plugin which adds the ability to include markdown fragment files.

Install

node.js, browser:

npm install markdown-it-include --save
bower install markdown-it-include --save

Use

Let's create a markdown which uses a header and a footer from two separate files:

header.md

# This is my header for all my markdowns

footer.md

Follow me on twitter!

Let's assume that header.md and footer.md are located in /in/this/directory.

Now it's your turn to play markdown-it!

var md = require('markdown-it')()
            .use(require('markdown-it-include'), '/in/this/directory');

md.render('!!!include(header.md)!!!\n\n*your content*\n\n!!!include(footer.md)!!!');

It will produce this

<h1>This is my header for all my markdowns</h1>
<p><em>your content</em></p>
<p>Follow me on twitter!</p>

Options

var md = require('markdown-it')()
            .use(require('markdown-it-include'), [, options]);
  • Type: String|Object

If it's a string, it's the same as options.root.

root

  • Type: String
  • Default: .

root is the base directory of all the markdown files.

includeRe

  • Type: RegExp
  • Default: /\!{3}\s*include\s*\(\s*(.+?)\s*\)\s*\!{3}/i

By default the !!!include( )!!! statement is used to include markdown fragment files. This option allows to change the regular expression and then customize this statement.

Disclaimer

This purposefully doesn't conform to any spec or discussion related to CommonMark.

License

MIT

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.