MCPcopy Index your code
hub / github.com/nodejs/nodejs.org / parseMeta

Function parseMeta

packages/rehype-shiki/src/plugin.mjs:21–35  ·  view source on GitHub ↗

* Parses a fenced code block metadata string into a JavaScript object. * @param {string} meta - The metadata string from a Markdown code fence. * @returns {Record } An object representing the metadata.

(meta)

Source from the content-addressed store, hash-verified

19 * @returns {Record<string, string|boolean>} An object representing the metadata.
20 */
21function parseMeta(meta) {
22 const obj = { __raw: meta };
23
24 if (!meta) {
25 return obj;
26 }
27
28 let match;
29
30 while ((match = rMeta.exec(meta)) !== null) {
31 obj[match[1]] = match[2] ?? match[3] ?? true;
32 }
33
34 return obj;
35}
36
37/**
38 * @typedef {import('unist').Node} Node

Callers 1

rehypeShikijiFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected