myst-to-react 0.5.20 → 0.5.22

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.
@@ -16,7 +16,7 @@ export declare enum AdmonitionKind {
16
16
  }
17
17
  type Color = 'blue' | 'green' | 'yellow' | 'red';
18
18
  export declare const AdmonitionTitle: NodeRenderer<AdmonitionTitleSpec>;
19
- export declare function Admonition({ title, kind, color, simple, dropdown, children, hideIcon, }: {
19
+ export declare function Admonition({ title, kind, color, simple, dropdown, children, hideIcon, className, }: {
20
20
  title?: React.ReactNode;
21
21
  color?: Color;
22
22
  kind?: AdmonitionKind;
@@ -24,6 +24,7 @@ export declare function Admonition({ title, kind, color, simple, dropdown, child
24
24
  simple?: boolean;
25
25
  dropdown?: boolean;
26
26
  hideIcon?: boolean;
27
+ className?: string;
27
28
  }): import("react/jsx-runtime").JSX.Element;
28
29
  export declare const AdmonitionRenderer: NodeRenderer<AdmonitionSpec>;
29
30
  declare const ADMONITION_RENDERERS: {
@@ -1 +1 @@
1
- {"version":3,"file":"admonitions.d.ts","sourceRoot":"","sources":["../src/admonitions.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,UAAU,IAAI,cAAc,EAC5B,eAAe,IAAI,mBAAmB,EACvC,MAAM,WAAW,CAAC;AACnB,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAsB1D,oBAAY,cAAc;IACxB,UAAU,eAAe;IACzB,SAAS,cAAc;IACvB,OAAO,YAAY;IACnB,MAAM,WAAW;IACjB,KAAK,UAAU;IACf,SAAS,cAAc;IACvB,IAAI,SAAS;IACb,IAAI,SAAS;IACb,OAAO,YAAY;IACnB,GAAG,QAAQ;IACX,OAAO,YAAY;CACpB;AAED,KAAK,KAAK,GAAG,MAAM,GAAG,OAAO,GAAG,QAAQ,GAAG,KAAK,CAAC;AAyEjD,eAAO,MAAM,eAAe,EAAE,Y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AK,EACL,IAAI,EACJ,KAAK,EACL,MAAM,EACN,QAAQ,EACR,QAAQ,EACR,QAAQ,EACR,SAAS,GACV,EAAE;IACD,KAAK,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IACxB,KAAK,CAAC,EAAE,KAAK,CAAC;IACd,IAAI,CAAC,EAAE,cAAc,CAAC;IACtB,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;IAC1B,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,2CAsEA;AAED,eAAO,MAAM,kBAAkB,EAAE,YAAY,CAAC,cAAc,CAuB3D,CAAC;AAEF,QAAA,MAAM,oBAAoB;;;CAGzB,CAAC;AAEF,eAAe,oBAAoB,CAAC"}
@@ -96,7 +96,7 @@ const HeaderElement = ({ dropdown, className, children, }) => {
96
96
  return _jsx("summary", { className: className, children: children });
97
97
  return _jsx("div", { className: className, children: children });
98
98
  };
99
- export function Admonition({ title, kind, color, simple, dropdown, children, hideIcon, }) {
99
+ export function Admonition({ title, kind, color, simple, dropdown, children, hideIcon, className, }) {
100
100
  return (_jsxs(WrapperElement, { dropdown: dropdown, className: classNames('my-5 shadow-md dark:shadow-2xl dark:shadow-neutral-900', 'bg-gray-50/10 dark:bg-stone-800', 'overflow-hidden', {
101
101
  'rounded border-l-4': !simple,
102
102
  'border-l-2': simple,
@@ -104,7 +104,7 @@ export function Admonition({ title, kind, color, simple, dropdown, children, hid
104
104
  'border-green-600': color === 'green',
105
105
  'border-amber-600': color === 'yellow',
106
106
  'border-red-600': color === 'red',
107
- }), children: [title && (_jsxs(HeaderElement, { dropdown: dropdown, className: classNames('m-0 font-medium py-1 flex min-w-0', {
107
+ }, className), children: [title && (_jsxs(HeaderElement, { dropdown: dropdown, className: classNames('m-0 font-medium py-1 flex min-w-0', {
108
108
  'text-lg': !simple,
109
109
  'text-md': simple,
110
110
  'bg-gray-100 dark:bg-stone-700': simple,
@@ -129,7 +129,7 @@ export const AdmonitionRenderer = ({ node }) => {
129
129
  const isSimple = classes.includes('simple');
130
130
  const hideIcon = node.icon === false;
131
131
  const useTitle = (title === null || title === void 0 ? void 0 : title.type) === 'admonitionTitle';
132
- return (_jsx(Admonition, { title: useTitle ? _jsx(MyST, { ast: [title] }) : undefined, kind: kind, color: color, dropdown: isDropdown, simple: isSimple, hideIcon: hideIcon, children: useTitle ? _jsx(MyST, { ast: rest }) : _jsx(MyST, { ast: node.children }) }));
132
+ return (_jsx(Admonition, { title: useTitle ? _jsx(MyST, { ast: [title] }) : undefined, kind: kind, color: color, dropdown: isDropdown, simple: isSimple, hideIcon: hideIcon, className: classNames(classes), children: useTitle ? _jsx(MyST, { ast: rest }) : _jsx(MyST, { ast: node.children }) }));
133
133
  };
134
134
  const ADMONITION_RENDERERS = {
135
135
  admonition: AdmonitionRenderer,
@@ -1 +1 @@
1
- {"version":3,"file":"code.d.ts","sourceRoot":"","sources":["../src/code.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAQ,UAAU,EAAE,MAAM,WAAW,CAAC;AAClD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAS1D,KAAK,KAAK,GAAG;IACX,KAAK,EAAE,MAAM,CAAC;IACd,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,cAAc,CAAC,EAAE,MAAM,EAAE,CAAC;IAC1B,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,CAAC;AAWF,wBAAgB,SAAS,CAAC,KAAK,EAAE,KAAK,2CA4ErC;AA+CD,QAAA,MAAM,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;oBA7C0B,OAAO;;;CAgDpD,CAAC;AAEF,eAAe,cAAc,CAAC"}
1
+ {"version":3,"file":"code.d.ts","sourceRoot":"","sources":["../src/code.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAQ,UAAU,EAAE,MAAM,WAAW,CAAC;AAClD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAU1D,KAAK,KAAK,GAAG;IACX,KAAK,EAAE,MAAM,CAAC;IACd,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,cAAc,CAAC,EAAE,MAAM,EAAE,CAAC;IAC1B,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,CAAC;AAWF,wBAAgB,SAAS,CAAC,KAAK,EAAE,KAAK,2CA4ErC;AAuDD,QAAA,MAAM,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;oBArD0B,OAAO;;;CAwDpD,CAAC;AAEF,eAAe,cAAc,CAAC"}
package/dist/code.js CHANGED
@@ -6,6 +6,7 @@ import dark from 'react-syntax-highlighter/dist/esm/styles/hljs/vs2015.js';
6
6
  import { DocumentIcon } from '@heroicons/react/24/outline';
7
7
  import classNames from 'classnames';
8
8
  import { CopyIcon } from './components/index.js';
9
+ import { MyST } from './MyST.js';
9
10
  function normalizeLanguage(lang) {
10
11
  switch (lang) {
11
12
  case 'html':
@@ -60,6 +61,10 @@ const inlineCode = ({ node }) => {
60
61
  if (isColor(node.value)) {
61
62
  return (_jsxs("code", { className: "px-1 rounded bg-slate-100 text-slate-700 dark:bg-slate-800 dark:text-slate-100", children: [node.value, _jsx("span", { style: { backgroundColor: node.value }, className: "inline-block w-[10px] h-[10px] rounded-full ml-1" })] }));
62
63
  }
64
+ if (node.children && node.children.length > 0) {
65
+ // The inline code can potentially have children
66
+ return (_jsx("code", { children: _jsx(MyST, { ast: node.children }) }));
67
+ }
63
68
  return _jsx("code", { children: node.value });
64
69
  };
65
70
  const CODE_RENDERERS = {
@@ -1 +1 @@
1
- {"version":3,"file":"crossReference.d.ts","sourceRoot":"","sources":["../src/crossReference.tsx"],"names":[],"mappings":";AAEA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAChD,OAAO,EAOL,KAAK,YAAY,EAClB,MAAM,uBAAuB,CAAC;AA0H/B,wBAAgB,aAAa,CAAC,EAC5B,MAAM,EACN,GAAG,EACH,OAAO,GACR,EAAE;IACD,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB,sDAWA;AAuBD,wBAAgB,mBAAmB,CAAC,EAClC,GAAG,EAAE,KAAK,EACV,OAAO,EAAE,SAAS,EAClB,MAAM,EAAE,QAAQ,EAChB,QAAQ,EACR,UAAU,EACV,MAAW,GACZ,EAAE;IACD,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,UAAU,EAAE,MAAM,CAAC;IACnB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;CAC3B,2CAuDA;AAED,eAAO,MAAM,kBAAkB,EAAE,YAAY,CAAC,cAAc,CAqB3D,CAAC;AAEF,QAAA,MAAM,yBAAyB;;CAE9B,CAAC;AAEF,eAAe,yBAAyB,CAAC"}
1
+ {"version":3,"file":"crossReference.d.ts","sourceRoot":"","sources":["../src/crossReference.tsx"],"names":[],"mappings":";AAEA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAChD,OAAO,EAOL,KAAK,YAAY,EAClB,MAAM,uBAAuB,CAAC;AA0H/B,wBAAgB,aAAa,CAAC,EAC5B,MAAM,EACN,GAAG,EACH,OAAO,GACR,EAAE;IACD,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB,sDAWA;AAuBD,wBAAgB,mBAAmB,CAAC,EAClC,GAAG,EAAE,KAAK,EACV,OAAO,EAAE,SAAS,EAClB,MAAM,EAAE,QAAQ,EAChB,QAAQ,EACR,UAAU,EACV,MAAW,GACZ,EAAE;IACD,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,UAAU,EAAE,MAAM,CAAC;IACnB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;CAC3B,2CAuDA;AAED,eAAO,MAAM,kBAAkB,EAAE,YAAY,CAAC,cAAc,CAuB3D,CAAC;AAEF,QAAA,MAAM,yBAAyB;;CAE9B,CAAC;AAEF,eAAe,yBAAyB,CAAC"}
@@ -145,7 +145,7 @@ export const CrossReferenceNode = ({ node }) => {
145
145
  return (_jsx(InlineError, { value: node.label || node.identifier || 'No Label', message: "Cross Reference Not Found" }));
146
146
  }
147
147
  const { remote, url, dataUrl, identifier, html_id } = node;
148
- return (_jsx(CrossReferenceHover, { identifier: identifier, htmlId: html_id, remote: remote, url: url, dataUrl: dataUrl, children: _jsx(MyST, { ast: node.children }) }));
148
+ return (_jsxs(CrossReferenceHover, { identifier: identifier, htmlId: html_id, remote: remote, url: url, dataUrl: dataUrl, children: [node.prefix && _jsxs(_Fragment, { children: [node.prefix, " "] }), _jsx(MyST, { ast: node.children }), node.suffix || null] }));
149
149
  };
150
150
  const CROSS_REFERENCE_RENDERERS = {
151
151
  crossReference: CrossReferenceNode,
package/dist/image.js CHANGED
@@ -37,7 +37,7 @@ function Video({ src, urlSource, align = 'center', width, height, }) {
37
37
  muted: true, "webkit-playsinline": "true", playsInline: true, loop: true }));
38
38
  }
39
39
  function Picture({ src, srcOptimized, urlSource, align = 'center', alt, width, height, }) {
40
- if (src.endsWith('.mp4')) {
40
+ if (src.endsWith('.mp4') || (urlSource === null || urlSource === void 0 ? void 0 : urlSource.endsWith('.mp4'))) {
41
41
  return _jsx(Video, { width: width, height: height, align: align, src: src, urlSource: urlSource });
42
42
  }
43
43
  const image = (_jsx("img", { style: Object.assign({ width: getStyleValue(width), height: getStyleValue(height) }, alignToMargin(align)), src: src, alt: alt, "data-canonical-url": urlSource }));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "myst-to-react",
3
- "version": "0.5.20",
3
+ "version": "0.5.22",
4
4
  "type": "module",
5
5
  "exports": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",
@@ -21,7 +21,7 @@
21
21
  },
22
22
  "dependencies": {
23
23
  "@heroicons/react": "^2.0.18",
24
- "@myst-theme/providers": "^0.5.20",
24
+ "@myst-theme/providers": "^0.5.22",
25
25
  "@radix-ui/react-hover-card": "^1.0.6",
26
26
  "buffer": "^6.0.3",
27
27
  "classnames": "^2.3.2",