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

0.1.5 • Public • Published

remark-code-title

preview badge

Remark plugin to add a title to code blocks.

Inspired by:

Demos

Astro Next.js
 Open in StackBlitz  Open in StackBlitz

Installation

npm install remark-code-title

Usage

Given this markdown file example.md:

# Example

```js title="example.js"
console.log("Hello World");
```

And this script, example.js, using remark-code-title:

import codeTitle from "remark-code-title";
import html from "remark-html";
import { read } from "to-vfile";
import { remark } from "remark";

const processor = remark().use(codeTitle).use(html, { sanitize: false });
const markdown = await read("example.md");
const result = await processor.process(markdown);

Running node example.js yields:

<h1>Example</h1>
<div data-remark-code-title data-language="js">example.js</div>
<pre>
  <code>console.log("Hello World");</code>
</pre>

Package Sidebar

Install

npm i remark-code-title-polyfill

Weekly Downloads

15

Version

0.1.5

License

MIT

Unpacked Size

4.81 kB

Total Files

5

Last publish

Collaborators

  • sbin0819