Naboo's Podracing Misadventure

    remark-code-titles

    0.1.2 • Public • Published

    remark-code-titles

    npm version

    Remark plugin to add code title inspired by gatsby-remark-code-titles

    Usage

    We have the following file, hello.md:

    # Hello World
    
    ```js:hello.js
    console.log('js')
    ```

    And our script, hello.js, lokks as follows:

    const vfile = require('to-vfile')
    const unified = require('unified')
    const parse = require('remark-parse')
    const codeTitle = require('remark-code-titles')
    const html = require('remark-html')
    
    const result = unified()
      .use(parse)
      .use(codeTitle)
      .use(html)
      .process(vfile.readSync('./hello.md'), (err, file) => {
        if (err) throw err
        console.log(String(file))
      })

    Now, running node hello.js yields:

    <h1>Hello World</h1>
    <div class="remark-code-title">hello.js</div>
    <pre><code class="language-js">console.log('js')
    </code></pre>

    Keywords

    none

    Install

    npm i remark-code-titles

    DownloadsWeekly Downloads

    2,724

    Version

    0.1.2

    License

    MIT

    Unpacked Size

    2.04 kB

    Total Files

    4

    Last publish

    Collaborators

    • mottox2