npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@it-service-npm/remark-include

v5.0.1

Published

Add transclusion recursive ability `::include{file=other-file.md}`.

Readme

@it-service-npm/remark-include Remark plugin

GitHub release NPM release Node version Dependencies status Install size

CI Status Tests Results Coverage status

Semantic Versioning Conventional Commits semantic-release: angular PRs Welcome

VS Code TypeScript EditorConfig ESLint

With this plugin, you can use ::include{file=./included.md} GitLab transclusion syntax statements to compose markdown files together.

Additional features:

  • GitLab include directives inside the included file are ignored, but this plugin support recursive transclusion
  • It is possible to use globs (::include{file=./included*.md}) in file attribute
  • New attribute optional, which disable fatal directive error when file does not exists
  • Relative images and links in the imported files will have their paths rewritten to be relative the original document rather than the imported file (with @it-service-npm/remark-relative-url-adjustment)
  • An imported markdown file will “inherit” the heading levels. If the ::include{file=./included.md} statement happens under Heading 2, for example, any heading 1 in the included file will be “translated” to have header level 3 (with @it-service-npm/remark-heading-adjustment)

This plugin is a modern version of remark-import plugin and remark-include plugin, written in Typescript, and compatible with Remark v15.

There are two plugins: remarkInclude (preferred) and remarkIncludeSync.

[!IMPORTANT] remark-directive plugin expected before @it-service-npm/remark-include.

This package provides two plugins presets:

  • remarkIncludePreset. This preset contains:

    • remarkInclude
    • remarkDirective
    • remarkHeadingsAdjustment
    • remarkRelativeUrlsAdjustment
    • remarkRelativeCodePathsAdjustment
  • remarkIncludePresetSync. This preset contains:

    • remarkIncludeSync
    • remarkDirective
    • remarkHeadingsAdjustment
    • remarkRelativeUrlsAdjustment
    • remarkRelativeCodePathsAdjustment

Contents

Install

npm install --save-dev @it-service-npm/remark-include

Examples

Transclusion or including markdown sub-documents for reuse

@it-service-npm/remark-include can include sub-documents in markdown document.

import { remark } from 'remark';
import * as vFile from 'to-vfile';
import { remarkIncludePresetSync } from '@it-service-npm/remark-include';
import type { VFile } from 'vfile';

export async function remarkDirectiveUsingExample(
  filePath: string
): Promise<VFile> {
  return remark()
    .use(remarkIncludePresetSync)
    .process(await vFile.read(filePath));
};

Source files:

main.md:

Hello. I am an main markdown file with `::include` directive.

::include{file=./included.md}

_That_ should do it!

included.md:

Hello. I am the included.

Remark output:

Hello. I am an main markdown file with `::include` directive.

Hello. I am the included.

*That* should do it!

Recursive transclusion

@it-service-npm/remark-include directive supported in included files.

Source files:

main.md:

Hello. I am an main markdown file with `::include` directive.

::include{file=./included1.md}

_That_ should do it!

included1.md:

Hello. I am the included1.

::include{file=./included2.md}

included2.md:

Hello. I am the included2.

Remark output:

Hello. I am an main markdown file with `::include` directive.

Hello. I am the included1.

Hello. I am the included2.

*That* should do it!

Adjust the heading levels

@it-service-npm/remark-include adjust the heading levels within the included content.

Source files:

main.md:

# Main file

Hello. I am an main markdown file with `::include` directive.

::include{file=./included1.md}

## in main file

_That_ should do it!

included1.md:

# included1 file

Hello. I am the included1.

## in included1 file

::include{file=./included2.md}

## in included 1 file after included2

text text text.

included2.md:

# included2 file

Hello. I am the included2.

Remark output:

# Main file

Hello. I am an main markdown file with `::include` directive.

## included1 file

Hello. I am the included1.

### in included1 file

#### included2 file

Hello. I am the included2.

### in included 1 file after included2

