myst-to-react 0.1.17 → 0.1.19
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/cjs/admonitions.d.ts +32 -0
- package/dist/cjs/admonitions.d.ts.map +1 -0
- package/dist/cjs/admonitions.js +126 -0
- package/dist/cjs/basic.d.ts +62 -0
- package/dist/cjs/basic.d.ts.map +1 -0
- package/dist/cjs/basic.js +125 -0
- package/dist/cjs/card.d.ts +27 -0
- package/dist/cjs/card.d.ts.map +1 -0
- package/dist/cjs/card.js +64 -0
- package/dist/cjs/cite.d.ts +6 -0
- package/dist/cjs/cite.d.ts.map +1 -0
- package/dist/cjs/cite.js +36 -0
- package/dist/cjs/code.d.ts +20 -0
- package/dist/cjs/code.d.ts.map +1 -0
- package/dist/cjs/code.js +63 -0
- package/dist/cjs/components/ClickPopover.d.ts +11 -0
- package/dist/cjs/components/ClickPopover.d.ts.map +1 -0
- package/dist/cjs/components/ClickPopover.js +18 -0
- package/dist/cjs/components/CopyIcon.d.ts +5 -0
- package/dist/cjs/components/CopyIcon.d.ts.map +1 -0
- package/dist/cjs/components/CopyIcon.js +28 -0
- package/dist/cjs/components/HoverPopover.d.ts +9 -0
- package/dist/cjs/components/HoverPopover.d.ts.map +1 -0
- package/dist/cjs/components/HoverPopover.js +32 -0
- package/dist/cjs/components/LinkCard.d.ts +11 -0
- package/dist/cjs/components/LinkCard.d.ts.map +1 -0
- package/dist/cjs/components/LinkCard.js +15 -0
- package/dist/cjs/convertToReact.d.ts +6 -0
- package/dist/cjs/convertToReact.d.ts.map +1 -0
- package/dist/cjs/convertToReact.js +30 -0
- package/dist/cjs/crossReference.d.ts +13 -0
- package/dist/cjs/crossReference.d.ts.map +1 -0
- package/dist/cjs/crossReference.js +91 -0
- package/dist/cjs/dropdown.d.ts +16 -0
- package/dist/cjs/dropdown.d.ts.map +1 -0
- package/dist/cjs/dropdown.js +27 -0
- package/dist/cjs/extensions/chemicalFormula.d.ts +7 -0
- package/dist/cjs/extensions/chemicalFormula.d.ts.map +1 -0
- package/dist/cjs/extensions/chemicalFormula.js +39 -0
- package/dist/cjs/extensions/index.d.ts +4 -0
- package/dist/cjs/extensions/index.d.ts.map +1 -0
- package/dist/cjs/extensions/index.js +9 -0
- package/dist/cjs/extensions/siunits.d.ts +7 -0
- package/dist/cjs/extensions/siunits.d.ts.map +1 -0
- package/dist/cjs/extensions/siunits.js +12 -0
- package/dist/cjs/footnotes.d.ts +11 -0
- package/dist/cjs/footnotes.d.ts.map +1 -0
- package/dist/cjs/footnotes.js +24 -0
- package/dist/cjs/grid.d.ts +11 -0
- package/dist/cjs/grid.d.ts.map +1 -0
- package/dist/cjs/grid.js +117 -0
- package/dist/cjs/heading.d.ts +14 -0
- package/dist/cjs/heading.d.ts.map +1 -0
- package/dist/cjs/heading.js +40 -0
- package/dist/cjs/iframe.d.ts +7 -0
- package/dist/cjs/iframe.d.ts.map +1 -0
- package/dist/cjs/iframe.js +24 -0
- package/dist/cjs/image.d.ts +11 -0
- package/dist/cjs/image.d.ts.map +1 -0
- package/dist/cjs/image.js +52 -0
- package/dist/cjs/index.d.ts +10 -0
- package/dist/cjs/index.d.ts.map +1 -0
- package/dist/cjs/index.js +46 -0
- package/dist/cjs/inlineError.d.ts +8 -0
- package/dist/cjs/inlineError.d.ts.map +1 -0
- package/dist/cjs/inlineError.js +9 -0
- package/dist/cjs/links/github.d.ts +12 -0
- package/dist/cjs/links/github.d.ts.map +1 -0
- package/dist/cjs/links/github.js +63 -0
- package/dist/cjs/links/index.d.ts +14 -0
- package/dist/cjs/links/index.d.ts.map +1 -0
- package/dist/cjs/links/index.js +68 -0
- package/dist/cjs/links/rrid.d.ts +5 -0
- package/dist/cjs/links/rrid.d.ts.map +1 -0
- package/dist/cjs/links/rrid.js +35 -0
- package/dist/cjs/links/wiki.d.ts +8 -0
- package/dist/cjs/links/wiki.d.ts.map +1 -0
- package/dist/cjs/links/wiki.js +39 -0
- package/dist/cjs/math.d.ts +13 -0
- package/dist/cjs/math.d.ts.map +1 -0
- package/dist/cjs/math.js +29 -0
- package/dist/cjs/output/components.d.ts +10 -0
- package/dist/cjs/output/components.d.ts.map +1 -0
- package/dist/cjs/output/components.js +41 -0
- package/dist/cjs/output/error.d.ts +6 -0
- package/dist/cjs/output/error.d.ts.map +1 -0
- package/dist/cjs/output/error.js +15 -0
- package/dist/cjs/output/hooks.d.ts +67 -0
- package/dist/cjs/output/hooks.d.ts.map +1 -0
- package/dist/cjs/output/hooks.js +85 -0
- package/dist/cjs/output/index.d.ts +6 -0
- package/dist/cjs/output/index.d.ts.map +1 -0
- package/dist/cjs/output/index.js +7 -0
- package/dist/cjs/output/jupyter.d.ts +7 -0
- package/dist/cjs/output/jupyter.d.ts.map +1 -0
- package/dist/cjs/output/jupyter.js +75 -0
- package/dist/cjs/output/output.d.ts +7 -0
- package/dist/cjs/output/output.d.ts.map +1 -0
- package/dist/cjs/output/output.js +66 -0
- package/dist/cjs/output/outputBlock.d.ts +10 -0
- package/dist/cjs/output/outputBlock.d.ts.map +1 -0
- package/dist/cjs/output/outputBlock.js +13 -0
- package/dist/cjs/output/safe.d.ts +7 -0
- package/dist/cjs/output/safe.d.ts.map +1 -0
- package/dist/cjs/output/safe.js +77 -0
- package/dist/cjs/output/selectors.d.ts +10 -0
- package/dist/cjs/output/selectors.d.ts.map +1 -0
- package/dist/cjs/output/selectors.js +10 -0
- package/dist/cjs/output/stream.d.ts +6 -0
- package/dist/cjs/output/stream.d.ts.map +1 -0
- package/dist/cjs/output/stream.js +13 -0
- package/dist/cjs/reactive.d.ts +88 -0
- package/dist/cjs/reactive.d.ts.map +1 -0
- package/dist/cjs/reactive.js +64 -0
- package/dist/cjs/tabs.d.ts +12 -0
- package/dist/cjs/tabs.d.ts.map +1 -0
- package/dist/cjs/tabs.js +38 -0
- package/dist/cjs/types.d.ts +7 -0
- package/dist/cjs/types.d.ts.map +1 -0
- package/dist/cjs/types.js +2 -0
- package/dist/types/admonitions.d.ts +32 -0
- package/dist/types/admonitions.d.ts.map +1 -0
- package/dist/types/basic.d.ts +62 -0
- package/dist/types/basic.d.ts.map +1 -0
- package/dist/types/card.d.ts +27 -0
- package/dist/types/card.d.ts.map +1 -0
- package/dist/types/cite.d.ts +6 -0
- package/dist/types/cite.d.ts.map +1 -0
- package/dist/types/code.d.ts +20 -0
- package/dist/types/code.d.ts.map +1 -0
- package/dist/types/components/ClickPopover.d.ts +11 -0
- package/dist/types/components/ClickPopover.d.ts.map +1 -0
- package/dist/types/components/CopyIcon.d.ts +5 -0
- package/dist/types/components/CopyIcon.d.ts.map +1 -0
- package/dist/types/components/HoverPopover.d.ts +9 -0
- package/dist/types/components/HoverPopover.d.ts.map +1 -0
- package/dist/types/components/LinkCard.d.ts +11 -0
- package/dist/types/components/LinkCard.d.ts.map +1 -0
- package/dist/types/convertToReact.d.ts +6 -0
- package/dist/types/convertToReact.d.ts.map +1 -0
- package/dist/types/crossReference.d.ts +13 -0
- package/dist/types/crossReference.d.ts.map +1 -0
- package/dist/types/dropdown.d.ts +16 -0
- package/dist/types/dropdown.d.ts.map +1 -0
- package/dist/types/extensions/chemicalFormula.d.ts +7 -0
- package/dist/types/extensions/chemicalFormula.d.ts.map +1 -0
- package/dist/types/extensions/index.d.ts +4 -0
- package/dist/types/extensions/index.d.ts.map +1 -0
- package/dist/types/extensions/siunits.d.ts +7 -0
- package/dist/types/extensions/siunits.d.ts.map +1 -0
- package/dist/types/footnotes.d.ts +11 -0
- package/dist/types/footnotes.d.ts.map +1 -0
- package/dist/types/grid.d.ts +11 -0
- package/dist/types/grid.d.ts.map +1 -0
- package/dist/types/heading.d.ts +14 -0
- package/dist/types/heading.d.ts.map +1 -0
- package/dist/types/iframe.d.ts +7 -0
- package/dist/types/iframe.d.ts.map +1 -0
- package/dist/types/image.d.ts +11 -0
- package/dist/types/image.d.ts.map +1 -0
- package/dist/types/index.d.ts +10 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/inlineError.d.ts +8 -0
- package/dist/types/inlineError.d.ts.map +1 -0
- package/dist/types/links/github.d.ts +12 -0
- package/dist/types/links/github.d.ts.map +1 -0
- package/dist/types/links/index.d.ts +14 -0
- package/dist/types/links/index.d.ts.map +1 -0
- package/dist/types/links/rrid.d.ts +5 -0
- package/dist/types/links/rrid.d.ts.map +1 -0
- package/dist/types/links/wiki.d.ts +8 -0
- package/dist/types/links/wiki.d.ts.map +1 -0
- package/dist/types/math.d.ts +13 -0
- package/dist/types/math.d.ts.map +1 -0
- package/dist/types/output/components.d.ts +10 -0
- package/dist/types/output/components.d.ts.map +1 -0
- package/dist/types/output/error.d.ts +6 -0
- package/dist/types/output/error.d.ts.map +1 -0
- package/dist/types/output/hooks.d.ts +67 -0
- package/dist/types/output/hooks.d.ts.map +1 -0
- package/dist/types/output/index.d.ts +6 -0
- package/dist/types/output/index.d.ts.map +1 -0
- package/dist/types/output/jupyter.d.ts +7 -0
- package/dist/types/output/jupyter.d.ts.map +1 -0
- package/dist/types/output/output.d.ts +7 -0
- package/dist/types/output/output.d.ts.map +1 -0
- package/dist/types/output/outputBlock.d.ts +10 -0
- package/dist/types/output/outputBlock.d.ts.map +1 -0
- package/dist/types/output/safe.d.ts +7 -0
- package/dist/types/output/safe.d.ts.map +1 -0
- package/dist/types/output/selectors.d.ts +10 -0
- package/dist/types/output/selectors.d.ts.map +1 -0
- package/dist/types/output/stream.d.ts +6 -0
- package/dist/types/output/stream.d.ts.map +1 -0
- package/dist/types/reactive.d.ts +88 -0
- package/dist/types/reactive.d.ts.map +1 -0
- package/dist/types/tabs.d.ts +12 -0
- package/dist/types/tabs.d.ts.map +1 -0
- package/dist/types/types.d.ts +7 -0
- package/dist/types/types.d.ts.map +1 -0
- package/package.json +36 -23
- package/src/admonitions.tsx +0 -183
- package/src/basic.tsx +0 -224
- package/src/card.tsx +0 -153
- package/src/cite.tsx +0 -94
- package/src/code.tsx +0 -119
- package/src/components/ClickPopover.tsx +0 -56
- package/src/components/CopyIcon.tsx +0 -40
- package/src/components/HoverPopover.tsx +0 -60
- package/src/components/LinkCard.tsx +0 -42
- package/src/convertToReact.ts +0 -33
- package/src/crossReference.tsx +0 -139
- package/src/dropdown.tsx +0 -69
- package/src/extensions/chemicalFormula.tsx +0 -42
- package/src/extensions/index.tsx +0 -10
- package/src/extensions/siunits.tsx +0 -15
- package/src/footnotes.tsx +0 -30
- package/src/grid.tsx +0 -127
- package/src/heading.tsx +0 -68
- package/src/iframe.tsx +0 -42
- package/src/image.tsx +0 -97
- package/src/index.tsx +0 -65
- package/src/inlineError.tsx +0 -15
- package/src/links/index.tsx +0 -132
- package/src/links/rrid.tsx +0 -81
- package/src/links/wiki.tsx +0 -119
- package/src/math.tsx +0 -81
- package/src/mermaid.tsx +0 -49
- package/src/myst.tsx +0 -221
- package/src/output/components.tsx +0 -34
- package/src/output/error.tsx +0 -20
- package/src/output/hooks.ts +0 -127
- package/src/output/index.tsx +0 -7
- package/src/output/jupyter.tsx +0 -86
- package/src/output/output.tsx +0 -79
- package/src/output/outputBlock.tsx +0 -21
- package/src/output/safe.tsx +0 -84
- package/src/output/selectors.ts +0 -15
- package/src/output/stream.tsx +0 -18
- package/src/reactive.tsx +0 -64
- package/src/tabs.tsx +0 -63
- package/src/types.ts +0 -6
package/src/links/wiki.tsx
DELETED
|
@@ -1,119 +0,0 @@
|
|
|
1
|
-
import useSWR from 'swr';
|
|
2
|
-
import { ExternalLinkIcon } from '@heroicons/react/outline';
|
|
3
|
-
import { HoverPopover } from '../components/HoverPopover';
|
|
4
|
-
import { LinkCard } from '../components/LinkCard';
|
|
5
|
-
import React from 'react';
|
|
6
|
-
|
|
7
|
-
const WikiTextMark = () => (
|
|
8
|
-
<svg
|
|
9
|
-
xmlns="http://www.w3.org/2000/svg"
|
|
10
|
-
version="1.1"
|
|
11
|
-
id="svg3400"
|
|
12
|
-
viewBox="0 0 500 85"
|
|
13
|
-
className="h-4"
|
|
14
|
-
>
|
|
15
|
-
<g transform="translate(-357.71336,-784.65111)">
|
|
16
|
-
<path
|
|
17
|
-
fill="currentColor"
|
|
18
|
-
d="m 412.98736,806.72288 c 0,0 -1.468,-2.984 -1.968,-3.976 -3.336,-6.612 -3.264,-6.964 -6.636,-7.408 -0.944,-0.124 -1.432,-0.244 -1.432,-0.712 v -2.092 l 0.284,-0.204 c 6.092,-0.008 19.648,-0.008 19.648,-0.008 l 0.52,0.172 v 2.084 c 0,0.476 -0.34,0.72 -1.032,0.72 l -1.424,0.204 c -3.6,0.28 -3.012,1.752 -0.62,6.516 l 22.708,46.46 0.776,0.212 20.16,-47.844 c 0.7,-1.928 0.592,-3.296 -0.308,-4.1 -0.904,-0.784 -1.54,-1.248 -3.876,-1.344 l -1.892,-0.096 c -0.232,0 -0.452,-0.084 -0.664,-0.24 -0.208,-0.148 -0.316,-0.344 -0.316,-0.58 v -1.992 l 0.288,-0.204 c 5.68,0 22.776,0 22.776,0 l 0.232,0.204 v 1.992 c 0,0.54 -0.308,0.812 -0.916,0.812 -2.984,0.132 -5.196,0.78 -6.628,1.936 -1.436,1.164 -2.556,2.768 -3.36,4.852 0,0 -18.54,42.436 -24.884,56.54 -2.428,4.624 -4.816,4.2 -6.916,-0.132 -4.436,-9.136 -16.928,-36.852 -16.928,-36.852 l -7.592,-14.92 z"
|
|
19
|
-
/>
|
|
20
|
-
<path
|
|
21
|
-
fill="currentColor"
|
|
22
|
-
d="m 449.37136,792.29888 c 0,0 -12.812,-0.04 -18.516,0 l -0.284,0.204 v 1.984 c 0,0.244 0.104,0.436 0.312,0.584 0.212,0.156 0.428,0.236 0.66,0.236 l 0.916,0.1 c 2.332,0.096 3.404,0.708 3.724,1.092 0.556,0.68 0.832,1.416 -0.516,4.356 l -23.92,47.708 -0.628,-0.164 c 0,0 -17.132,-36.124 -22.092,-48.208 -0.516,-1.252 -0.748,-2.18 -0.748,-2.752 0,-1.228 1.108,-1.892 3.324,-1.984 l 2.584,-0.108 c 0.684,0 1.032,-0.264 1.032,-0.812 v -1.984 l -0.232,-0.204 c 0,0 -20.52,-0.024 -24.76,0 l -0.232,0.204 v 2.084 c 0,0.376 0.476,0.608 1.432,0.712 2.604,0.14 4.316,0.556 5.14,1.248 0.82,0.7 1.688,2.468 2.84,5.224 6.228,14.96 19.46,41.656 25.904,56.86 1.856,4.152 4.188,4.796 7.02,-0.128 4.904,-9.096 18.2,-36.872 18.2,-36.872 l 10.472,-19.584 c 1.22,-2.068 2.396,-3.912 2.992,-4.772 1.092,-1.572 1.704,-1.868 4.688,-2.008 0.608,0 0.916,-0.272 0.916,-0.82 v -1.984 l -0.228,-0.212 z"
|
|
23
|
-
/>
|
|
24
|
-
<path
|
|
25
|
-
fill="currentColor"
|
|
26
|
-
d="m 488.32736,854.23088 c 0,2.288 1.04,3.64 4.368,3.952 l 2.184,0.212 c 0.312,0 0.624,0.204 0.624,0.62 v 2.184 l -0.104,0.212 c 0,0 -7.904,-0.212 -11.128,-0.212 -2.912,0 -11.024,0.212 -11.024,0.212 l -0.208,-0.212 v -2.184 c 0,-0.416 0.312,-0.62 0.728,-0.62 l 2.08,-0.212 c 3.432,-0.312 4.472,-1.976 4.472,-3.952 v -34.632 c 0,-2.284 -1.252,-2.916 -4.472,-3.22 l -2.08,-0.216 c -0.416,0 -0.728,-0.096 -0.728,-0.416 v -2.396 l 0.104,-0.208 c 0,0 8.216,0.208 11.44,0.208 2.808,0 10.816,-0.208 10.816,-0.208 l 0.104,0.208 v 2.288 c 0,0.312 -0.208,0.52 -0.624,0.52 l -2.184,0.212 c -3.224,0.308 -4.368,1.144 -4.368,3.228 v 34.632 z"
|
|
27
|
-
/>
|
|
28
|
-
<path
|
|
29
|
-
fill="currentColor"
|
|
30
|
-
d="m 519.01936,854.23088 c 0,2.288 1.352,3.432 4.368,3.952 l 1.144,0.212 c 0.312,0.1 0.624,0.204 0.624,0.62 v 2.184 l -0.104,0.212 c 0,0 -6.552,-0.212 -9.672,-0.212 -2.912,0 -11.44,0.212 -11.44,0.212 l -0.208,-0.212 v -2.184 c 0,-0.416 0.312,-0.62 0.728,-0.62 l 2.08,-0.212 c 3.12,-0.312 4.472,-1.976 4.472,-3.952 v -34.632 c 0,-2.284 -1.144,-2.916 -4.472,-3.22 l -2.08,-0.216 c -0.416,0 -0.728,-0.096 -0.728,-0.416 v -2.396 l 0.104,-0.208 c 0,0 8.528,0.208 11.752,0.208 2.916,0 9.464,-0.208 9.464,-0.208 l 0.104,0.208 v 2.288 c 0,0.312 -0.208,0.416 -0.624,0.52 l -1.144,0.212 c -3.224,0.62 -4.368,1.144 -4.368,3.228 v 15.704 c 3.432,0 5.408,-1.764 9.984,-6.656 4.16,-4.58 7.384,-8.42 7.384,-10.4 0,-0.836 -0.936,-1.768 -3.016,-2.084 -0.416,-0.1 -0.624,-0.208 -0.624,-0.52 v -2.396 l 0.104,-0.1 c 0,0 8.424,0.208 11.44,0.208 2.704,0 7.28,-0.208 7.28,-0.208 l 0.312,0.1 v 2.396 c 0,0.312 -0.312,0.52 -0.832,0.52 -4.056,0.312 -6.864,0.52 -10.608,4.784 l -8.944,10.292 c -1.768,1.876 -2.392,3.016 -2.392,3.852 0,0.624 0.416,1.14 0.936,1.764 l 15.704,18.928 c 1.248,1.452 3.744,2.08 5.824,2.492 l 0.52,0.1 c 0.312,0.104 0.728,0.312 0.728,0.624 v 2.184 l -0.312,0.104 c 0,0 -5.512,-0.104 -8.424,-0.104 -2.6,0 -6.344,0.104 -6.344,0.104 l -0.104,-0.104 v -1.248 c 0,-1.356 -0.104,-2.492 -1.56,-4.156 l -11.544,-14.356 c -1.56,-2.084 -3.224,-2.596 -5.512,-2.596 v 15.404 l 0,0 z"
|
|
31
|
-
/>
|
|
32
|
-
<path
|
|
33
|
-
fill="currentColor"
|
|
34
|
-
d="m 575.08736,854.23088 c 0,2.288 1.04,3.64 4.368,3.952 l 2.184,0.212 c 0.312,0 0.624,0.204 0.624,0.62 v 2.184 l -0.104,0.212 c 0,0 -7.904,-0.212 -11.128,-0.212 -2.912,0 -11.024,0.212 -11.024,0.212 l -0.208,-0.212 v -2.184 c 0,-0.416 0.312,-0.62 0.728,-0.62 l 2.08,-0.212 c 3.432,-0.312 4.472,-1.976 4.472,-3.952 v -34.632 c 0,-2.284 -1.248,-2.916 -4.472,-3.22 l -2.08,-0.216 c -0.416,0 -0.728,-0.096 -0.728,-0.416 v -2.396 l 0.104,-0.208 c 0,0 8.216,0.208 11.44,0.208 2.808,0 10.816,-0.208 10.816,-0.208 l 0.104,0.208 v 2.288 c 0,0.312 -0.208,0.52 -0.624,0.52 l -2.184,0.212 c -3.224,0.308 -4.368,1.144 -4.368,3.228 v 34.632 z"
|
|
35
|
-
/>
|
|
36
|
-
<path
|
|
37
|
-
fill="currentColor"
|
|
38
|
-
d="m 597.55936,819.80288 c 0,-3.224 -1.352,-3.328 -6.24,-3.64 -0.624,0 -0.728,-0.308 -0.728,-0.52 v -2.392 l 0.208,-0.104 c 1.56,0 7.696,0.208 10.712,0.208 2.912,0 7.072,-0.208 10.92,-0.208 14.76,0 17.464,7.276 17.464,12.692 0,6.244 -3.016,16.016 -17.776,16.016 -2.6,0 -4.68,-0.212 -6.556,-1.04 v 13.928 c 0,2.288 1.248,2.812 4.58,3.328 l 2.084,0.312 c 0.416,0.104 0.728,0.212 0.728,0.624 v 2.184 l -0.1,0.208 c 0,0 -8.32,-0.208 -11.544,-0.208 -2.912,0 -10.712,0.208 -10.712,0.208 l -0.104,-0.208 v -2.184 c 0,-0.416 0.208,-0.52 0.624,-0.624 l 2.184,-0.312 c 3.224,-0.416 4.264,-1.352 4.264,-3.328 l -0.008,-34.94 0,0 z m 8.008,18.1 c 2.08,0.836 4.68,0.936 6.76,0.936 6.244,0 9.248,-3.752 9.248,-11.752 0,-8.944 -4.056,-10.92 -9.768,-10.92 -4.996,0 -6.244,0.936 -6.244,3.64 l 0.004,18.096 0,0 z"
|
|
39
|
-
/>
|
|
40
|
-
<path
|
|
41
|
-
fill="currentColor"
|
|
42
|
-
d="m 647.80736,861.19888 c -3.12,0 -10.292,0.212 -10.292,0.212 l -0.108,-0.212 v -2.288 c 0,-0.204 0.108,-0.516 0.624,-0.516 l 2.396,-0.212 c 3.228,-0.312 4.164,-2.392 4.164,-4.468 v -34.32 c 0,-2.4 -1.252,-2.812 -4.164,-3.016 l -2.396,-0.216 c -0.624,-0.096 -0.624,-0.308 -0.624,-0.416 v -2.396 l 0.108,-0.208 c 0,0 8.108,0.208 11.228,0.208 h 15.288 c 3.12,0 10.508,-0.208 10.508,-0.208 l 0.212,0.208 c 0.1,4.472 0.828,8.536 1.56,12.484 l -2.596,0.416 c -1.14,-3.852 -3.116,-9.36 -9.772,-9.36 h -8.32 c -1.976,0 -3.016,0.728 -3.016,2.492 v 15.084 h 7.796 c 2.916,0 3.64,-1.248 4.06,-3.328 l 0.62,-2.184 c 0,-0.312 0.212,-0.524 0.624,-0.524 h 1.764 c 0.212,0 0.212,0.108 0.212,0.312 -0.212,2.288 -0.624,5.204 -0.624,7.7 0,2.596 0.416,4.784 0.624,7.176 l -0.212,0.212 h -1.764 c -0.516,0 -0.732,-0.212 -0.732,-0.524 l -0.52,-2.284 c -0.416,-2.084 -1.352,-3.228 -4.064,-3.228 h -7.792 v 15.916 c 0,1.972 1.136,3.948 3.016,3.948 h 9.88 c 5.304,0 8.22,-3.328 9.464,-8.74 l 2.596,0.312 -2.084,11.956 -0.208,0.208 c 0,0 -6.136,-0.208 -9.256,-0.208 l -18.2,0.012 0,0 z"
|
|
43
|
-
/>
|
|
44
|
-
<path
|
|
45
|
-
fill="currentColor"
|
|
46
|
-
d="m 686.91936,858.39488 2.392,-0.212 c 3.124,-0.312 4.164,-1.248 4.164,-4.468 v -34.32 c 0,-2.712 -0.736,-2.712 -4.164,-3.016 l -2.28,-0.216 c -0.416,0 -0.736,-0.208 -0.736,-0.52 v -2.288 l 0.1,-0.208 c 0,0 9.156,0.208 11.032,0.208 1.968,0 11.024,-0.208 13.728,-0.208 17.368,0 25.9,10.816 25.9,24.648 0,18.204 -12.9,23.604 -24.44,23.604 -8.32,0 -11.956,-0.208 -15.18,-0.208 -3.124,0 -11.028,0.208 -11.028,0.208 l -0.104,-0.208 v -2.184 c -0.008,-0.3 0.204,-0.612 0.616,-0.612 z m 23.196,0 c 11.436,0 17.892,-4.26 17.892,-18.828 0,-10.812 -2.396,-23.404 -19.868,-23.404 -4.056,0 -6.656,0.624 -6.656,3.232 v 34.32 c 0,2.904 0.724,4.68 8.632,4.68 z"
|
|
47
|
-
/>
|
|
48
|
-
<path
|
|
49
|
-
fill="currentColor"
|
|
50
|
-
d="m 761.60736,854.23088 c 0,2.288 1.04,3.64 4.368,3.952 l 2.184,0.212 c 0.312,0 0.624,0.204 0.624,0.62 v 2.184 l -0.104,0.212 c 0,0 -7.904,-0.212 -11.124,-0.212 -2.916,0 -11.024,0.212 -11.024,0.212 l -0.212,-0.212 v -2.184 c 0,-0.416 0.312,-0.62 0.728,-0.62 l 2.084,-0.212 c 3.428,-0.312 4.472,-1.976 4.472,-3.952 v -34.632 c 0,-2.284 -1.252,-2.916 -4.472,-3.22 l -2.084,-0.216 c -0.416,0 -0.728,-0.096 -0.728,-0.416 v -2.396 l 0.104,-0.208 c 0,0 8.216,0.208 11.432,0.208 2.808,0 10.82,-0.208 10.82,-0.208 l 0.1,0.208 v 2.288 c 0,0.312 -0.212,0.52 -0.624,0.52 l -2.184,0.212 c -3.224,0.308 -4.368,1.144 -4.368,3.228 l 0.008,34.632 0,0 z"
|
|
51
|
-
/>
|
|
52
|
-
<path
|
|
53
|
-
fill="currentColor"
|
|
54
|
-
d="m 793.64736,858.18288 3.016,0.212 c 0.416,0 0.832,0.312 0.832,0.828 v 1.976 l -0.208,0.212 c 0,0 -11.336,-0.212 -13.832,-0.212 -2.708,0 -9.364,0.212 -9.364,0.212 l -0.212,-0.212 v -1.976 c 0,-0.516 0.312,-0.828 0.836,-0.828 4.58,-0.312 7.172,-1.148 10.084,-7.804 l 23.084,-54.084 c 1.14,-2.704 1.976,-3.748 3.54,-3.748 1.452,0 1.976,1.044 2.804,3.124 l 21.32,56.368 c 1.46,4.06 3.54,5.616 7.7,6.032 l 1.144,0.1 c 0.52,0 1.04,0.312 1.04,0.836 v 1.972 l -0.312,0.208 c 0,0 -8.008,-0.208 -12.064,-0.208 -3.64,0 -13.836,0.208 -13.836,0.208 l -0.1,-0.208 v -1.972 c 0,-0.524 0.208,-0.836 0.736,-0.836 l 2.912,-0.208 c 3.948,-0.308 5.412,-1.564 4.368,-4.472 l -6.344,-17.58 h -21.632 c -2.496,0 -3.12,0.416 -3.636,1.764 l -6.036,15.084 c -1.04,2.608 0.312,4.9 4.16,5.212 z m 25.48,-26.424 -10.088,-27.764 h -0.208 l -10.4,26.416 c -0.416,1.044 0.308,1.352 2.596,1.352 h 18.1 z"
|
|
55
|
-
/>
|
|
56
|
-
</g>
|
|
57
|
-
</svg>
|
|
58
|
-
);
|
|
59
|
-
|
|
60
|
-
const fetcher = (...args: Parameters<typeof fetch>) =>
|
|
61
|
-
fetch(...args).then((res) => {
|
|
62
|
-
if (res.status === 200) return res.json();
|
|
63
|
-
throw new Error(`Content returned with status ${res.status}.`);
|
|
64
|
-
});
|
|
65
|
-
|
|
66
|
-
const ENGLISH_WIKIPEDIA = 'https://en.wikipedia.org/';
|
|
67
|
-
function createWikiUrl(name: string, wiki?: string): string {
|
|
68
|
-
return `${wiki || ENGLISH_WIKIPEDIA}wiki/${name}`;
|
|
69
|
-
}
|
|
70
|
-
function createWikiApiUrl(name: string, wiki?: string): string {
|
|
71
|
-
return `${wiki || ENGLISH_WIKIPEDIA}api/rest_v1/page/summary/${name}`;
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
function WikiChild({ page, wiki, open }: { page: string; wiki: string; open: boolean }) {
|
|
75
|
-
const { data, error } = useSWR(open ? createWikiApiUrl(page, wiki) : null, fetcher);
|
|
76
|
-
const { thumbnail, extract, content_urls } = data ?? {};
|
|
77
|
-
const url = content_urls?.desktop?.page ?? createWikiUrl(page);
|
|
78
|
-
const image = thumbnail?.source;
|
|
79
|
-
if (error) {
|
|
80
|
-
return (
|
|
81
|
-
<span>
|
|
82
|
-
<a href={url} className="block" target="_blank" rel="noreferrer">
|
|
83
|
-
<ExternalLinkIcon className="w-4 h-4 float-right" />
|
|
84
|
-
<WikiTextMark />
|
|
85
|
-
</a>
|
|
86
|
-
<div className="mt-2">Error loading "{page}" from wikipedia.</div>
|
|
87
|
-
</span>
|
|
88
|
-
);
|
|
89
|
-
}
|
|
90
|
-
return (
|
|
91
|
-
<LinkCard
|
|
92
|
-
loading={!data}
|
|
93
|
-
url={url}
|
|
94
|
-
title={<WikiTextMark />}
|
|
95
|
-
thumbnail={image}
|
|
96
|
-
description={extract}
|
|
97
|
-
/>
|
|
98
|
-
);
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
export function WikiLink({
|
|
102
|
-
children,
|
|
103
|
-
page,
|
|
104
|
-
url,
|
|
105
|
-
wiki,
|
|
106
|
-
}: {
|
|
107
|
-
children: React.ReactNode;
|
|
108
|
-
page: string;
|
|
109
|
-
url: string;
|
|
110
|
-
wiki: string;
|
|
111
|
-
}) {
|
|
112
|
-
return (
|
|
113
|
-
<HoverPopover card={({ open }) => <WikiChild wiki={wiki} page={page} open={open} />}>
|
|
114
|
-
<a href={url} className="italic" target="_blank" rel="noreferrer">
|
|
115
|
-
{children}
|
|
116
|
-
</a>
|
|
117
|
-
</HoverPopover>
|
|
118
|
-
);
|
|
119
|
-
}
|
package/src/math.tsx
DELETED
|
@@ -1,81 +0,0 @@
|
|
|
1
|
-
import classNames from 'classnames';
|
|
2
|
-
import { ExclamationIcon } from '@heroicons/react/outline';
|
|
3
|
-
import type { InlineMath, Math } from 'myst-spec';
|
|
4
|
-
import { InlineError } from './inlineError';
|
|
5
|
-
import { HashLink } from './heading';
|
|
6
|
-
import type { NodeRenderer } from './types';
|
|
7
|
-
|
|
8
|
-
// function Math({ value, html }: { value: string; html: string }) {
|
|
9
|
-
// const [loaded, setLoaded] = useState(false);
|
|
10
|
-
// const ref = useRef<HTMLDivElement | null>(null);
|
|
11
|
-
// useEffect(() => {
|
|
12
|
-
// import('katex').then(() => {
|
|
13
|
-
// setLoaded(true);
|
|
14
|
-
// });
|
|
15
|
-
// }, []);
|
|
16
|
-
// useEffect(() => {
|
|
17
|
-
// if (!loaded) return;
|
|
18
|
-
// import('katex').then(({ default: katex }) => {
|
|
19
|
-
// if (!ref.current) return;
|
|
20
|
-
// katex.render(value, ref.current, { displayMode: true });
|
|
21
|
-
// });
|
|
22
|
-
// }, [loaded, ref]);
|
|
23
|
-
// return (
|
|
24
|
-
// <>
|
|
25
|
-
// {(typeof document === 'undefined' || !loaded) && (
|
|
26
|
-
// <div dangerouslySetInnerHTML={{ __html: html }} />
|
|
27
|
-
// )}
|
|
28
|
-
// {loaded && <div ref={ref} />}
|
|
29
|
-
// </>
|
|
30
|
-
// );
|
|
31
|
-
// }
|
|
32
|
-
|
|
33
|
-
type MathLike = (InlineMath | Math) & {
|
|
34
|
-
error?: boolean;
|
|
35
|
-
message?: string;
|
|
36
|
-
html?: string;
|
|
37
|
-
};
|
|
38
|
-
|
|
39
|
-
const mathRenderer: NodeRenderer<MathLike> = (node) => {
|
|
40
|
-
if (node.type === 'math') {
|
|
41
|
-
if (node.error || !node.html) {
|
|
42
|
-
return (
|
|
43
|
-
<pre key={node.key} title={node.message}>
|
|
44
|
-
<span className="text-red-500">
|
|
45
|
-
<ExclamationIcon className="inline h-[1em] mr-1" />
|
|
46
|
-
{node.message}
|
|
47
|
-
{'\n\n'}
|
|
48
|
-
</span>
|
|
49
|
-
{node.value}
|
|
50
|
-
</pre>
|
|
51
|
-
);
|
|
52
|
-
}
|
|
53
|
-
const id = node.html_id || node.identifier || node.key;
|
|
54
|
-
return (
|
|
55
|
-
<div key={node.key} id={id} className={classNames('flex group')}>
|
|
56
|
-
<div
|
|
57
|
-
dangerouslySetInnerHTML={{ __html: node.html }}
|
|
58
|
-
className="overflow-x-auto flex-grow"
|
|
59
|
-
/>
|
|
60
|
-
{node.enumerator && (
|
|
61
|
-
<div className="flex-none text-right m-0 pl-2 self-center relative">
|
|
62
|
-
<span>({node.enumerator})</span>
|
|
63
|
-
<HashLink id={id} align="right" kind="Equation" />
|
|
64
|
-
</div>
|
|
65
|
-
)}
|
|
66
|
-
</div>
|
|
67
|
-
);
|
|
68
|
-
}
|
|
69
|
-
if (node.error || !node.html) {
|
|
70
|
-
return <InlineError key={node.key} value={node.value} message={node.message} />;
|
|
71
|
-
}
|
|
72
|
-
return <span key={node.key} dangerouslySetInnerHTML={{ __html: node.html }} />;
|
|
73
|
-
// return <Math key={node.key} html={node.html} value={node.value as string} />;
|
|
74
|
-
};
|
|
75
|
-
|
|
76
|
-
const MATH_RENDERERS = {
|
|
77
|
-
math: mathRenderer,
|
|
78
|
-
inlineMath: mathRenderer,
|
|
79
|
-
};
|
|
80
|
-
|
|
81
|
-
export default MATH_RENDERERS;
|
package/src/mermaid.tsx
DELETED
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
import type { NodeRenderer } from './types';
|
|
2
|
-
import { useEffect, useState } from 'react';
|
|
3
|
-
|
|
4
|
-
async function parse(id: string, text: string): Promise<string> {
|
|
5
|
-
const { default: mermaid } = await import('mermaid');
|
|
6
|
-
return await new Promise<string>((resolve) => {
|
|
7
|
-
mermaid.render(id, text, (code) => {
|
|
8
|
-
resolve(code);
|
|
9
|
-
});
|
|
10
|
-
});
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
export function MermaidRenderer({ id, value }: { value: string; id: string }) {
|
|
14
|
-
const [graph, setGraph] = useState<string>();
|
|
15
|
-
const [error, setError] = useState<Error>();
|
|
16
|
-
useEffect(() => {
|
|
17
|
-
parse(id, value)
|
|
18
|
-
.then((svg) => {
|
|
19
|
-
setGraph(svg);
|
|
20
|
-
setError(undefined);
|
|
21
|
-
})
|
|
22
|
-
.catch((err) => {
|
|
23
|
-
setGraph(undefined);
|
|
24
|
-
setError(err as Error);
|
|
25
|
-
});
|
|
26
|
-
}, []);
|
|
27
|
-
return (
|
|
28
|
-
<figure className="">
|
|
29
|
-
{graph && <div dangerouslySetInnerHTML={{ __html: graph }}></div>}
|
|
30
|
-
{error && (
|
|
31
|
-
<pre>
|
|
32
|
-
Error parsing mermaid graph.
|
|
33
|
-
{'\n\n'}
|
|
34
|
-
{value}
|
|
35
|
-
</pre>
|
|
36
|
-
)}
|
|
37
|
-
</figure>
|
|
38
|
-
);
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
const MermaidNodeRenderer: NodeRenderer = (node) => {
|
|
42
|
-
return <MermaidRenderer key={node.key} id={node.key} value={node.value} />;
|
|
43
|
-
};
|
|
44
|
-
|
|
45
|
-
const MERMAID_RENDERERS = {
|
|
46
|
-
mermaid: MermaidNodeRenderer,
|
|
47
|
-
};
|
|
48
|
-
|
|
49
|
-
export default MERMAID_RENDERERS;
|
package/src/myst.tsx
DELETED
|
@@ -1,221 +0,0 @@
|
|
|
1
|
-
import { useParse } from '.';
|
|
2
|
-
import { VFile } from 'vfile';
|
|
3
|
-
import type { LatexResult } from 'myst-to-tex'; // Only import the type!!
|
|
4
|
-
import type { VFileMessage } from 'vfile-message';
|
|
5
|
-
import yaml from 'js-yaml';
|
|
6
|
-
import type { References } from '@curvenote/site-common';
|
|
7
|
-
import type { DocxResult } from 'myst-to-docx';
|
|
8
|
-
import type { PageFrontmatter } from 'myst-frontmatter';
|
|
9
|
-
import type { NodeRenderer } from './types';
|
|
10
|
-
import React, { useEffect, useRef, useState } from 'react';
|
|
11
|
-
import classnames from 'classnames';
|
|
12
|
-
import ExclamationIcon from '@heroicons/react/outline/ExclamationIcon';
|
|
13
|
-
import ExclamationCircleIcon from '@heroicons/react/outline/ExclamationCircleIcon';
|
|
14
|
-
import InformationCircleIcon from '@heroicons/react/outline/InformationCircleIcon';
|
|
15
|
-
import { CopyIcon } from './components/CopyIcon';
|
|
16
|
-
import { CodeBlock } from './code';
|
|
17
|
-
import { ReferencesProvider } from '@curvenote/ui-providers';
|
|
18
|
-
|
|
19
|
-
function downloadBlob(filename: string, blob: Blob) {
|
|
20
|
-
const a = document.createElement('a');
|
|
21
|
-
const url = URL.createObjectURL(blob);
|
|
22
|
-
a.href = url;
|
|
23
|
-
a.download = filename;
|
|
24
|
-
a.click();
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
async function saveDocxFile(filename: string, mdast: any, footnotes?: any) {
|
|
28
|
-
const { unified } = await import('unified');
|
|
29
|
-
const { mystToDocx, fetchImagesAsBuffers } = await import('myst-to-docx');
|
|
30
|
-
// Clone the tree
|
|
31
|
-
const tree = JSON.parse(JSON.stringify(mdast));
|
|
32
|
-
// Put the footnotes back in
|
|
33
|
-
if (footnotes) tree.children.push(...Object.values(footnotes));
|
|
34
|
-
const opts = await fetchImagesAsBuffers(tree);
|
|
35
|
-
const docxBlob = await (unified()
|
|
36
|
-
.use(mystToDocx, opts)
|
|
37
|
-
.stringify(tree as any).result as DocxResult);
|
|
38
|
-
downloadBlob(filename, docxBlob as Blob);
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
async function parse(text: string, defaultFrontmatter?: PageFrontmatter) {
|
|
42
|
-
// Ensure that any imports from myst are async and scoped to this function
|
|
43
|
-
const { visit } = await import('unist-util-visit');
|
|
44
|
-
const { unified } = await import('unified');
|
|
45
|
-
const { MyST } = await import('mystjs');
|
|
46
|
-
const {
|
|
47
|
-
mathPlugin,
|
|
48
|
-
footnotesPlugin,
|
|
49
|
-
keysPlugin,
|
|
50
|
-
basicTransformationsPlugin,
|
|
51
|
-
enumerateTargetsPlugin,
|
|
52
|
-
resolveReferencesPlugin,
|
|
53
|
-
WikiTransformer,
|
|
54
|
-
DOITransformer,
|
|
55
|
-
RRIDTransformer,
|
|
56
|
-
linksPlugin,
|
|
57
|
-
ReferenceState,
|
|
58
|
-
getFrontmatter,
|
|
59
|
-
} = await import('myst-transforms');
|
|
60
|
-
const { default: mystToTex } = await import('myst-to-tex');
|
|
61
|
-
const myst = new MyST();
|
|
62
|
-
const mdast = myst.parse(text);
|
|
63
|
-
const linkTransforms = [new WikiTransformer(), new DOITransformer(), new RRIDTransformer()];
|
|
64
|
-
// For the mdast that we show, duplicate, strip positions and dump to yaml
|
|
65
|
-
// Also run some of the transforms, like the links
|
|
66
|
-
const mdastPre = JSON.parse(JSON.stringify(mdast));
|
|
67
|
-
unified().use(linksPlugin, { transformers: linkTransforms }).runSync(mdastPre);
|
|
68
|
-
visit(mdastPre, (n) => delete n.position);
|
|
69
|
-
const mdastString = yaml.dump(mdastPre);
|
|
70
|
-
const htmlString = myst.renderMdast(mdastPre);
|
|
71
|
-
const file = new VFile();
|
|
72
|
-
const references = {
|
|
73
|
-
cite: { order: [], data: {} },
|
|
74
|
-
footnotes: {},
|
|
75
|
-
};
|
|
76
|
-
const { frontmatter } = getFrontmatter(mdast, { removeYaml: true, removeHeading: false });
|
|
77
|
-
const state = new ReferenceState({
|
|
78
|
-
numbering: frontmatter.numbering ?? defaultFrontmatter?.numbering,
|
|
79
|
-
file,
|
|
80
|
-
});
|
|
81
|
-
unified()
|
|
82
|
-
.use(basicTransformationsPlugin)
|
|
83
|
-
.use(mathPlugin, { macros: frontmatter?.math ?? {} }) // This must happen before enumeration, as it can add labels
|
|
84
|
-
.use(enumerateTargetsPlugin, { state })
|
|
85
|
-
.use(linksPlugin, { transformers: linkTransforms })
|
|
86
|
-
.use(footnotesPlugin, { references })
|
|
87
|
-
.use(resolveReferencesPlugin, { state })
|
|
88
|
-
.use(keysPlugin)
|
|
89
|
-
.runSync(mdast as any, file);
|
|
90
|
-
const tex = unified()
|
|
91
|
-
.use(mystToTex)
|
|
92
|
-
.stringify(mdast as any).result as LatexResult;
|
|
93
|
-
const content = useParse(mdast as any);
|
|
94
|
-
return {
|
|
95
|
-
yaml: mdastString,
|
|
96
|
-
references: { ...references, article: mdast } as References,
|
|
97
|
-
html: htmlString,
|
|
98
|
-
tex: tex.value,
|
|
99
|
-
content,
|
|
100
|
-
warnings: file.messages,
|
|
101
|
-
};
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
export function MySTRenderer({ value, numbering }: { value: string; numbering: any }) {
|
|
105
|
-
const area = useRef<HTMLTextAreaElement | null>(null);
|
|
106
|
-
const [text, setText] = useState<string>(value.trim());
|
|
107
|
-
const [references, setReferences] = useState<References>({});
|
|
108
|
-
const [mdastYaml, setYaml] = useState<string>('Loading...');
|
|
109
|
-
const [html, setHtml] = useState<string>('Loading...');
|
|
110
|
-
const [tex, setTex] = useState<string>('Loading...');
|
|
111
|
-
const [warnings, setWarnings] = useState<VFileMessage[]>([]);
|
|
112
|
-
const [content, setContent] = useState<React.ReactNode>(<p>{value}</p>);
|
|
113
|
-
const [previewType, setPreviewType] = useState('DEMO');
|
|
114
|
-
|
|
115
|
-
useEffect(() => {
|
|
116
|
-
const ref = { current: true };
|
|
117
|
-
parse(text, { numbering }).then((result) => {
|
|
118
|
-
if (!ref.current) return;
|
|
119
|
-
setYaml(result.yaml);
|
|
120
|
-
setReferences(result.references);
|
|
121
|
-
setHtml(result.html);
|
|
122
|
-
setTex(result.tex);
|
|
123
|
-
setContent(result.content);
|
|
124
|
-
setWarnings(result.warnings);
|
|
125
|
-
});
|
|
126
|
-
return () => {
|
|
127
|
-
ref.current = false;
|
|
128
|
-
};
|
|
129
|
-
}, [text]);
|
|
130
|
-
|
|
131
|
-
useEffect(() => {
|
|
132
|
-
if (!area.current) return;
|
|
133
|
-
area.current.style.height = 'auto'; // for the scroll area in the next step!
|
|
134
|
-
area.current.style.height = `${area.current.scrollHeight}px`;
|
|
135
|
-
}, [text]);
|
|
136
|
-
|
|
137
|
-
return (
|
|
138
|
-
<figure className="relative shadow-lg rounded">
|
|
139
|
-
<div className="absolute right-0 p-1">
|
|
140
|
-
<CopyIcon text={text} />
|
|
141
|
-
</div>
|
|
142
|
-
<div className="myst">
|
|
143
|
-
<label>
|
|
144
|
-
<span className="sr-only">Edit the MyST text</span>
|
|
145
|
-
<textarea
|
|
146
|
-
ref={area}
|
|
147
|
-
value={text}
|
|
148
|
-
className="block p-6 shadow-inner resize-none w-full font-mono bg-slate-50 dark:bg-slate-800 outline-none"
|
|
149
|
-
onChange={(e) => setText(e.target.value)}
|
|
150
|
-
></textarea>
|
|
151
|
-
</label>
|
|
152
|
-
</div>
|
|
153
|
-
{/* The `exclude-from-outline` class is excluded from the document outline */}
|
|
154
|
-
<div className="exclude-from-outline relative min-h-1 pt-[50px] px-6 pb-6 dark:bg-slate-900">
|
|
155
|
-
<div className="absolute cursor-pointer top-0 left-0 border dark:border-slate-600">
|
|
156
|
-
{['DEMO', 'AST', 'HTML', 'LaTeX'].map((show) => (
|
|
157
|
-
<button
|
|
158
|
-
key={show}
|
|
159
|
-
className={classnames('px-2', {
|
|
160
|
-
'bg-white hover:bg-slate-200 dark:bg-slate-500 dark:hover:bg-slate-700':
|
|
161
|
-
previewType !== show,
|
|
162
|
-
'bg-blue-800 text-white': previewType === show,
|
|
163
|
-
})}
|
|
164
|
-
title={`Show the ${show}`}
|
|
165
|
-
aria-label={`Show the ${show}`}
|
|
166
|
-
aria-pressed={previewType === show ? 'true' : 'false'}
|
|
167
|
-
onClick={() => setPreviewType(show)}
|
|
168
|
-
>
|
|
169
|
-
{show}
|
|
170
|
-
</button>
|
|
171
|
-
))}
|
|
172
|
-
<button
|
|
173
|
-
className={classnames(
|
|
174
|
-
'px-2',
|
|
175
|
-
'bg-white hover:bg-slate-200 dark:bg-slate-500 dark:hover:bg-slate-700',
|
|
176
|
-
)}
|
|
177
|
-
title={`Download Micorsoft Word`}
|
|
178
|
-
aria-label={`Download Micorsoft Word`}
|
|
179
|
-
onClick={() => saveDocxFile('demo.docx', references.article, references.footnotes)}
|
|
180
|
-
>
|
|
181
|
-
DOCX
|
|
182
|
-
</button>
|
|
183
|
-
</div>
|
|
184
|
-
{previewType === 'DEMO' && (
|
|
185
|
-
<ReferencesProvider references={references}>{content}</ReferencesProvider>
|
|
186
|
-
)}
|
|
187
|
-
{previewType === 'AST' && <CodeBlock lang="yaml" value={mdastYaml} showCopy={false} />}
|
|
188
|
-
{previewType === 'HTML' && <CodeBlock lang="xml" value={html} showCopy={false} />}
|
|
189
|
-
{previewType === 'LaTeX' && <CodeBlock lang="latex" value={tex} showCopy={false} />}
|
|
190
|
-
</div>
|
|
191
|
-
{previewType === 'DEMO' && warnings.length > 0 && (
|
|
192
|
-
<div>
|
|
193
|
-
{warnings.map((m) => (
|
|
194
|
-
<div
|
|
195
|
-
className={classnames('p-1 shadow-inner text-white not-prose', {
|
|
196
|
-
'bg-red-500 dark:bg-red-800': m.fatal === true,
|
|
197
|
-
'bg-orange-500 dark:bg-orange-700': m.fatal === false,
|
|
198
|
-
'bg-slate-500 dark:bg-slate-800': m.fatal === null,
|
|
199
|
-
})}
|
|
200
|
-
>
|
|
201
|
-
{m.fatal === true && <ExclamationCircleIcon className="inline h-[1.3em] mr-1" />}
|
|
202
|
-
{m.fatal === false && <ExclamationIcon className="inline h-[1.3em] mr-1" />}
|
|
203
|
-
{m.fatal === null && <InformationCircleIcon className="inline h-[1.3em] mr-1" />}
|
|
204
|
-
<code>{m.ruleId || m.source}</code>: {m.message}
|
|
205
|
-
</div>
|
|
206
|
-
))}
|
|
207
|
-
</div>
|
|
208
|
-
)}
|
|
209
|
-
</figure>
|
|
210
|
-
);
|
|
211
|
-
}
|
|
212
|
-
|
|
213
|
-
const MystNodeRenderer: NodeRenderer = (node) => {
|
|
214
|
-
return <MySTRenderer key={node.key} value={node.value} numbering={node.numbering} />;
|
|
215
|
-
};
|
|
216
|
-
|
|
217
|
-
const MYST_RENDERERS = {
|
|
218
|
-
myst: MystNodeRenderer,
|
|
219
|
-
};
|
|
220
|
-
|
|
221
|
-
export default MYST_RENDERERS;
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import { useEffect, useRef } from 'react';
|
|
2
|
-
import { useLongContent } from './hooks';
|
|
3
|
-
|
|
4
|
-
export const MaybeLongContent = ({
|
|
5
|
-
content,
|
|
6
|
-
path,
|
|
7
|
-
render,
|
|
8
|
-
}: {
|
|
9
|
-
content?: string;
|
|
10
|
-
path?: string;
|
|
11
|
-
render: (content: string) => JSX.Element;
|
|
12
|
-
}) => {
|
|
13
|
-
const { error, data } = useLongContent(content, path);
|
|
14
|
-
if (error) {
|
|
15
|
-
return <div className="text-red-500">Error loading content: {error.message}</div>;
|
|
16
|
-
}
|
|
17
|
-
if (!data) {
|
|
18
|
-
return <div>Fetching long content....</div>;
|
|
19
|
-
}
|
|
20
|
-
return <div>{render(data.content)}</div>;
|
|
21
|
-
};
|
|
22
|
-
|
|
23
|
-
export const DangerousHTML = ({ content, ...rest }: { content: string }) => {
|
|
24
|
-
const ref = useRef<HTMLDivElement | null>(null);
|
|
25
|
-
|
|
26
|
-
useEffect(() => {
|
|
27
|
-
if (!content || !ref.current) return;
|
|
28
|
-
const el = document.createRange().createContextualFragment(content);
|
|
29
|
-
ref.current.innerHTML = '';
|
|
30
|
-
ref.current.appendChild(el);
|
|
31
|
-
}, [content, ref]);
|
|
32
|
-
|
|
33
|
-
return <div {...rest} ref={ref} />;
|
|
34
|
-
};
|
package/src/output/error.tsx
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import Ansi from 'ansi-to-react';
|
|
2
|
-
import { ensureString } from '@curvenote/blocks';
|
|
3
|
-
import type { MinifiedErrorOutput } from '@curvenote/nbtx';
|
|
4
|
-
import { MaybeLongContent } from './components';
|
|
5
|
-
|
|
6
|
-
export default function Error({ output }: { output: MinifiedErrorOutput }) {
|
|
7
|
-
return (
|
|
8
|
-
<MaybeLongContent
|
|
9
|
-
content={ensureString(output.traceback)}
|
|
10
|
-
path={output.path}
|
|
11
|
-
render={(content?: string) => {
|
|
12
|
-
return (
|
|
13
|
-
<pre className="text-sm font-thin font-system jupyter-error">
|
|
14
|
-
<Ansi>{content ?? ''}</Ansi>
|
|
15
|
-
</pre>
|
|
16
|
-
);
|
|
17
|
-
}}
|
|
18
|
-
/>
|
|
19
|
-
);
|
|
20
|
-
}
|
package/src/output/hooks.ts
DELETED
|
@@ -1,127 +0,0 @@
|
|
|
1
|
-
import useSWRImmutable from 'swr/immutable';
|
|
2
|
-
import type {
|
|
3
|
-
MinifiedErrorOutput,
|
|
4
|
-
MinifiedMimeBundle,
|
|
5
|
-
MinifiedMimePayload,
|
|
6
|
-
MinifiedOutput,
|
|
7
|
-
MinifiedStreamOutput,
|
|
8
|
-
} from '@curvenote/nbtx/dist/minify/types';
|
|
9
|
-
import { walkPaths } from '@curvenote/nbtx/dist/minify/utils';
|
|
10
|
-
import { useState, useLayoutEffect } from 'react';
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* Truncation vs Summarization
|
|
14
|
-
*
|
|
15
|
-
* In Curvespace, we're decided to change our data structure for outputs to align it as
|
|
16
|
-
* closely as possible with Jupyters nbformat.IOutput[] type, but in a way that still allows
|
|
17
|
-
* us to truncate output content and push that to storage.
|
|
18
|
-
*
|
|
19
|
-
* This will be used only in the CLI and Curvespace initially but should be ported back to
|
|
20
|
-
* the rest of the code base. This will mean
|
|
21
|
-
*
|
|
22
|
-
* - changing the DB schema
|
|
23
|
-
* - migration
|
|
24
|
-
* - changing API response
|
|
25
|
-
* - changing the frontend
|
|
26
|
-
* - changing the extension
|
|
27
|
-
*
|
|
28
|
-
*/
|
|
29
|
-
|
|
30
|
-
interface LongContent {
|
|
31
|
-
content_type?: string;
|
|
32
|
-
content: string;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
const fetcher = (...args: Parameters<typeof fetch>) =>
|
|
36
|
-
fetch(...args).then((res) => {
|
|
37
|
-
if (res.status === 200) return res.json();
|
|
38
|
-
throw new Error(`Content returned with status ${res.status}.`);
|
|
39
|
-
});
|
|
40
|
-
|
|
41
|
-
export function useLongContent(
|
|
42
|
-
content?: string,
|
|
43
|
-
url?: string,
|
|
44
|
-
): { data?: LongContent; error?: Error } {
|
|
45
|
-
if (typeof document === 'undefined') {
|
|
46
|
-
// This is ONLY called on the server
|
|
47
|
-
return url ? {} : { data: { content: content ?? '' } };
|
|
48
|
-
}
|
|
49
|
-
const { data, error } = useSWRImmutable<LongContent>(url || null, fetcher);
|
|
50
|
-
if (!url) return { data: { content: content ?? '' } };
|
|
51
|
-
return { data, error };
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
const arrayFetcher = (...urls: string[]) => {
|
|
55
|
-
return Promise.all(urls.map((url) => fetcher(url)));
|
|
56
|
-
};
|
|
57
|
-
|
|
58
|
-
type ObjectWithPath = MinifiedErrorOutput | MinifiedStreamOutput | MinifiedMimePayload;
|
|
59
|
-
|
|
60
|
-
function shallowCloneOutputs(outputs: MinifiedOutput[]) {
|
|
61
|
-
return outputs.map((output) => {
|
|
62
|
-
if ('data' in output && output.data) {
|
|
63
|
-
const data = output.data as MinifiedMimeBundle;
|
|
64
|
-
return {
|
|
65
|
-
...output,
|
|
66
|
-
data: Object.entries(data).reduce((acc, [mimetype, payload]) => {
|
|
67
|
-
return { ...acc, [mimetype]: { ...payload } };
|
|
68
|
-
}, {}),
|
|
69
|
-
};
|
|
70
|
-
}
|
|
71
|
-
return { ...output };
|
|
72
|
-
});
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
export function useFetchAnyTruncatedContent(outputs: MinifiedOutput[]) {
|
|
76
|
-
const itemsWithPaths: ObjectWithPath[] = [];
|
|
77
|
-
const updated = shallowCloneOutputs(outputs);
|
|
78
|
-
|
|
79
|
-
walkPaths(updated, (path, obj) => {
|
|
80
|
-
// images have paths, but we don't need to fetch them
|
|
81
|
-
if ('content_type' in obj && (obj as MinifiedMimePayload).content_type.startsWith('image/'))
|
|
82
|
-
return;
|
|
83
|
-
obj.path = path;
|
|
84
|
-
itemsWithPaths.push(obj);
|
|
85
|
-
});
|
|
86
|
-
|
|
87
|
-
const { data, error } = useSWRImmutable<LongContent[]>(
|
|
88
|
-
itemsWithPaths.map(({ path }) => path),
|
|
89
|
-
arrayFetcher,
|
|
90
|
-
);
|
|
91
|
-
|
|
92
|
-
data?.forEach(({ content }, idx) => {
|
|
93
|
-
const obj = itemsWithPaths[idx];
|
|
94
|
-
if ('text' in obj) obj.text = content; // stream
|
|
95
|
-
if ('traceback' in obj) obj.traceback = content; // error
|
|
96
|
-
if ('content' in obj) obj.content = content; // mimeoutput
|
|
97
|
-
obj.path = undefined;
|
|
98
|
-
});
|
|
99
|
-
|
|
100
|
-
return {
|
|
101
|
-
data: itemsWithPaths.length === 0 || data ? updated : undefined,
|
|
102
|
-
error,
|
|
103
|
-
};
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
function getWindowSize() {
|
|
107
|
-
const { innerWidth: width, innerHeight: height } = window;
|
|
108
|
-
return {
|
|
109
|
-
width,
|
|
110
|
-
height,
|
|
111
|
-
};
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
export default function useWindowSize() {
|
|
115
|
-
const [windowSize, setWindowSize] = useState(getWindowSize());
|
|
116
|
-
|
|
117
|
-
useLayoutEffect(() => {
|
|
118
|
-
function handleResize() {
|
|
119
|
-
setWindowSize(getWindowSize());
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
window.addEventListener('resize', handleResize);
|
|
123
|
-
return () => window.removeEventListener('resize', handleResize);
|
|
124
|
-
}, []);
|
|
125
|
-
|
|
126
|
-
return windowSize;
|
|
127
|
-
}
|