myst-demo 0.13.4 → 0.13.6

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.
package/dist/index.d.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  import type { PageFrontmatter } from 'myst-frontmatter';
2
2
  import type { NodeRenderer } from '@myst-theme/providers';
3
- export declare function MySTRenderer({ value, column, fullscreen, numbering, TitleBlock, captureTab, className, }: {
3
+ export declare function MySTRenderer({ id, value, column, fullscreen, numbering, TitleBlock, captureTab, className, }: {
4
+ id?: string;
4
5
  value: string;
5
6
  column?: boolean;
6
7
  fullscreen?: boolean;
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.tsx"],"names":[],"mappings":"AAiBA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AACxD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAsN1D,wBAAgB,YAAY,CAAC,EAC3B,KAAK,EACL,MAAM,EACN,UAAU,EACV,SAAS,EACT,UAAU,EACV,UAAU,EACV,SAAS,GACV,EAAE;IACD,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,UAAU,CAAC,EAAE,CAAC,KAAK,EAAE;QAAE,WAAW,EAAE,eAAe,CAAA;KAAE,KAAK,GAAG,CAAC,OAAO,GAAG,IAAI,CAAC;IAC7E,SAAS,CAAC,EAAE,GAAG,CAAC;IAChB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,2CA8PA;AAED,eAAO,MAAM,gBAAgB,EAAE,YAE9B,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.tsx"],"names":[],"mappings":"AAiBA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AACxD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AA0N1D,wBAAgB,YAAY,CAAC,EAC3B,EAAE,EACF,KAAK,EACL,MAAM,EACN,UAAU,EACV,SAAS,EACT,UAAU,EACV,UAAU,EACV,SAAS,GACV,EAAE;IACD,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,UAAU,CAAC,EAAE,CAAC,KAAK,EAAE;QAAE,WAAW,EAAE,eAAe,CAAA;KAAE,KAAK,GAAG,CAAC,OAAO,GAAG,IAAI,CAAC;IAC7E,SAAS,CAAC,EAAE,GAAG,CAAC;IAChB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,2CA+PA;AAED,eAAO,MAAM,gBAAgB,EAAE,YAS9B,CAAC"}
package/dist/index.js CHANGED
@@ -93,6 +93,7 @@ function parse(text, defaultFrontmatter, options) {
93
93
  const { default: mystToTypst } = yield import('myst-to-typst');
94
94
  const { default: mystToJats } = yield import('myst-to-jats').catch(() => ({ default: null }));
95
95
  const { mystToHtml } = yield import('myst-to-html');
96
+ const { buttonRole } = yield import('myst-ext-button');
96
97
  const { cardDirective } = yield import('myst-ext-card');
97
98
  const { gridDirective } = yield import('myst-ext-grid');
98
99
  const { tabDirectives } = yield import('myst-ext-tabs');
@@ -108,7 +109,7 @@ function parse(text, defaultFrontmatter, options) {
108
109
  proofDirective,
109
110
  ...exerciseDirectives,
110
111
  ],
111
- // roles: [reactiveRole],
112
+ roles: [buttonRole],
112
113
  vfile,
113
114
  });
114
115
  const mdast = parseMyst(text);
@@ -134,7 +135,7 @@ function parse(text, defaultFrontmatter, options) {
134
135
  messages: {},
135
136
  });
136
137
  const state = new ReferenceState('', {
137
- numbering: (_a = frontmatter.numbering) !== null && _a !== void 0 ? _a : defaultFrontmatter === null || defaultFrontmatter === void 0 ? void 0 : defaultFrontmatter.numbering,
138
+ frontmatter: Object.assign(Object.assign({}, frontmatter), { numbering: (_a = frontmatter.numbering) !== null && _a !== void 0 ? _a : defaultFrontmatter === null || defaultFrontmatter === void 0 ? void 0 : defaultFrontmatter.numbering }),
138
139
  vfile,
139
140
  });
140
141
  visit(mdast, (n) => {
@@ -206,7 +207,7 @@ function parse(text, defaultFrontmatter, options) {
206
207
  };
207
208
  });
208
209
  }
209
- export function MySTRenderer({ value, column, fullscreen, numbering, TitleBlock, captureTab, className, }) {
210
+ export function MySTRenderer({ id, value, column, fullscreen, numbering, TitleBlock, captureTab, className, }) {
210
211
  var _a;
211
212
  const area = useRef(null);
212
213
  const [text, setText] = useState(value.trim());
@@ -297,22 +298,22 @@ export function MySTRenderer({ value, column, fullscreen, numbering, TitleBlock,
297
298
  }), title: `Show the AST Stage ${show.toUpperCase()}`, "aria-pressed": astStage === show ? 'true' : 'false', onClick: () => setAstStage(show), children: show.toUpperCase() }, show)))] }))] }));
298
299
  const mdastStage = astStage === 'pre' ? mdastPre : mdastPost;
