# remark-code-titles

> Remark plugin to add title to code block

Latest version **0.1.2** (published 2021-05-01) · MIT license · 0 weekly downloads

## Install

```sh
npm install remark-code-titles
pnpm add remark-code-titles
yarn add remark-code-titles
bun add remark-code-titles
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.1.2 |
| Published | 2021-05-01 |
| First published | 2019-02-02 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 2 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 16 |
| Author | mottox2 |
| Maintainers | mottox2 |

## Links

- npm: https://www.npmjs.com/package/remark-code-titles
- Repository: https://github.com/mottox2/remark-code-titles
- npm.io page: https://npm.io/package/remark-code-titles

## Dependencies (1)

- [unist-util-visit](https://npm.io/package/unist-util-visit.md) ^1.4.0

## Recent versions

- 0.1.2 (latest) — 2021-05-01
- 0.1.1 — 2019-02-02
- 0.1.0 — 2019-02-02

## README

# remark-code-titles

[![npm version](https://badge.fury.io/js/remark-code-titles.svg)](https://badge.fury.io/js/remark-code-titles)

[Remark](https://github.com/remarkjs/remark) plugin to add code title inspired by [gatsby-remark-code-titles](https://github.com/DSchau/gatsby-remark-code-titles)

## Usage

We have the following file, `hello.md`:

~~~markdown
# Hello World

```js:hello.js
console.log('js')
```
~~~

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

```js:sample.js
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:

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

---
_Source: https://npm.io/package/remark-code-titles · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
