@readme/markdown 15.7.3 → 15.9.0

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.
@@ -0,0 +1,12 @@
1
+ import type { Root } from 'hast';
2
+ import type { Transformer } from 'unified';
3
+ /**
4
+ * Forces `safeMode` on every element that renders through `HTMLBlock` so it is
5
+ * shown as escaped text instead of injected.
6
+ *
7
+ * Runs last, so it sees every producer of the element — `[block:html]`,
8
+ * `<HTMLBlock>` with a template body or an `html` attribute, and a literal
9
+ * `<html-block>` — and it is unconditional so an author-supplied
10
+ * `safeMode="false"` can't opt out.
11
+ */
12
+ export declare const enforceSafeModeHtmlBlocks: () => Transformer<Root, Root>;
@@ -0,0 +1,31 @@
1
+ import type { Program } from 'estree';
2
+ import type { Root } from 'hast';
3
+ import type { Plugin, Transformer } from 'unified';
4
+ /**
5
+ * Tags removed from user-provided content because rendering them executes in the
6
+ * page. Add an entry to cover another vector; nothing else needs to change.
7
+ *
8
+ * Deliberately narrow for now — `<script>` is the only vector this plugin claims
9
+ * to close. Broader parity with the `md` sanitization schema (`javascript:` URLs,
10
+ * `on*` handlers, `<iframe>`, `<object>`, …) is tracked in readmeio/markdown#1526.
11
+ */
12
+ export declare const STRIPPED_TAG_NAMES: Set<string>;
13
+ /**
14
+ * Removes matching elements and their subtrees when `sanitize` is enabled.
15
+ *
16
+ * Explicit `HTMLBlock`s are an intentional exception, matching legacy: their
17
+ * scripts live in a string prop rather than as elements, so they never appear
18
+ * in SSR HTML, and they only execute client-side when the author opts in via
19
+ * `runScripts`.
20
+ */
21
+ export declare const rehypeStripTags: () => Transformer<Root, Root>;
22
+ /**
23
+ * JSX inside expressions and exports stays in ESTree, outside the HAST pass.
24
+ * Strip it before evaluation in mdxish or after JSX compilation in MDX.
25
+ *
26
+ * Elements are spliced out of JSX children and replaced with `null` anywhere
27
+ * else, which React renders as nothing.
28
+ */
29
+ export declare const stripJsxTags: (program: Program) => Program;
30
+ /** `stripJsxTags` as a recma plugin, for the `mdx` compile pipeline. */
31
+ export declare const recmaStripTags: Plugin<[], Program>;
@@ -11,6 +11,10 @@ declare module 'hast' {
11
11
  mdxishScope?: MdxishScope;
12
12
  }
13
13
  }
14
+ interface Options {
15
+ /** Drop `STRIPPED_TAG_NAMES` JSX from the exported code before it is evaluated. */
16
+ sanitize?: boolean;
17
+ }
14
18
  /**
15
19
  * Evaluate `export const/function` declarations introduced by mdxjsEsm nodes.
16
20
  *
@@ -23,5 +27,5 @@ declare module 'hast' {
23
27
  * Any evaluation error is consumed and logged. We don't throw because it's
24
28
  * against the spirit of this engine to be less permissive than MDX needs.
25
29
  */
26
- declare const evaluateExports: Plugin<[], Root>;
30
+ declare const evaluateExports: Plugin<[Options?], Root>;
27
31
  export default evaluateExports;
@@ -64,7 +64,6 @@ export interface RecipeJson extends MagicBlockJson {
64
64
  export interface MagicBlockTransformerOptions {
65
65
  compatibilityMode?: boolean;
66
66
  hardBreaks?: boolean;
67
- safeMode?: boolean;
68
67
  }
69
68
  /**
70
69
  * Magic block image node structure (output from magicBlockTransformer).
@@ -0,0 +1,7 @@
1
+ import type { MdxJsxAttribute } from 'mdast-util-mdx-jsx';
2
+ type CellAlign = 'center' | 'left' | 'right' | null;
3
+ /** `left` is the browser default, so it's omitted. Lowercase tables get the HTML string form. */
4
+ export declare const cellStyle: (align: CellAlign, width?: string | null, { html }?: {
5
+ html?: boolean;
6
+ }) => MdxJsxAttribute | null;
7
+ export {};
@@ -0,0 +1,9 @@
1
+ import type { MdxJsxFlowElement, MdxJsxTextElement } from 'mdast-util-mdx-jsx';
2
+ /** Bare numbers are pixels. A value carrying declaration separators is not a single width. */
3
+ export declare const normalizeWidth: (value: unknown) => string | null;
4
+ /** Handles a CSS declaration list and a style object safe mode left as a string (`{ width: "30%" }`). */
5
+ export declare const widthFromStyleString: (style: string) => string | undefined;
6
+ /** Accepts `style={{ width }}`, `style="width: …"` and the hand-authored `width="…"`. */
7
+ export declare const getCellWidth: (cell: MdxJsxFlowElement | MdxJsxTextElement) => string | null;
8
+ /** True when the cell's attributes state nothing but its width, which mdast can carry. */
9
+ export declare const hasOnlyWidthAttributes: (cell: MdxJsxFlowElement | MdxJsxTextElement) => boolean;