Have ideas to improve npm?Join in the discussion! ยป

    remark-code-import

    0.3.0ย โ€ขย Publicย โ€ขย Published

    remark-code-import

    ๐Ÿ“ Populate code blocks from files

    npm version

    The plain remark version of gatsby-remark-import-code.

    Installation

    # npm
    npm install -D remark-code-import
    
    # yarn
    yarn add -D remark-code-import

    Setup

    See Using plugins in the official documentation.

    It can also be used in various of libraries using remark: MDX, Gatsby gatsby-plugin-mdx, Storybook docs, etc.

    Use as Gatsby remark plugin

    Just use the /gatsby endpoint. It's possible through to-gatsby-remark-plugin.

    {
      resolve: 'remark-code-import/gatsby',
      options: {}
    }

    Usage

    Transform:

    ```js file=./say-hi.js
    ```

    into:

    ```js file=./say-hi.js
    console.log('Hello remark-code-import!');
    ```

    The file path is relative to the markdown file path.

    You may also specify specific lines or ranges:

    ```js file=./say-hi.js#L3
    ```
    
    ```js file=./say-hi.js#L3-L6
    ```
    
    ```js file=./say-hi.js#L3-
    ```

    Options

    • async: By default, this plugin uses readFileSync to read the contents of the files. Set this to true if you want to use readFile for non-blocking IO.

    Testing

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

    License

    Kai Hao MIT

    Install

    npm i remark-code-import

    DownloadsWeekly Downloads

    1,504

    Version

    0.3.0

    License

    MIT

    Unpacked Size

    6.12 kB

    Total Files

    6

    Last publish

    Collaborators

    • avatar