diff --git a/README.md b/README.md index 9398ce6..7e8c091 100644 --- a/README.md +++ b/README.md @@ -21,6 +21,8 @@ - [Example: custom callouts](#example-custom-callouts) - [Example: configure aliases](#example-configure-aliases) - [Example: configure element type](#example-configure-element-type) + - [Example: configure element type globally](#example-configure-element-type-globally) + - [Example: configure element type globally as well as specifically for a callout](#example-configure-element-type-globally-as-well-as-specifically-for-a-callout) - [Example: override the defaults](#example-override-the-defaults) - [License](#license) @@ -126,6 +128,7 @@ The following options are available. All of them are optional. - `aliases`: a list of aliases for the `callouts` - `callouts`: an object containing the callout definitions +- `tagName`: global custom element type. If specified, it'll override the default `aside` element type. This can be overridden by callout specific configuration (`callouts..tagName`). ### Default options @@ -419,6 +422,147 @@ Running that with `node example.js` yields: ``` +### Example: configure element type globally + +You can override the element type of all callouts by providing a `tagName`. + +Say we have the following file `example.md`: + +```md +:::assert +Some **content** with _Markdown_ `syntax`. +::: +``` + +And our module `example.js` looks as follows: + +```js +import { read } from "to-vfile" +import { unified } from "unified" +import remarkParse from "remark-parse" +import remarkDirective from "remark-directive" +import remarkCalloutDirectives from "@microflash/remark-callout-directives" +import remarkRehype from "remark-rehype" +import rehypeStringify from "rehype-stringify" + +main() + +async function main() { + const file = await unified() + .use(remarkParse) + .use(remarkDirective) + .use(remarkCalloutDirectives, { + tagName: "section" + }) + .use(remarkRehype, { allowDangerousHtml: true }) + .use(rehypeStringify, { allowDangerousHtml: true }) + .process(await read("example.md")) + + console.log(String(file)) +} +``` + +Running that with `node example.js` yields: + +```html +
+
+
+ + + +
+
Info
+
+
+

Some content with Markdown syntax.

+
+
+``` + +### Example: configure element type globally as well as specifically for a callout + +You can mix the `tagName` configurations globally and specifically for a callout. + +Say we have the following file `example.md`: + +```md +:::assert +Some **content** with _Markdown_ `syntax`. +::: + +:::note +Some **content** with _Markdown_ `syntax`. +::: +``` + +And our module `example.js` looks as follows: + +```js +import { read } from "to-vfile" +import { unified } from "unified" +import remarkParse from "remark-parse" +import remarkDirective from "remark-directive" +import remarkCalloutDirectives from "@microflash/remark-callout-directives" +import remarkRehype from "remark-rehype" +import rehypeStringify from "rehype-stringify" + +main() + +async function main() { + const file = await unified() + .use(remarkParse) + .use(remarkDirective) + .use(remarkCalloutDirectives, { + tagName: "section", + callouts: { + assert: { + tagName: "div" + } + } + }) + .use(remarkRehype, { allowDangerousHtml: true }) + .use(rehypeStringify, { allowDangerousHtml: true }) + .process(await read("example.md")) + + console.log(String(file)) +} +``` + +Running that with `node example.js` yields: + +```html +
+
+
+ + + +
+
Info
+
+
+

Some content with Markdown syntax.

+
+
+ +
+
+
+ + + + +
+
Note
+
+
+

Some content with Markdown syntax. +

+
+
+``` + ### Example: override the defaults You can override the defaults by passing your own preferences; they will be merged on top of the default values. diff --git a/index.js b/index.js index ae1a191..e2d47e1 100644 --- a/index.js +++ b/index.js @@ -104,9 +104,10 @@ export default function remarkCalloutDirectives(userOptions = {}) { node.children = generate(title || callout.title, node.children, callout.hint); - const tagName = callout.tagName || "aside"; - data.hName = tagName; - data.hProperties = h(tagName, node.attributes).properties; + const tagName = callout.tagName || options.tagName || "aside"; + const hast = h(tagName, node.attributes); + data.hName = hast.tagName; + data.hProperties = hast.properties; } }); }; diff --git a/package.json b/package.json index bdc3e2d..55a22d8 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@microflash/remark-callout-directives", - "version": "2.0.0", + "version": "3.0.0", "description": "remark plugin to render callouts and admonitions with directives", "license": "MIT", "keywords": [ @@ -27,17 +27,17 @@ "test": "ava" }, "dependencies": { - "defu": "^6.1.3", - "hastscript": "^8.0.0", + "defu": "^6.1.4", + "hastscript": "^9.0.0", "mdast-util-from-markdown": "^2.0.0", "unist-util-visit": "^5.0.0" }, "devDependencies": { - "ava": "^6.0.0", + "ava": "^6.1.1", "rehype-stringify": "^10.0.0", "remark-directive": "^3.0.0", "remark-parse": "^11.0.0", - "remark-rehype": "^11.0.0", + "remark-rehype": "^11.1.0", "unified": "^11.0.4" }, "ava": { diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 00cdc7a..2a5d97e 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -6,11 +6,11 @@ settings: dependencies: defu: - specifier: ^6.1.3 - version: 6.1.3 + specifier: ^6.1.4 + version: 6.1.4 hastscript: - specifier: ^8.0.0 - version: 8.0.0 + specifier: ^9.0.0 + version: 9.0.0 mdast-util-from-markdown: specifier: ^2.0.0 version: 2.0.0 @@ -20,8 +20,8 @@ dependencies: devDependencies: ava: - specifier: ^6.0.0 - version: 6.0.0 + specifier: ^6.1.1 + version: 6.1.1 rehype-stringify: specifier: ^10.0.0 version: 10.0.0 @@ -32,8 +32,8 @@ devDependencies: specifier: ^11.0.0 version: 11.0.0 remark-rehype: - specifier: ^11.0.0 - version: 11.0.0 + specifier: ^11.1.0 + version: 11.1.0 unified: specifier: ^11.0.4 version: 11.0.4 @@ -51,7 +51,7 @@ packages: nopt: 5.0.0 npmlog: 5.0.1 rimraf: 3.0.2 - semver: 7.5.4 + semver: 7.6.0 tar: 6.2.0 transitivePeerDependencies: - encoding @@ -76,7 +76,7 @@ packages: engines: {node: '>= 8'} dependencies: '@nodelib/fs.scandir': 2.1.5 - fastq: 1.15.0 + fastq: 1.17.1 dev: true /@rollup/pluginutils@4.2.1: @@ -102,6 +102,11 @@ packages: dependencies: '@types/unist': 3.0.2 + /@types/hast@3.0.4: + resolution: {integrity: sha512-WPs+bbQw5aCj+x6laNGWLH3wviHtoCv/P3+otBhbOhJgG8qtpdAMlTCxLtsTWA7LH1Oh/bFCHsBn0TPS5m30EQ==} + dependencies: + '@types/unist': 3.0.2 + /@types/mdast@4.0.3: resolution: {integrity: sha512-LsjtqsyF+d2/yFOYaN22dHZI1Cpwkrj+g06G8+qtUKlhovPW89YhqSnfKtMbkgmEtYpH2gydRNULd6y8mciAFg==} dependencies: @@ -121,21 +126,22 @@ packages: resolution: {integrity: sha512-zuVdFrMJiuCDQUMCzQaD6KL28MjnqqN8XnAqiEq9PNm/hCPTSGfrXCOfwj1ow4LFb/tNymJPwsNbVePc1xFqrQ==} dev: true - /@vercel/nft@0.24.4: - resolution: {integrity: sha512-KjYAZty7boH5fi5udp6p+lNu6nawgs++pHW+3koErMgbRkkHuToGX/FwjN5clV1FcaM3udfd4zW/sUapkMgpZw==} + /@vercel/nft@0.26.3: + resolution: {integrity: sha512-h1z/NN9ppS4YOKwSgBoopJlhm7tS2Qb/9Ld1HXjDpvvTE7mY0xVD8nllXs+RihD9uTGJISOIMzp18Eg0EApaMA==} engines: {node: '>=16'} hasBin: true dependencies: '@mapbox/node-pre-gyp': 1.0.11 '@rollup/pluginutils': 4.2.1 - acorn: 8.11.2 + acorn: 8.11.3 + acorn-import-attributes: 1.9.2(acorn@8.11.3) async-sema: 3.1.1 bindings: 1.5.0 estree-walker: 2.0.2 glob: 7.2.3 graceful-fs: 4.2.11 micromatch: 4.0.5 - node-gyp-build: 4.7.1 + node-gyp-build: 4.8.0 resolve-from: 5.0.0 transitivePeerDependencies: - encoding @@ -146,13 +152,21 @@ packages: resolution: {integrity: sha512-nne9/IiQ/hzIhY6pdDnbBtz7DjPTKrY00P/zvPSm5pOFkl6xuGrGnXn/VtTNNfNtAfZ9/1RtehkszU9qcTii0Q==} dev: true - /acorn-walk@8.3.0: - resolution: {integrity: sha512-FS7hV565M5l1R08MXqo8odwMTB02C2UqzB17RVgu9EyuYFBqJZ3/ZY97sQD5FewVu1UyDFc1yztUDrAwT0EypA==} + /acorn-import-attributes@1.9.2(acorn@8.11.3): + resolution: {integrity: sha512-O+nfJwNolEA771IYJaiLWK1UAwjNsQmZbTRqqwBYxCgVQTmpFEMvBw6LOIQV0Me339L5UMVYFyRohGnGlQDdIQ==} + peerDependencies: + acorn: ^8 + dependencies: + acorn: 8.11.3 + dev: true + + /acorn-walk@8.3.2: + resolution: {integrity: sha512-cjkyv4OtNCIeqhHrfS81QWXoCBPExR/J62oyEqepVw8WaQeSqpW2uhuLPh1m9eWhDuOo/jUXVTlifvesOWp/4A==} engines: {node: '>=0.4.0'} dev: true - /acorn@8.11.2: - resolution: {integrity: sha512-nc0Axzp/0FILLEVsm4fNwLCwMttvhEI263QtVPQcbpfZZ3ts0hLsZGOpE6czNlid7CJ9MlyH8reXkpsf3YUY4w==} + /acorn@8.11.3: + resolution: {integrity: sha512-Y9rRfJG5jcKOE0CLisYbojUjIrIEE7AGMzA/Sm4BslANhbS+cDMpgBdcPT91oJ7OuJ9hYJBx59RjbhxVnrF8Xg==} engines: {node: '>=0.4.0'} hasBin: true dev: true @@ -225,8 +239,8 @@ packages: resolution: {integrity: sha512-tLRNUXati5MFePdAk8dw7Qt7DpxPB60ofAgn8WRhW6a2rcimZnYBP9oxHiv0OHy+Wz7kPMG+t4LGdt31+4EmGg==} dev: true - /ava@6.0.0: - resolution: {integrity: sha512-sgruhDqX9QwW3iuivRgvHNZsE/3oc2yMpANUms2WIN3YGLmhng6aFoDDEFFtwKaaw2H7KteAOuNzv9ml1UO2QQ==} + /ava@6.1.1: + resolution: {integrity: sha512-A+DG0Ag0e5zvt262Ze0pG5QH7EBmhn+DB9uK7WkUtJVAtGjZFeKTpUOKx339DMGn53+FB24pCJC5klX2WU4VOw==} engines: {node: ^18.18 || ^20.8 || ^21} hasBin: true peerDependencies: @@ -235,14 +249,14 @@ packages: '@ava/typescript': optional: true dependencies: - '@vercel/nft': 0.24.4 - acorn: 8.11.2 - acorn-walk: 8.3.0 + '@vercel/nft': 0.26.3 + acorn: 8.11.3 + acorn-walk: 8.3.2 ansi-styles: 6.2.1 arrgv: 1.0.2 arrify: 3.0.0 callsites: 4.1.0 - cbor: 9.0.1 + cbor: 9.0.2 chalk: 5.3.0 chunkd: 2.0.1 ci-info: 4.0.0 @@ -253,7 +267,7 @@ packages: concordance: 5.0.4 currently-unhandled: 0.4.1 debug: 4.3.4 - emittery: 1.0.1 + emittery: 1.0.2 figures: 6.0.1 globby: 14.0.0 ignore-by-default: 2.1.0 @@ -263,11 +277,11 @@ packages: matcher: 5.0.0 memoize: 10.0.0 ms: 2.1.3 - p-map: 6.0.0 + p-map: 7.0.1 package-config: 5.0.0 picomatch: 3.0.1 plur: 5.1.0 - pretty-ms: 8.0.0 + pretty-ms: 9.0.0 resolve-cwd: 3.0.0 stack-utils: 2.0.6 strip-ansi: 7.1.0 @@ -317,8 +331,8 @@ packages: engines: {node: '>=12.20'} dev: true - /cbor@9.0.1: - resolution: {integrity: sha512-/TQOWyamDxvVIv+DY9cOLNuABkoyz8K/F3QE56539pGVYohx0+MEA1f4lChFTX79dBTBS7R1PF6ovH7G+VtBfQ==} + /cbor@9.0.2: + resolution: {integrity: sha512-JPypkxsB10s9QOWwa6zwPzqE1Md3vqpPc+cai4sAecuCsRyAtAl/pMyhPlMbT/xtPnm2dznJZYRLui57qiRhaQ==} engines: {node: '>=16'} dependencies: nofilter: 3.1.0 @@ -371,7 +385,7 @@ packages: engines: {node: '>=18'} dependencies: slice-ansi: 5.0.0 - string-width: 7.0.0 + string-width: 7.1.0 dev: true /cliui@8.0.1: @@ -427,7 +441,7 @@ packages: js-string-escape: 1.0.1 lodash: 4.17.21 md5-hex: 3.0.1 - semver: 7.5.4 + semver: 7.6.0 well-known-symbols: 2.0.0 dev: true @@ -470,8 +484,8 @@ packages: dependencies: character-entities: 2.0.2 - /defu@6.1.3: - resolution: {integrity: sha512-Vy2wmG3NTkmHNg/kzpuvHhkqeIx3ODWqasgCRbKtbXEN0G+HpEEv9BtJLp7ZG1CZloFaC41Ah3ZFbq7aqCqMeQ==} + /defu@6.1.4: + resolution: {integrity: sha512-mEQCMmwJu317oSz8CwdIOdwf3xMif1ttiM8LTufzc3g6kR+9Pe236twL8j3IYT1F7GfRgGcW6MWxzZjLIkuHIg==} dev: false /delegates@1.0.0: @@ -492,8 +506,8 @@ packages: dependencies: dequal: 2.0.3 - /emittery@1.0.1: - resolution: {integrity: sha512-2ID6FdrMD9KDLldGesP6317G78K7km/kMcwItRtVFva7I/cSEOIaLpewaUb+YLXVwdAp3Ctfxh/V5zIl1sj7dQ==} + /emittery@1.0.2: + resolution: {integrity: sha512-PqHdP6JJrxiSXQzCAzII77dVsfyGWu+7V0ghqkaCej2shF1cnIPeFE9kKZcVTqvBjrRMDVOdNXKEYcjxkznS1g==} engines: {node: '>=14.16'} dev: true @@ -510,8 +524,8 @@ packages: engines: {node: '>=0.12'} dev: true - /escalade@3.1.1: - resolution: {integrity: sha512-k0er2gUkLf8O0zKJiAhmkTnJlTvINGv7ygDNPbeIsX/TJjGJZHuh9B2UxbsaEkmlEo9MfhrSzmhIlhRlI2GXnw==} + /escalade@3.1.2: + resolution: {integrity: sha512-ErCHMCae19vR8vQGe50xIsVomy19rg6gFu3+r3jkEO46suLMWBksvVyoGgQV+jOfl84ZSOSlmv6Gxa89PmTGmA==} engines: {node: '>=6'} dev: true @@ -559,8 +573,8 @@ packages: micromatch: 4.0.5 dev: true - /fastq@1.15.0: - resolution: {integrity: sha512-wBrocU2LCXXa+lWBt8RoIRD89Fi8OdABODa/kEnyeyjS5aZO5/GNvI5sEINADqP/h8M29UHTHUb53sUu5Ihqdw==} + /fastq@1.17.1: + resolution: {integrity: sha512-sRVD3lWVIXWg6By68ZN7vho9a1pQcN/WBFaAAsDDFzlJjvoGx0P8z7V1t72grFJfJhu3YPZBuu25f7Kaw2jN1w==} dependencies: reusify: 1.0.4 dev: true @@ -648,7 +662,7 @@ packages: dependencies: '@sindresorhus/merge-streams': 1.0.0 fast-glob: 3.3.2 - ignore: 5.3.0 + ignore: 5.3.1 path-type: 5.0.0 slash: 5.1.0 unicorn-magic: 0.1.0 @@ -741,6 +755,17 @@ packages: hast-util-parse-selector: 4.0.0 property-information: 6.4.0 space-separated-tokens: 2.0.2 + dev: true + + /hastscript@9.0.0: + resolution: {integrity: sha512-jzaLBGavEDKHrc5EfFImKN7nZKKBdSLIdGvCwDZ9TfzbF2ffXiov8CKE445L2Z1Ek2t/m4SKQ2j6Ipv7NyUolw==} + dependencies: + '@types/hast': 3.0.4 + comma-separated-tokens: 2.0.3 + hast-util-parse-selector: 4.0.0 + property-information: 6.4.1 + space-separated-tokens: 2.0.2 + dev: false /html-void-elements@3.0.0: resolution: {integrity: sha512-bEqo66MRXsUGxWHV5IP0PUiAWwoEjba4VCzg0LjFJBpchPaTfyfCKTG6bc5F8ucKec3q5y6qOdGyYTSBEvhCrg==} @@ -761,8 +786,8 @@ packages: engines: {node: '>=10 <11 || >=12 <13 || >=14'} dev: true - /ignore@5.3.0: - resolution: {integrity: sha512-g7dmpshy+gD7mh88OC9NwSGTKoc3kyLAZQRU1mt53Aw/vnvfXnbC+F/7F7QoYVKbV+KNvJx8wArewKy1vXMtlg==} + /ignore@5.3.1: + resolution: {integrity: sha512-5Fytz/IraMjqpwfd34ke28PTVMjZjJG2MPn5t7OE4eUCUNf8BAa7b5WUS9/Qvr6mwOQS7Mk6vdsMno5he+T8Xw==} engines: {node: '>= 4'} dev: true @@ -964,6 +989,20 @@ packages: unist-util-visit: 5.0.0 dev: true + /mdast-util-to-hast@13.1.0: + resolution: {integrity: sha512-/e2l/6+OdGp/FB+ctrJ9Avz71AN/GRH3oi/3KAx/kMnoUsD6q0woXlDT8lLEeViVKE7oZxE7RXzvO3T8kF2/sA==} + dependencies: + '@types/hast': 3.0.4 + '@types/mdast': 4.0.3 + '@ungap/structured-clone': 1.2.0 + devlop: 1.1.0 + micromark-util-sanitize-uri: 2.0.0 + trim-lines: 3.0.1 + unist-util-position: 5.0.0 + unist-util-visit: 5.0.0 + vfile: 6.0.1 + dev: true + /mdast-util-to-markdown@2.1.0: resolution: {integrity: sha512-SR2VnIEdVNCJbP6y7kVTJgPLifdr8WEU440fQec7qHoHOUz/oJ2jmNRqdDQ3rbiStOXb2mCDGTuwsK5OPUgYlQ==} dependencies: @@ -1224,8 +1263,8 @@ packages: whatwg-url: 5.0.0 dev: true - /node-gyp-build@4.7.1: - resolution: {integrity: sha512-wTSrZ+8lsRRa3I3H8Xr65dLWSgCvY2l4AOnaeKdPA9TB/WYMPaTcrzf3rXvFoVvjKNVnu0CcWSx54qq9GKRUYg==} + /node-gyp-build@4.8.0: + resolution: {integrity: sha512-u6fs2AEUljNho3EYTJNBfImO5QTo/J/1Etd+NVdCj7qWKUSN/bSLkZwhDv7I+w/MSC6qJ4cknepkAYykDdK8og==} hasBin: true dev: true @@ -1262,9 +1301,9 @@ packages: wrappy: 1.0.2 dev: true - /p-map@6.0.0: - resolution: {integrity: sha512-T8BatKGY+k5rU+Q/GTYgrEf2r4xRMevAN5mtXc2aPc4rS1j3s+vWTaO2Wag94neXuCAUAs8cxBL9EeB5EA6diw==} - engines: {node: '>=16'} + /p-map@7.0.1: + resolution: {integrity: sha512-2wnaR0XL/FDOj+TgpDuRb2KTjLnu3Fma6b1ZUwGY7LcqenMcvP/YFpjpbPKY6WVGsbuJZRuoUz8iPrt8ORnAFw==} + engines: {node: '>=18'} dev: true /package-config@5.0.0: @@ -1288,9 +1327,9 @@ packages: is-hexadecimal: 2.0.1 dev: true - /parse-ms@3.0.0: - resolution: {integrity: sha512-Tpb8Z7r7XbbtBTrM9UhpkzzaMrqA2VXMT3YChzYltwV3P3pM6t8wl7TvpMnSTosz1aQAdVib7kdoys7vYOPerw==} - engines: {node: '>=12'} + /parse-ms@4.0.0: + resolution: {integrity: sha512-TXfryirbmq34y8QBwgqCVLi+8oA3oWx2eAnSn62ITyEhEYaWRlVZ2DvMM9eZbMs/RfxPu/PK/aBLyGj4IrqMHw==} + engines: {node: '>=18'} dev: true /parse5@7.1.2: @@ -1326,15 +1365,20 @@ packages: irregular-plurals: 3.5.0 dev: true - /pretty-ms@8.0.0: - resolution: {integrity: sha512-ASJqOugUF1bbzI35STMBUpZqdfYKlJugy6JBziGi2EE+AL5JPJGSzvpeVXojxrr0ViUYoToUjb5kjSEGf7Y83Q==} - engines: {node: '>=14.16'} + /pretty-ms@9.0.0: + resolution: {integrity: sha512-E9e9HJ9R9NasGOgPaPE8VMeiPKAyWR5jcFpNnwIejslIhWqdqOrb2wShBsncMPUb+BcCd2OPYfh7p2W6oemTng==} + engines: {node: '>=18'} dependencies: - parse-ms: 3.0.0 + parse-ms: 4.0.0 dev: true /property-information@6.4.0: resolution: {integrity: sha512-9t5qARVofg2xQqKtytzt+lZ4d1Qvj8t5B8fEwXK6qOfgRLgH/b13QlgEyDh033NOS31nXeFbYv7CLUDG1CeifQ==} + dev: true + + /property-information@6.4.1: + resolution: {integrity: sha512-OHYtXfu5aI2sS2LWFSN5rgJjrQ4pCy8i1jubJLe2QvMF8JJ++HXTUIVWFLfXJoaOfvYYjk2SN8J2wFUWIGXT4w==} + dev: false /queue-microtask@1.2.3: resolution: {integrity: sha512-NuaNSa6flKT5JaSYQzJok04JzTL1CA6aGhv5rfLW3PgqA+M2ChpZQnAC8h8i4ZFkBS8X5RqkDBHA7r4hej3K9A==} @@ -1379,12 +1423,12 @@ packages: - supports-color dev: true - /remark-rehype@11.0.0: - resolution: {integrity: sha512-vx8x2MDMcxuE4lBmQ46zYUDfcFMmvg80WYX+UNLeG6ixjdCCLcw1lrgAukwBTuOFsS78eoAedHGn9sNM0w7TPw==} + /remark-rehype@11.1.0: + resolution: {integrity: sha512-z3tJrAs2kIs1AqIIy6pzHmAHlF1hWQ+OdY4/hv+Wxe35EhyLKcajL33iUEn3ScxtFox9nUvRufR/Zre8Q08H/g==} dependencies: - '@types/hast': 3.0.3 + '@types/hast': 3.0.4 '@types/mdast': 4.0.3 - mdast-util-to-hast: 13.0.2 + mdast-util-to-hast: 13.1.0 unified: 11.0.4 vfile: 6.0.1 dev: true @@ -1433,8 +1477,8 @@ packages: hasBin: true dev: true - /semver@7.5.4: - resolution: {integrity: sha512-1bCSESV6Pv+i21Hvpxp3Dx+pSD8lIPt8uVjRrxAUt/nbswYc+tK6Y2btiULjd4+fnq15PX+nqQDC7Oft7WkwcA==} + /semver@7.6.0: + resolution: {integrity: sha512-EnwXhrlwXMk9gKu5/flx5sv/an57AkRplG3hTK68W7FRDN+k+OWBj65M7719OkA82XLBxrcX0KSHj+X5COhOVg==} engines: {node: '>=10'} hasBin: true dependencies: @@ -1497,8 +1541,8 @@ packages: strip-ansi: 6.0.1 dev: true - /string-width@7.0.0: - resolution: {integrity: sha512-GPQHj7row82Hjo9hKZieKcHIhaAIKOJvFSIZXuCU9OASVZrMNUaZuz++SPVrBjnLsnk4k+z9f2EIypgxf2vNFw==} + /string-width@7.1.0: + resolution: {integrity: sha512-SEIJCWiX7Kg4c129n48aDRwLbFb2LJmXXFrWBG4NGaRtMQ3myKPKbwrD1BKqQn74oCoNMBVrfDEr5M9YxCsrkw==} engines: {node: '>=18'} dependencies: emoji-regex: 10.3.0 @@ -1727,7 +1771,7 @@ packages: engines: {node: '>=12'} dependencies: cliui: 8.0.1 - escalade: 3.1.1 + escalade: 3.1.2 get-caller-file: 2.0.5 require-directory: 2.1.1 string-width: 4.2.3 diff --git a/test/fixtures.js b/test/fixtures.js index 54690ce..240e31f 100644 --- a/test/fixtures.js +++ b/test/fixtures.js @@ -117,4 +117,23 @@ export default [ input: `:::deter\nSome **content** with _Markdown_ \`syntax\`.\n:::`, output: `` }, + { + title: "callout with global custom element type", + options: { tagName: "section" }, + input: `:::note\nSome **content** with _Markdown_ \`syntax\`.\n:::`, + output: `
Note

Some content with Markdown syntax.

` + }, + { + title: "callout with global custom element type and specific custom element type", + options: { + tagName: "section", + callouts: { + assert: { + tagName: "div" + } + } + }, + input: `:::assert\nSome **content** with _Markdown_ \`syntax\`.\n:::`, + output: `
Info

Some content with Markdown syntax.

` + }, ];