remark-code-github
TypeScript icon, indicating that this package has built-in type declarations

0.2.1 • Public • Published

remark-code-github

Populate code blocks from GitHub

Inspired by remark-code-import

Installation

# npm
npm install -D remark-code-github

# yarn
yarn add -D remark-code-github

Setup

See Using plugins in the official documentation.

Usage

Transform:

```js raw_url=https://raw.githubusercontent.com/remarkjs/remark/main/packages/remark/index.js
```

into:

```js
import {unified} from 'unified'
import remarkParse from 'remark-parse'
import remarkStringify from 'remark-stringify'

export const remark = unified().use(remarkParse).use(remarkStringify).freeze()
```

The raw_url is URL of plain text content.

You may also specify specific lines or ranges:

```js file=https://raw.githubusercontent.com/remarkjs/remark/main/packages/remark/index.js#L3
```

```js file=https://raw.githubusercontent.com/remarkjs/remark/main/packages/remark/index.js#L3-L5
```

```js file=https://raw.githubusercontent.com/remarkjs/remark/main/packages/remark/index.js#L3-
```

Options

  • preserveTrailingNewline: By default, this plugin will trim the trailing newline of the file when importing the code. You can preserve the trailing new line in the code block by setting this option to true.

Testing

After installing dependencies with npm install, the tests can be run with: npm test

License

fossamagna MIT

Package Sidebar

Install

npm i remark-code-github

Weekly Downloads

10

Version

0.2.1

License

MIT

Unpacked Size

29.8 kB

Total Files

18

Last publish

Collaborators

  • fossamagna