rehype-meta-string
TypeScript icon, indicating that this package has built-in type declarations

0.0.4 • Public • Published

rehype-meta-string

Known Vulnerabilities Maintainability publish workflow license GitHub issues NPM bundle size(minified + gzip)

NPM

A rehype plugin for parsing the meta string of markdown code fence.

This plugin parse the meta string into key-value paris and assign them to code tag ast nodes.

The parsing contains rules below:

  • true: empty or literal value true is treated as true
  • false: literal value false is treated as false
  • word: literal string without spaces is treated as word.
  • sentence: double quoted, singled quoted, back-ticked string are treated as string.
  • range: square brackets wrapped string is treated as range numbers. It requires format like {digits}-{digits}.
  • mixed: mix all the markers above.

There is the illustration table:

meta string parsed
foo { foo: true }
foo=true { foo: false }

| | foo=false | { foo: false } | | | foo=bar | { foo: "bar" } | | | foo="false" | { foo: "false" } | | foo='false' | { foo: "false" } | | foo=`false` | { foo: "false" } | | foo="true" | { foo: "true" } | | foo='true' | { foo: "true" } | | foo=`true` | { foo: "true" } | | foo="bar baz" | { foo: "bar baz" } | | foo='bar baz' | { foo: "bar baz" } | | foo=`bar baz` | { foo: "bar baz" } | | | foo=[42-71] | { foo: [42, 71] } | | | foo foo1=true foo2=false foo3=bar foo4="true" foo5='false' foo6=`hello world` foo7=[42-71] | { foo: true, foo1: true, foo2: false, foo3: "bar", foo4: "true", foo5: "false", foo6="hello world", foo7: [42, 71] }

🧩 Installation

yarn add rehype-meta-string (or npm/pnpm)

💫 Options

  • metaString?: string

Specify the field name which holds the raw meta string. By default, it is metaString.

Package Sidebar

Install

npm i rehype-meta-string

Weekly Downloads

0

Version

0.0.4

License

MIT

Unpacked Size

9.23 kB

Total Files

4

Last publish

Collaborators

  • zheeeng