299
300
  const { downloads, exports, parts } = frontmatter, reducedFrontmatter = __rest(frontmatter, ["downloads", "exports", "parts"]);
300
- return (_jsxs("figure", { className: classnames('relative', {
301
+ return (_jsxs("figure", { id: id, className: classnames('relative', {
301
302
  'grid grid-cols-2 gap-0 grid-rows-[3rem_1fr]': column,
302
- 'shadow-lg rounded': !fullscreen,
303
+ 'rounded shadow-lg': !fullscreen,
303
304
  'm-0': fullscreen,
304
- }, className), children: [column && (_jsxs("div", { className: "flex flex-row items-stretch h-full col-span-2 px-2 border dark:border-slate-600", children: [_jsx("div", { className: "flex-grow" }), demoMenu] })), _jsxs("div", { className: classnames('myst relative', { 'overflow-auto': column }), children: [_jsx(CopyIcon, { text: text, className: "absolute right-0 p-1" }), _jsxs("label", { children: [_jsx("span", { className: "sr-only", children: "Edit the MyST Markdown text" }), _jsx("textarea", { ref: area, value: text, className: classnames('block p-6 shadow-inner resize-none w-full font-mono bg-slate-50/50 dark:bg-slate-800/50 outline-none', { 'text-sm': !column }, { 'h-full': column }), onChange: (e) => setText(e.target.value) })] })] }), _jsxs("div", { className: classnames('exclude-from-outline relative min-h-1 dark:bg-slate-900', {
305
+ }, className), children: [column && (_jsxs("div", { className: "flex flex-row col-span-2 items-stretch px-2 h-full border dark:border-slate-600", children: [_jsx("div", { className: "flex-grow" }), demoMenu] })), _jsxs("div", { className: classnames('relative myst', { 'overflow-auto': column }), children: [_jsx(CopyIcon, { text: text, className: "absolute right-0 p-1" }), _jsxs("label", { children: [_jsx("span", { className: "sr-only", children: "Edit the MyST Markdown text" }), _jsx("textarea", { ref: area, value: text, className: classnames('block p-6 w-full font-mono shadow-inner outline-none resize-none bg-slate-50/50 dark:bg-slate-800/50', { 'text-sm': !column }, { 'h-full': column }), onChange: (e) => setText(e.target.value) })] })] }), _jsxs("div", { className: classnames('relative exclude-from-outline min-h-1 dark:bg-slate-900', {
305
306
  'overflow-auto': column,
306
307
  }), children: [!column && _jsx("div", { className: "absolute top-0 left-0", children: demoMenu }), _jsxs("div", { className: classnames('px-6 pb-6', {
307
308
  'pt-[40px]': !column && previewType !== 'AST',
308
309
  'pt-[80px]': !column && previewType === 'AST',
309
310
  'pt-4': column,
310
- }), children: [previewType === 'DEMO' && (_jsx(_Fragment, { children: _jsxs(ReferencesProvider, { references: references, frontmatter: reducedFrontmatter, children: [TitleBlock && _jsx(TitleBlock, { frontmatter: frontmatter }), _jsx(MyST, { ast: (_a = references.article) === null || _a === void 0 ? void 0 : _a.children })] }) })), previewType === 'AST' && (_jsx(_Fragment, { children: _jsx(CodeBlock, { lang: astLang, value: astLang === 'yaml' ? yamlDump(mdastStage) : JSON.stringify(mdastStage, null, 2) }) })), previewType === 'HTML' && _jsx(CodeBlock, { lang: "xml", value: html, showCopy: false }), previewType === 'LaTeX' && _jsx(CodeBlock, { lang: "latex", value: tex, showCopy: false }), previewType === 'Typst' && _jsx(CodeBlock, { lang: "typst", value: typst, showCopy: false }), previewType === 'JATS' && _jsx(CodeBlock, { lang: "xml", value: jats, showCopy: false }), previewType === 'DOCX' && (_jsx("div", { children: _jsxs("button", { className: "p-3 border rounded", onClick: () => saveDocxFile('demo.docx', references.article), title: `Download Micorsoft Word`, "aria-label": `Download Micorsoft Word`, children: [_jsx(ArrowDownTrayIcon, { width: "1.3rem", height: "1.3rem", className: "inline mr-1" }), ' ', "Download as Microsoft Word"] }) }))] }), currentWarnings.length > 0 && (_jsx("div", { className: classnames('w-full', { 'absolute bottom-0': column }), children: currentWarnings.map((m, i) => (_jsxs("div", { className: classnames('p-1 shadow-inner text-white not-prose', {
311
+ }), children: [previewType === 'DEMO' && (_jsx(_Fragment, { children: _jsxs(ReferencesProvider, { references: references, frontmatter: reducedFrontmatter, children: [TitleBlock && _jsx(TitleBlock, { frontmatter: frontmatter }), _jsx(MyST, { ast: (_a = references.article) === null || _a === void 0 ? void 0 : _a.children })] }) })), previewType === 'AST' && (_jsx(_Fragment, { children: _jsx(CodeBlock, { lang: astLang, value: astLang === 'yaml' ? yamlDump(mdastStage) : JSON.stringify(mdastStage, null, 2) }) })), previewType === 'HTML' && _jsx(CodeBlock, { lang: "xml", value: html, showCopy: false }), previewType === 'LaTeX' && _jsx(CodeBlock, { lang: "latex", value: tex, showCopy: false }), previewType === 'Typst' && _jsx(CodeBlock, { lang: "typst", value: typst, showCopy: false }), previewType === 'JATS' && _jsx(CodeBlock, { lang: "xml", value: jats, showCopy: false }), previewType === 'DOCX' && (_jsx("div", { children: _jsxs("button", { className: "p-3 rounded border", onClick: () => saveDocxFile('demo.docx', references.article), title: `Download Micorsoft Word`, "aria-label": `Download Micorsoft Word`, children: [_jsx(ArrowDownTrayIcon, { width: "1.3rem", height: "1.3rem", className: "inline mr-1" }), ' ', "Download as Microsoft Word"] }) }))] }), currentWarnings.length > 0 && (_jsx("div", { className: classnames('w-full', { 'absolute bottom-0': column }), children: currentWarnings.map((m, i) => (_jsxs("div", { className: classnames('p-1 shadow-inner text-white not-prose', {
311
312
  'bg-red-500 dark:bg-red-800': m.fatal === true,
312
313
  'bg-orange-500 dark:bg-orange-700': m.fatal === false,
313
314
  'bg-slate-500 dark:bg-slate-800': m.fatal === null,
314
315
  }), children: [m.fatal === true && (_jsx(ExclamationCircleIcon, { width: "1.3rem", height: "1.3rem", className: "inline mr-1" })), m.fatal === false && (_jsx(ExclamationTriangleIcon, { width: "1.3rem", height: "1.3rem", className: "inline mr-1" })), m.fatal === null && (_jsx(InformationCircleIcon, { width: "1.3rem", height: "1.3rem", className: "inline mr-1" })), _jsx("code", { children: m.ruleId || m.source }), ": ", m.message] }, i))) }))] })] }));
315
316
  }
316
317
  export const MystDemoRenderer = ({ node }) => {
317
- return _jsx(MySTRenderer, { value: node.value, numbering: node.numbering });
318
+ return (_jsx(MySTRenderer, { id: node.html_id || node.identifier, value: node.value, numbering: node.numbering, className: node.class }));
318
319
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "myst-demo",
3
- "version": "0.13.4",
3
+ "version": "0.13.6",
4
4
  "type": "module",
5
5
  "exports": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",
@@ -23,24 +23,25 @@
23
23
  "@heroicons/react": "^2.0.18",
24
24
  "classnames": "^2.3.2",
25
25
  "js-yaml": "^4.1.0",
26
- "myst-common": "^1.7.3",
27
- "myst-config": "^1.7.3",
28
- "myst-directives": "^1.5.7",
26
+ "myst-common": "^1.7.8",
27
+ "myst-config": "^1.7.8",
28
+ "myst-directives": "^1.5.11",
29
+ "myst-ext-button": "^0.0.1",
29
30
  "myst-ext-card": "^1.0.9",
30
- "myst-ext-exercise": "^1.0.8",
31
- "myst-ext-grid": "^1.0.8",
32
- "myst-ext-proof": "^1.0.11",
33
- "myst-ext-tabs": "^1.0.8",
34
- "myst-frontmatter": "^1.7.3",
35
- "myst-parser": "^1.5.7",
31
+ "myst-ext-exercise": "^1.0.9",
32
+ "myst-ext-grid": "^1.0.9",
33
+ "myst-ext-proof": "^1.0.12",
34
+ "myst-ext-tabs": "^1.0.9",
35
+ "myst-frontmatter": "^1.7.8",
36
+ "myst-parser": "^1.5.11",
36
37
  "myst-spec": "^0.0.5",
37
- "myst-to-docx": "^1.0.12",
38
- "myst-to-html": "^1.5.7",
39
- "myst-to-jats": "^1.0.30",
40
- "myst-to-react": "^0.13.4",
41
- "myst-to-tex": "^1.0.38",
42
- "myst-to-typst": "^0.0.25",
43
- "myst-transforms": "^1.3.26",
38
+ "myst-to-docx": "^1.0.13",
39
+ "myst-to-html": "^1.5.11",
40
+ "myst-to-jats": "^1.0.32",
41
+ "myst-to-react": "^0.13.6",
42
+ "myst-to-tex": "^1.0.41",
43
+ "myst-to-typst": "^0.0.30",
44
+ "myst-transforms": "^1.3.31",
44
45
  "unified": "^10.1.2",
45
46
  "unist-util-remove": "^4.0.0",
46
47
  "unist-util-visit": "^4.1.2",