@chassis-ui/docs 0.1.4 → 0.1.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/libs/rehype.ts +24 -2
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@chassis-ui/docs",
3
3
  "description": "Shared Astro components and layouts for Chassis documentation sites.",
4
- "version": "0.1.4",
4
+ "version": "0.1.5",
5
5
  "type": "module",
6
6
  "repository": {
7
7
  "type": "git",
@@ -2,8 +2,13 @@ import type { Root } from 'hast'
2
2
  import type { Plugin } from 'unified'
3
3
  import { SKIP, visit } from 'unist-util-visit'
4
4
 
5
- // A rehype plugin to apply CSS classes to tables rendered in markdown (or MDX) files when wrapped in a `<CxTable />`
6
- // component.
5
+ /**
6
+ * Rehype plugin to apply CSS classes to tables in Markdown/MDX files.
7
+ *
8
+ * When a `<table>` is wrapped in a `<CxTable />` MDX component, this plugin
9
+ * reads the `class` attribute from the wrapper and applies it to the `<table>`
10
+ * element. Defaults to `"table"` if no class is specified.
11
+ */
7
12
  export const rehypeCxTable: Plugin<[], Root> = function () {
8
13
  return function rehypeCxTablePlugin(ast) {
9
14
  visit(ast, 'element', (node, _index, parent) => {
@@ -36,3 +41,20 @@ export const rehypeCxTable: Plugin<[], Root> = function () {
36
41
  })
37
42
  }
38
43
  }
44
+
45
+ /**
46
+ * Rehype plugin to strip `is:raw` attributes from code elements.
47
+ *
48
+ * The `@astrojs/markdown-remark` rehype-prism plugin adds `is:raw` as an Astro
49
+ * directive, but it leaks into the final HTML output because rehype processes
50
+ * it as a plain attribute rather than an Astro compiler directive.
51
+ */
52
+ export const rehypeStripIsRaw: Plugin<[], Root> = function () {
53
+ return function rehypeStripIsRawPlugin(tree) {
54
+ visit(tree, 'element', (node) => {
55
+ if (node.properties && 'is:raw' in node.properties) {
56
+ delete node.properties['is:raw']
57
+ }
58
+ })
59
+ }
60
+ }