@karuga/remark-include_
include other markdown content into an mdast / remark document
Last updated 2 months ago by karuga .
ISC · Original npm · Tarball · package.json
$ cnpm install @karuga/remark-include_ 
SYNC missed versions from official npm registry.

remark-include

@include directives for remark / mdast

features:

  • recursive includes (include a file which in turn includes another file)
  • include patterns (@include mydir/*.md will include all matching files)

downsides:

  • this operates after parsing is done
  • syntax restrictions (e.g. there must be blank lines before and after a block of imports)

alternatives (remark-based):

usage

simple imports:

@import foo.md
@import bar/baz.md

wildcard imports:

<!-- prettier-ignore-start -->

@import bar/*.md

<!-- prettier-ignore-end -->

note: code formatters (like prettier) may have to be disabled (e.g. to prevent replacing * with \*):

using the remark plugin:

const { remarkInclude } = require("@karuga/remark-include");

const processor = remark().use(remarkInclude);

const input = "@include foo.md";
const output = (await processor.process(input)).toString();
// output will be the contents of foo.md

using the mdast transformer:

const { mdastInclude } = require("@karuga/remark-include");

const input = {
  type: "root",
  children: [
    { type: "paragraph" /*...*/ }
    /*...*/
  ]
};
const output = await mdastInclude(input);

Current Tags

  • 0.3.5                                ...           latest (2 months ago)

1 Versions

  • 0.3.5                                ...           2 months ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 1
Last Month 1
Dependencies (4)
Dev Dependencies (3)
Dependents (0)
None

Copyright 2014 - 2016 © taobao.org |