@karuga/remark-include
Transform @include statements to contents
Last updated 23 days ago by karuga .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install @karuga/remark-include 
SYNC missed versions from official npm registry.

remark-include

With remark-include, you can use @include statements to compose markdown files together.

This repository is based on https://github.com/Qard/remark-include. Compared to the original additionally supports glob patterns and has fixed tests.

Installation

npm install @karuga/remark-include

Example

const unified = require('unified');
const remarkParse = require('remark-parse');
const remarkInclude = require('@karuga/remark-include');
const remarkStringify = require('remark-stringify');

const processor = unified()
  .use(remarkParse)
  .use(remarkInclude, { cwd: __dirname, glob: true, escaped: true })
  .use(remarkStringify);

const input = `
# My Memoirs

@include chapters/*.md
@include appendix.md
`;

const result = processor.processSync(input).toString();

Usage

Path resolution

The input can be either a string or a VFile

If the input is a VFile, includes will be relative to its location.

If the input is a string you can explicitly supply the base directory via use(remarkInclude, {cwd: "..."}).

If no directory is supplied the current working directory will be used.

Glob patterns

It is possible to use glob patterns to include multiple files (e.g. via @include chapters/*.md); to enable glob patterns, call use(remarkInclude, {glob: true})

Escaped paths

Formatters like prettier might escape characters inside an include statement, e.g. @include chapters/\*.md

To correct for these escapes, call use(remarkInclude, {escaped: true})

License (MIT)

Copyright (c) 2016 Stephen Belanger

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Current Tags

  • 0.5.0                                ...           latest (23 days ago)

17 Versions

  • 0.5.0                                ...           23 days ago
  • 0.4.4                                ...           2 months ago
  • 0.4.3                                ...           2 months ago
  • 0.4.2                                ...           2 months ago
  • 0.4.1                                ...           2 months ago
  • 0.4.0                                ...           2 months ago
  • 0.3.8                                ...           2 months ago
  • 0.3.7                                ...           2 months ago
  • 0.3.6                                ...           2 months ago
  • 0.3.5                                ...           2 months ago
  • 0.3.4                                ...           2 months ago
  • 0.3.3                                ...           2 months ago
  • 0.3.2                                ...           2 months ago
  • 0.3.1                                ...           2 months ago
  • 0.3.0                                ...           2 months ago
  • 0.2.1                                ...           2 months ago
  • 0.2.0                                ...           2 months ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 17
Last Month 41
Dependencies (2)
Dev Dependencies (4)

Copyright 2014 - 2016 © taobao.org |