text text text.

## in main file

*That* should do it!

Include multiple files with glob

@it-service-npm/remark-include support glob as file attribute value.

Source files:

main.md:

# main file

Hello. I am an main markdown file with `::include` directive.

::include{file=./included*.md}

_That_ should do it!

included1.md:

# included 1

Hello. I am the included1.

included2.md:

# included 2

Hello. I am the included2.

included3.md:

# included 3

Hello. I am the included3.

Remark output:

# main file

Hello. I am an main markdown file with `::include` directive.

## included 1

Hello. I am the included1.

## included 2

Hello. I am the included2.

## included 3

Hello. I am the included3.

*That* should do it!

Updating relative path for links, images

Relative images and links in the imported files will have their paths rewritten to be relative the original document rather than the imported file.

Source files:

main.md:

Hello. I am an main markdown file with `::include` directive.

::include{file=./subfolder1/included.md}

_That_ should do it!

included.md:

Hello. I am the included. Test image:

![Test local image](test-image.png)

![Test local image with space](test%20image.png)

![Test web image](https://img.shields.io/badge/github-repo-blue?logo=github)

Remark output:

Hello. I am an main markdown file with `::include` directive.

Hello. I am the included. Test image:

![Test local image](subfolder1/test-image.png)

![Test local image with space](subfolder1/test%20image.png)

![Test web image](https://img.shields.io/badge/github-repo-blue?logo=github)

*That* should do it!

Updating relative path for code files

Relative images and links in the imported files will have their paths rewritten to be relative the original document rather than the imported file.

Source files:

main.md:

Hello. I am an main markdown file with `::include` directive.

::include{file=./subfolder1/included.md}

_That_ should do it!

included.md:

Hello. I am the included. Test for code file path rebasing:

```typescript file=../../example.ts
import { remark } from 'remark';
import * as vFile from 'to-vfile';
import remarkDirective from 'remark-directive';
import { remarkInclude } from '@it-service-npm/remark-include';
import type { VFile } from 'vfile';

export async function remarkDirectiveUsingExample(
  filePath: string
): Promise<VFile> {
  return remark()
    .use(remarkDirective)
    .use(remarkInclude)
    .process(await vFile.read(filePath));
};

```

Code with file path with spaces and lines range:

```typescript file=code\ with\ spaces.ts#L11-L15
  return remark()
    .use(remarkDirective)
    .use([codeImport])
    .use(remarkInclude)
    .process(await vFile.read(filePath));
```

And code without file attribute:

```typescript
import { remark } from 'remark';
import * as vFile from 'to-vfile';
import remarkDirective from 'remark-directive';
import { remarkInclude } from '@it-service-npm/remark-include';
import type { VFile } from 'vfile';
```

Remark output:

Hello. I am an main markdown file with `::include` directive.

Hello. I am the included. Test for code file path rebasing:

```typescript file=../example.ts
import { remark } from 'remark';
import * as vFile from 'to-vfile';
import remarkDirective from 'remark-directive';
import { remarkInclude } from '@it-service-npm/remark-include';
import type { VFile } from 'vfile';

export async function remarkDirectiveUsingExample(
  filePath: string
): Promise<VFile> {
  return remark()
    .use(remarkDirective)
    .use(remarkInclude)
    .process(await vFile.read(filePath));
};

```

Code with file path with spaces and lines range:

```typescript file=subfolder1/code\ with\ spaces.ts#L11-L15
  return remark()
    .use(remarkDirective)
    .use([codeImport])
    .use(remarkInclude)
    .process(await vFile.read(filePath));
```

And code without file attribute:

```typescript
import { remark } from 'remark';
import * as vFile from 'to-vfile';
import remarkDirective from 'remark-directive';
import { remarkInclude } from '@it-service-npm/remark-include';
import type { VFile } from 'vfile';
```

*That* should do it!

API

Please, read the API reference.

License

MIT © Sergei S. Betke