@quarto/jupyterlab-quarto 0.1.27

Sign up to get free protection for your applications and to get access to all the features.
Files changed (168) hide show
  1. package/LICENSE +29 -0
  2. package/README.md +71 -0
  3. package/lib/const.d.ts +5 -0
  4. package/lib/const.js +11 -0
  5. package/lib/const.js.map +1 -0
  6. package/lib/hooks/codemirror.d.ts +4 -0
  7. package/lib/hooks/codemirror.js +51 -0
  8. package/lib/hooks/codemirror.js.map +1 -0
  9. package/lib/index.d.ts +6 -0
  10. package/lib/index.js +57 -0
  11. package/lib/index.js.map +1 -0
  12. package/lib/manager.d.ts +8 -0
  13. package/lib/manager.js +116 -0
  14. package/lib/manager.js.map +1 -0
  15. package/lib/plugins/callouts.d.ts +3 -0
  16. package/lib/plugins/callouts.js +208 -0
  17. package/lib/plugins/callouts.js.map +1 -0
  18. package/lib/plugins/cites.d.ts +3 -0
  19. package/lib/plugins/cites.js +147 -0
  20. package/lib/plugins/cites.js.map +1 -0
  21. package/lib/plugins/decorator.d.ts +3 -0
  22. package/lib/plugins/decorator.js +58 -0
  23. package/lib/plugins/decorator.js.map +1 -0
  24. package/lib/plugins/divs.d.ts +6 -0
  25. package/lib/plugins/divs.js +99 -0
  26. package/lib/plugins/divs.js.map +1 -0
  27. package/lib/plugins/figure-divs.d.ts +3 -0
  28. package/lib/plugins/figure-divs.js +52 -0
  29. package/lib/plugins/figure-divs.js.map +1 -0
  30. package/lib/plugins/figures.d.ts +17 -0
  31. package/lib/plugins/figures.js +98 -0
  32. package/lib/plugins/figures.js.map +1 -0
  33. package/lib/plugins/gridtables/common/gridtables/GetCells.d.ts +8 -0
  34. package/lib/plugins/gridtables/common/gridtables/GetCells.js +44 -0
  35. package/lib/plugins/gridtables/common/gridtables/GetCells.js.map +1 -0
  36. package/lib/plugins/gridtables/common/gridtables/GetColumnWidths.d.ts +8 -0
  37. package/lib/plugins/gridtables/common/gridtables/GetColumnWidths.js +26 -0
  38. package/lib/plugins/gridtables/common/gridtables/GetColumnWidths.js.map +1 -0
  39. package/lib/plugins/gridtables/common/markdown-it/ColumnAlignments.d.ts +8 -0
  40. package/lib/plugins/gridtables/common/markdown-it/ColumnAlignments.js +12 -0
  41. package/lib/plugins/gridtables/common/markdown-it/ColumnAlignments.js.map +1 -0
  42. package/lib/plugins/gridtables/common/markdown-it/EmitTable.d.ts +5 -0
  43. package/lib/plugins/gridtables/common/markdown-it/EmitTable.js +66 -0
  44. package/lib/plugins/gridtables/common/markdown-it/EmitTable.js.map +1 -0
  45. package/lib/plugins/gridtables/common/markdown-it/GetCharCodeAtStartOfLine.d.ts +9 -0
  46. package/lib/plugins/gridtables/common/markdown-it/GetCharCodeAtStartOfLine.js +18 -0
  47. package/lib/plugins/gridtables/common/markdown-it/GetCharCodeAtStartOfLine.js.map +1 -0
  48. package/lib/plugins/gridtables/common/markdown-it/GetLine.d.ts +3 -0
  49. package/lib/plugins/gridtables/common/markdown-it/GetLine.js +9 -0
  50. package/lib/plugins/gridtables/common/markdown-it/GetLine.js.map +1 -0
  51. package/lib/plugins/gridtables/common/markdown-it/ParseTable.d.ts +4 -0
  52. package/lib/plugins/gridtables/common/markdown-it/ParseTable.js +161 -0
  53. package/lib/plugins/gridtables/common/markdown-it/ParseTable.js.map +1 -0
  54. package/lib/plugins/gridtables/common/markdown-it/ParseTableResult.d.ts +13 -0
  55. package/lib/plugins/gridtables/common/markdown-it/ParseTableResult.js +17 -0
  56. package/lib/plugins/gridtables/common/markdown-it/ParseTableResult.js.map +1 -0
  57. package/lib/plugins/gridtables/index.d.ts +2 -0
  58. package/lib/plugins/gridtables/index.js +8 -0
  59. package/lib/plugins/gridtables/index.js.map +1 -0
  60. package/lib/plugins/gridtables/interfaces/markdown-it/IState.d.ts +11 -0
  61. package/lib/plugins/gridtables/interfaces/markdown-it/IState.js +5 -0
  62. package/lib/plugins/gridtables/interfaces/markdown-it/IState.js.map +1 -0
  63. package/lib/plugins/gridtables/interfaces/markdown-it/IToken.d.ts +7 -0
  64. package/lib/plugins/gridtables/interfaces/markdown-it/IToken.js +5 -0
  65. package/lib/plugins/gridtables/interfaces/markdown-it/IToken.js.map +1 -0
  66. package/lib/plugins/gridtables/interfaces/markdown-it/TRuleFunction.d.ts +4 -0
  67. package/lib/plugins/gridtables/interfaces/markdown-it/TRuleFunction.js +5 -0
  68. package/lib/plugins/gridtables/interfaces/markdown-it/TRuleFunction.js.map +1 -0
  69. package/lib/plugins/gridtables/rules/gridtable.d.ts +4 -0
  70. package/lib/plugins/gridtables/rules/gridtable.js +25 -0
  71. package/lib/plugins/gridtables/rules/gridtable.js.map +1 -0
  72. package/lib/plugins/math.d.ts +5 -0
  73. package/lib/plugins/math.js +174 -0
  74. package/lib/plugins/math.js.map +1 -0
  75. package/lib/plugins/mermaid/index.d.ts +3 -0
  76. package/lib/plugins/mermaid/index.js +53 -0
  77. package/lib/plugins/mermaid/index.js.map +1 -0
  78. package/lib/plugins/spans.d.ts +3 -0
  79. package/lib/plugins/spans.js +38 -0
  80. package/lib/plugins/table-captions.d.ts +3 -0
  81. package/lib/plugins/table-captions.js +74 -0
  82. package/lib/plugins/table-captions.js.map +1 -0
  83. package/lib/plugins/yaml.d.ts +3 -0
  84. package/lib/plugins/yaml.js +309 -0
  85. package/lib/plugins/yaml.js.map +1 -0
  86. package/lib/providers/attrs.d.ts +2 -0
  87. package/lib/providers/attrs.js +15 -0
  88. package/lib/providers/attrs.js.map +1 -0
  89. package/lib/providers/callouts.d.ts +2 -0
  90. package/lib/providers/callouts.js +15 -0
  91. package/lib/providers/callouts.js.map +1 -0
  92. package/lib/providers/cites.d.ts +2 -0
  93. package/lib/providers/cites.js +15 -0
  94. package/lib/providers/cites.js.map +1 -0
  95. package/lib/providers/decorator.d.ts +2 -0
  96. package/lib/providers/decorator.js +15 -0
  97. package/lib/providers/decorator.js.map +1 -0
  98. package/lib/providers/deflist.d.ts +2 -0
  99. package/lib/providers/deflist.js +15 -0
  100. package/lib/providers/deflist.js.map +1 -0
  101. package/lib/providers/divs.d.ts +2 -0
  102. package/lib/providers/divs.js +27 -0
  103. package/lib/providers/divs.js.map +1 -0
  104. package/lib/providers/figure-divs.d.ts +2 -0
  105. package/lib/providers/figure-divs.js +15 -0
  106. package/lib/providers/figure-divs.js.map +1 -0
  107. package/lib/providers/figures.d.ts +2 -0
  108. package/lib/providers/figures.js +15 -0
  109. package/lib/providers/figures.js.map +1 -0
  110. package/lib/providers/footnotes.d.ts +2 -0
  111. package/lib/providers/footnotes.js +15 -0
  112. package/lib/providers/footnotes.js.map +1 -0
  113. package/lib/providers/gridtables.d.ts +2 -0
  114. package/lib/providers/gridtables.js +15 -0
  115. package/lib/providers/gridtables.js.map +1 -0
  116. package/lib/providers/math.d.ts +2 -0
  117. package/lib/providers/math.js +104 -0
  118. package/lib/providers/math.js.map +1 -0
  119. package/lib/providers/mermaid.d.ts +2 -0
  120. package/lib/providers/mermaid.js +13 -0
  121. package/lib/providers/mermaid.js.map +1 -0
  122. package/lib/providers/provider.d.ts +4 -0
  123. package/lib/providers/provider.js +12 -0
  124. package/lib/providers/provider.js.map +1 -0
  125. package/lib/providers/spans.d.ts +2 -0
  126. package/lib/providers/spans.js +15 -0
  127. package/lib/providers/sub.d.ts +2 -0
  128. package/lib/providers/sub.js +15 -0
  129. package/lib/providers/sub.js.map +1 -0
  130. package/lib/providers/sup.d.ts +2 -0
  131. package/lib/providers/sup.js +15 -0
  132. package/lib/providers/sup.js.map +1 -0
  133. package/lib/providers/table-captions.d.ts +2 -0
  134. package/lib/providers/table-captions.js +15 -0
  135. package/lib/providers/table-captions.js.map +1 -0
  136. package/lib/providers/tasklists.d.ts +2 -0
  137. package/lib/providers/tasklists.js +15 -0
  138. package/lib/providers/tasklists.js.map +1 -0
  139. package/lib/providers/yaml.d.ts +2 -0
  140. package/lib/providers/yaml.js +15 -0
  141. package/lib/providers/yaml.js.map +1 -0
  142. package/lib/types.d.ts +44 -0
  143. package/lib/types.js +1 -0
  144. package/lib/types.js.map +1 -0
  145. package/lib/utils/html.d.ts +12 -0
  146. package/lib/utils/html.js +45 -0
  147. package/lib/utils/html.js.map +1 -0
  148. package/lib/utils/markdownit.d.ts +4 -0
  149. package/lib/utils/markdownit.js +44 -0
  150. package/lib/utils/markdownit.js.map +1 -0
  151. package/lib/utils/tok.d.ts +8 -0
  152. package/lib/utils/tok.js +13 -0
  153. package/lib/utils/tok.js.map +1 -0
  154. package/lib/widgets.d.ts +15 -0
  155. package/lib/widgets.js +57 -0
  156. package/lib/widgets.js.map +1 -0
  157. package/package.json +120 -0
  158. package/schema/plugin.json +8 -0
  159. package/src/@types/markdown-it-deflist.d.ts +10 -0
  160. package/src/@types/markdown-it-footnote.d.ts +10 -0
  161. package/src/@types/markdown-it-gridtables.d.ts +10 -0
  162. package/src/@types/markdown-it-implicit-figures.d.ts +10 -0
  163. package/src/@types/markdown-it-sub.d.ts +10 -0
  164. package/src/@types/markdown-it-sup.d.ts +10 -0
  165. package/src/@types/markdown-it-task-lists.d.ts +10 -0
  166. package/style/base.css +340 -0
  167. package/style/index.css +1 -0
  168. package/style/index.js +1 -0
package/LICENSE ADDED
@@ -0,0 +1,29 @@
1
+ BSD 3-Clause License
2
+
3
+ Copyright (c) 2023, Charles Teague
4
+ All rights reserved.
5
+
6
+ Redistribution and use in source and binary forms, with or without
7
+ modification, are permitted provided that the following conditions are met:
8
+
9
+ 1. Redistributions of source code must retain the above copyright notice, this
10
+ list of conditions and the following disclaimer.
11
+
12
+ 2. Redistributions in binary form must reproduce the above copyright notice,
13
+ this list of conditions and the following disclaimer in the documentation
14
+ and/or other materials provided with the distribution.
15
+
16
+ 3. Neither the name of the copyright holder nor the names of its
17
+ contributors may be used to endorse or promote products derived from
18
+ this software without specific prior written permission.
19
+
20
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21
+ AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
23
+ DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
24
+ FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25
+ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
26
+ SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
27
+ CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
28
+ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29
+ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
package/README.md ADDED
@@ -0,0 +1,71 @@
1
+ # jupyterlab-quarto
2
+
3
+ ## Requirements
4
+
5
+ - JupyterLab >= 3.0
6
+
7
+ ## Install
8
+
9
+ To install the extension, execute:
10
+
11
+ ```bash
12
+ pip install jupyterlab-quarto
13
+ ```
14
+
15
+ ## Uninstall
16
+
17
+ To remove the extension, execute:
18
+
19
+ ```bash
20
+ pip uninstall jupyterlab-quarto
21
+ ```
22
+
23
+ ## Contributing
24
+
25
+ ### Development install
26
+
27
+ ```bash
28
+ # From apps/jupyterlab
29
+ # Install package in development mode
30
+ pip install -e "."
31
+ # Link your development version of the extension with JupyterLab
32
+ jupyter labextension develop . --overwrite
33
+ # Rebuild extension Typescript source after making changes
34
+ yarn build
35
+ ```
36
+ Note: You will need NodeJS to build the extension package.
37
+
38
+ Note: The `jlpm` command is JupyterLab's pinned version of
39
+ [yarn](https://yarnpkg.com/) that is installed with JupyterLab. You may use
40
+ `yarn` or `npm` in lieu of `jlpm` below.
41
+
42
+ You can watch the source directory and run JupyterLab at the same time in different terminals to watch for changes in the extension's source and automatically rebuild the extension.
43
+
44
+ ```bash
45
+ # Watch the source directory in one terminal, automatically rebuilding when needed
46
+ yarn watch
47
+ # Run JupyterLab in another terminal
48
+ jupyter lab
49
+ ```
50
+
51
+ With the watch command running, every saved change will immediately be built locally and available in your running JupyterLab. Refresh JupyterLab to load the change in your browser (you may need to wait several seconds for the extension to be rebuilt).
52
+
53
+ By default, the `build` command generates the source maps for this extension to make it easier to debug using the browser dev tools. To also generate source maps for the JupyterLab core extensions, you can run the following command:
54
+
55
+ ```bash
56
+ jupyter lab build --minimize=False
57
+ ```
58
+
59
+ ### Development uninstall
60
+
61
+ ```bash
62
+ pip uninstall jupyterlab-quarto
63
+ ```
64
+
65
+ In development mode, you will also need to remove the symlink created by `jupyter labextension develop`
66
+ command. To find its location, you can run `jupyter labextension list` to figure out where the `labextensions`
67
+ folder is located. Then you can remove the symlink named `jupyterlab-quarto` within that folder.
68
+
69
+ ### Packaging the extension
70
+
71
+ See [RELEASE](RELEASE.md)
package/lib/const.d.ts ADDED
@@ -0,0 +1,5 @@
1
+ import { Token } from '@lumino/coreutils';
2
+ import { MarkdownItManager } from "./types";
3
+ export declare const kPackageNamespace = "jupyterlab-quarto";
4
+ export declare const kMarkdownItMgr: Token<MarkdownItManager>;
5
+ //# sourceMappingURL=const.d.ts.map
package/lib/const.js ADDED
@@ -0,0 +1,11 @@
1
+ /*
2
+ * const.ts
3
+ *
4
+ * Copyright (C) 2020-2023 Posit Software, PBC
5
+ *
6
+ */
7
+ import { Token } from '@lumino/coreutils';
8
+ // The namespace for this project
9
+ export const kPackageNamespace = 'jupyterlab-quarto';
10
+ // The MarkdownIt manager token.
11
+ export const kMarkdownItMgr = new Token(kPackageNamespace);
@@ -0,0 +1 @@
1
+ {"version":3,"file":"const.js","sourceRoot":"","sources":["../src/const.ts"],"names":[],"mappings":"AAAA;;;;;EAKE;AACF,OAAO,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAI1C,iCAAiC;AACjC,MAAM,CAAC,MAAM,iBAAiB,GAAG,gBAAgB,CAAC;AAElD,gCAAgC;AAChC,MAAM,CAAC,MAAM,cAAc,GAAG,IAAI,KAAK,CAAoB,iBAAiB,CAAC,CAAC"}
@@ -0,0 +1,4 @@
1
+ import { Hook } from "../types";
2
+ export declare function codeMirrorPreloadHook(): Hook<string, string>;
3
+ export declare const codeMirrorHighlight: (str: string, lang: string) => string;
4
+ //# sourceMappingURL=codemirror.d.ts.map
@@ -0,0 +1,51 @@
1
+ /*
2
+ * hooks.ts
3
+ *
4
+ * Copyright (C) 2020-2023 Posit Software, PBC
5
+ *
6
+ */
7
+ import { Mode } from '@jupyterlab/codemirror';
8
+ export function codeMirrorPreloadHook() {
9
+ // TODO: Properly deal with {r}, {{r}} style expressions
10
+ const fenced = new RegExp(/^`{3}([^\s]+)/g);
11
+ return {
12
+ run: async (source) => {
13
+ const newModes = new Map();
14
+ let match;
15
+ while ((match = fenced.exec(source))) {
16
+ if (!newModes.has(match[1])) {
17
+ newModes.set(match[1], Mode.ensure(match[1]));
18
+ }
19
+ }
20
+ if (newModes.size) {
21
+ Promise.all(newModes.values()).catch(console.warn);
22
+ }
23
+ return source;
24
+ }
25
+ };
26
+ }
27
+ export const codeMirrorHighlight = (str, lang) => {
28
+ if (!lang) {
29
+ return ''; // use external default escaping
30
+ }
31
+ try {
32
+ const spec = Mode.findBest(lang);
33
+ if (!spec) {
34
+ console.warn(`No CodeMirror mode: ${lang}`);
35
+ return '';
36
+ }
37
+ const el = document.createElement('div');
38
+ try {
39
+ Mode.run(str, spec.mime, el);
40
+ return el.innerHTML;
41
+ }
42
+ catch (err) {
43
+ console.warn(`Failed to highlight ${lang} code`, err);
44
+ }
45
+ }
46
+ catch (err) {
47
+ console.warn(`No CodeMirror mode: ${lang}`);
48
+ console.warn(`Require CodeMirror mode error: ${err}`);
49
+ }
50
+ return '';
51
+ };
@@ -0,0 +1 @@
1
+ {"version":3,"file":"codemirror.js","sourceRoot":"","sources":["../../src/hooks/codemirror.ts"],"names":[],"mappings":"AAAA;;;;;EAKE;AAGF,OAAO,EAAE,IAAI,EAAE,MAAM,wBAAwB,CAAC;AAE9C,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AAE,EAAE,CAAC,CAAC;YAC7B,OAAO,EAAE,CAAC,SAAS,CAAC;SACrB;QAAC,OAAO,GAAG,EAAE;YACZ,OAAO,CAAC,IAAI,CAAC,uBAAuB,IAAI,OAAO,EAAE,GAAG,CAAC,CAAC;SACvD;KACF;IAAC,OAAO,GAAG,EAAE;QACZ,OAAO,CAAC,IAAI,CAAC,uBAAuB,IAAI,EAAE,CAAC,CAAC;QAC5C,OAAO,CAAC,IAAI,CAAC,kCAAkC,GAAG,EAAE,CAAC,CAAC;KACvD;IACD,OAAO,EAAE,CAAC;AACZ,CAAC,CAAC"}
package/lib/index.d.ts ADDED
@@ -0,0 +1,6 @@
1
+ import { JupyterFrontEnd, JupyterFrontEndPlugin } from '@jupyterlab/application';
2
+ import { MarkdownItManager } from './types';
3
+ import '../style/index.css';
4
+ declare const _default: (JupyterFrontEndPlugin<MarkdownItManager, JupyterFrontEnd.IShell, "desktop" | "mobile"> | JupyterFrontEndPlugin<void, JupyterFrontEnd.IShell, "desktop" | "mobile">)[];
5
+ export default _default;
6
+ //# sourceMappingURL=index.d.ts.map
package/lib/index.js ADDED
@@ -0,0 +1,57 @@
1
+ import { mermaid } from './providers/mermaid';
2
+ import { kMarkdownItMgr, kPackageNamespace } from './const';
3
+ import { footnotes } from './providers/footnotes';
4
+ import '../style/index.css';
5
+ import { markdownItManager } from './manager';
6
+ import { divs } from './providers/divs';
7
+ import { deflist } from './providers/deflist';
8
+ import { gridtables } from './providers/gridtables';
9
+ import { sub } from './providers/sub';
10
+ import { sup } from './providers/sup';
11
+ import { tasklists } from './providers/tasklists';
12
+ import { cites } from './providers/cites';
13
+ import { attrs } from './providers/attrs';
14
+ import { callouts } from './providers/callouts';
15
+ import { decorator } from './providers/decorator';
16
+ import { yaml } from './providers/yaml';
17
+ import { math } from './providers/math';
18
+ import { figures } from './providers/figures';
19
+ import { figureDivs } from './providers/figure-divs';
20
+ import { tableCaptions } from './providers/table-captions';
21
+ import { spans } from './providers/spans';
22
+ const plugin = {
23
+ id: `${kPackageNamespace}:plugin`,
24
+ autoStart: true,
25
+ provides: kMarkdownItMgr,
26
+ activate: (_app) => {
27
+ console.log('JupyterLab extension jupyterlab-quarto is activated!');
28
+ // Create a markdown rendering manager
29
+ return markdownItManager();
30
+ }
31
+ };
32
+ // Markdown It Extensions which provide base Pandoc behavior
33
+ const kPandocExtensions = [
34
+ footnotes,
35
+ spans,
36
+ attrs,
37
+ deflist,
38
+ figures,
39
+ gridtables,
40
+ sub,
41
+ sup,
42
+ tasklists,
43
+ divs,
44
+ math
45
+ ];
46
+ // Markdown It Extensions which provide Quarto specific behavior
47
+ const kQuartoExtensions = [
48
+ figureDivs,
49
+ tableCaptions,
50
+ cites,
51
+ mermaid,
52
+ callouts,
53
+ decorator,
54
+ yaml
55
+ ];
56
+ // The extensions that should be enabled for Jupyter
57
+ export default [plugin, ...kPandocExtensions, ...kQuartoExtensions];
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAYA,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAC9C,OAAO,EAAE,cAAc,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC;AAC5D,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAElD,OAAO,oBAAoB,CAAC;AAC5B,OAAO,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAC;AAC9C,OAAO,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AACxC,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAC9C,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AACpD,OAAO,EAAE,GAAG,EAAE,MAAM,iBAAiB,CAAC;AACtC,OAAO,EAAE,GAAG,EAAE,MAAM,iBAAiB,CAAC;AACtC,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAClD,OAAO,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAC1C,OAAO,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAC1C,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAChD,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAClD,OAAO,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AACxC,OAAO,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AACxC,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAC9C,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AACrD,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAE3D,MAAM,MAAM,GAA6C;IACvD,EAAE,EAAE,GAAG,iBAAiB,SAAS;IACjC,SAAS,EAAE,IAAI;IACf,QAAQ,EAAE,cAAc;IACxB,QAAQ,EAAE,CAAC,IAAqB,EAAE,EAAE;QAClC,OAAO,CAAC,GAAG,CAAC,mDAAmD,CAAC,CAAC;QAEjE,uCAAuC;QACvC,OAAO,iBAAiB,EAAE,CAAC;IAC7B,CAAC;CACF,CAAC;AAGF,4DAA4D;AAC5D,MAAM,iBAAiB,GAAG;IACxB,SAAS;IACT,KAAK;IACL,OAAO;IACP,OAAO;IACP,UAAU;IACV,GAAG;IACH,GAAG;IACH,SAAS;IACT,IAAI;IACJ,IAAI;CACL,CAAC;AAEF,gEAAgE;AAChE,MAAM,iBAAiB,GAAG;IACxB,UAAU;IACV,aAAa;IACb,KAAK;IACL,OAAO;IACP,QAAQ;IACR,SAAS;IACT,IAAI;CACL,CAAC;AAGF,oDAAoD;AACpD,eAAe,CAAC,MAAM,EAAE,GAAG,iBAAiB,EAAE,GAAG,iBAAiB,CAAE,CAAC"}
@@ -0,0 +1,8 @@
1
+ import { Options } from 'markdown-it';
2
+ import { RenderedMarkdown } from './widgets';
3
+ import { MarkdownItPluginProvider, Renderer } from './types';
4
+ export declare function markdownItManager(): {
5
+ registerPlugin(provider: MarkdownItPluginProvider): void;
6
+ getRenderer(widget: RenderedMarkdown, options?: Options): Promise<Renderer>;
7
+ };
8
+ //# sourceMappingURL=manager.d.ts.map
package/lib/manager.js ADDED
@@ -0,0 +1,116 @@
1
+ /*
2
+ * manager.ts
3
+ *
4
+ * Copyright (C) 2020-2023 Posit Software, PBC
5
+ *
6
+ */
7
+ import { markdownRendererFactory } from '@jupyterlab/rendermime';
8
+ import { CodeMirrorEditor } from '@jupyterlab/codemirror';
9
+ import MarkdownIt from 'markdown-it';
10
+ import { RenderedMarkdown } from './widgets';
11
+ import { codeMirrorHighlight, codeMirrorPreloadHook } from './hooks/codemirror';
12
+ // Provides resolved MarkdownIt options using the passed in options, the plugin
13
+ // options, and default options.
14
+ const resolveOptions = (widget, options, providers) => {
15
+ // Build options table
16
+ let allOptions = {
17
+ html: true,
18
+ linkify: true,
19
+ typographer: true,
20
+ langPrefix: `cm-s-${CodeMirrorEditor.defaultConfig.theme} language-`,
21
+ highlight: codeMirrorHighlight
22
+ };
23
+ for (const plugin of providers) {
24
+ if (plugin.options) {
25
+ try {
26
+ // Add options for this plugin
27
+ allOptions = { ...allOptions, ...plugin.options(widget) };
28
+ }
29
+ catch (err) {
30
+ console.warn(`Failed to get options from markdown-it plugin ${plugin.id}`, err);
31
+ }
32
+ }
33
+ }
34
+ return {
35
+ ...allOptions,
36
+ ...options
37
+ };
38
+ };
39
+ export function markdownItManager() {
40
+ // The plugin providers
41
+ const pluginProviders = new Map();
42
+ // The IMarkdownItManager
43
+ const manager = {
44
+ registerPlugin(provider) {
45
+ pluginProviders.set(provider.id, provider);
46
+ },
47
+ async getRenderer(widget, options = {}) {
48
+ var _a, _b, _c, _d;
49
+ // Fetch the list of providers
50
+ const providers = [...pluginProviders.values()];
51
+ providers.sort(sortRanked);
52
+ // Create MarkdownIt instance
53
+ const allOptions = resolveOptions(widget, options, providers);
54
+ let md = new MarkdownIt('default', allOptions);
55
+ // Lifecycle hooks
56
+ const preParseHooks = [];
57
+ const postRenderHooks = [];
58
+ // add mode pre-loading hook if using default highlighter
59
+ if (codeMirrorHighlight === allOptions.highlight) {
60
+ preParseHooks.push(codeMirrorPreloadHook());
61
+ }
62
+ // Build MarkdownIt and load lifecycle hooks
63
+ for (const provider of providers) {
64
+ try {
65
+ // Load MarkdownIt plugin
66
+ const [plugin, ...pluginOptions] = await provider.plugin();
67
+ // Build MarkdownIt instance
68
+ md = md.use(plugin, ...pluginOptions);
69
+ // Build table of lifecycle hooks
70
+ if (((_a = provider.hooks) === null || _a === void 0 ? void 0 : _a.preParse) !== undefined) {
71
+ preParseHooks.push((_b = provider.hooks) === null || _b === void 0 ? void 0 : _b.preParse);
72
+ }
73
+ if (((_c = provider.hooks) === null || _c === void 0 ? void 0 : _c.postRender) !== undefined) {
74
+ postRenderHooks.push((_d = provider.hooks) === null || _d === void 0 ? void 0 : _d.postRender);
75
+ }
76
+ }
77
+ catch (err) {
78
+ console.warn(`Failed to load/use markdown-it plugin ${provider.id}`, err);
79
+ }
80
+ }
81
+ // Sort hooks by rank
82
+ preParseHooks.sort(sortRanked);
83
+ postRenderHooks.sort(sortRanked);
84
+ return {
85
+ // Parse and render Markdown
86
+ render: (content) => {
87
+ return md.render(content);
88
+ },
89
+ // Run hooks serially
90
+ preParse: async (content) => {
91
+ for (const hook of preParseHooks) {
92
+ content = await hook.run(content);
93
+ }
94
+ return content;
95
+ },
96
+ // Run hooks serially
97
+ postRender: async (node) => {
98
+ for (const hook of postRenderHooks) {
99
+ await hook.run(node);
100
+ }
101
+ }
102
+ };
103
+ }
104
+ };
105
+ // Register the Renderer
106
+ markdownRendererFactory.createRenderer = (options) => {
107
+ return new RenderedMarkdown(options, manager);
108
+ };
109
+ return manager;
110
+ }
111
+ // Sorts by rank, using 100 if no default is provided.
112
+ const kDefaultRank = 100;
113
+ const sortRanked = (left, right) => {
114
+ var _a, _b;
115
+ return ((_a = left.rank) !== null && _a !== void 0 ? _a : kDefaultRank) - ((_b = right.rank) !== null && _b !== void 0 ? _b : kD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I,mCAAI,YAAY,CAAC,GAAG,OAAC,KAAK,CAAC,IAAI,mCAAI,YAAY,CAAC,CAAC;AACpE,CAAC,CAAA"}
@@ -0,0 +1,3 @@
1
+ import type MarkdownIt from "markdown-it/lib";
2
+ export declare const calloutPlugin: (md: MarkdownIt) => void;
3
+ //# sourceMappingURL=callouts.d.ts.map
@@ -0,0 +1,208 @@
1
+ import Token from "markdown-it/lib/token";
2
+ import { addClass, readAttrValue } from "../utils/markdownit";
3
+ import { kTokDivClose, kTokDivOpen } from "./divs";
4
+ const kTokCalloutOpen = "quarto_callout_open";
5
+ const kTokCalloutClose = "quarto_callout_close";
6
+ const kTokCalloutTitleOpen = "quarto_callout_title_open";
7
+ const kTokCalloutTitleClose = "quarto_callout_title_close";
8
+ const kTokCalloutContentOpen = "quarto_callout_content_open";
9
+ const kTokCalloutContentClose = "quarto_callout_content_close";
10
+ const kCalloutPrefix = "callout-";
11
+ const kCalloutRuleName = "quarto-callouts";
12
+ export const calloutPlugin = (md) => {
13
+ // Handle pandoc-style divs
14
+ md.core.ruler.push(kCalloutRuleName, (state) => {
15
+ const noteStartCallout = (callout, depth) => {
16
+ if (calloutDepth == -1) {
17
+ calloutDepth = depth;
18
+ }
19
+ state.env['quarto-active-callout'] = callout;
20
+ };
21
+ const noteCloseCallout = () => {
22
+ calloutDepth = -1;
23
+ state.env['quarto-active-callout'] = undefined;
24
+ };
25
+ const activeCallout = () => {
26
+ return state.env['quarto-active-callout'];
27
+ };
28
+ const isCloseCallout = (depth) => {
29
+ return calloutDepth === depth;
30
+ };
31
+ const titleOpenTok = (title) => {
32
+ const token = new Token(kTokCalloutTitleOpen, "", 1);
33
+ token.tag = "div";
34
+ token.attrs = [["class", "callout-header"]];
35
+ if (title) {
36
+ token.attrs.push(["title", title]);
37
+ }
38
+ return token;
39
+ };
40
+ const titleCloseTok = () => {
41
+ const token = new Token(kTokCalloutTitleClose, "", -1);
42
+ token.tag = "div";
43
+ return token;
44
+ };
45
+ const contentOpenTok = () => {
46
+ const token = new Token(kTokCalloutContentOpen, "", 1);
47
+ token.tag = "div";
48
+ token.attrs = [["class", "callout-body-container callout-body"]];
49
+ return token;
50
+ };
51
+ const contentCloseTok = () => {
52
+ const token = new Token(kTokCalloutContentClose, "", -1);
53
+ token.tag = "div";
54
+ return token;
55
+ };
56
+ const outTokens = [];
57
+ let calloutDepth = -1;
58
+ let divDepth = 0;
59
+ // just started callout - process title
60
+ // finished processing title - process content
61
+ let calloutState = "scanning";
62
+ for (const token of state.tokens) {
63
+ switch (calloutState) {
64
+ case "add-title":
65
+ if (token.type === "heading_open") {
66
+ outTokens.push(titleOpenTok());
67
+ calloutState = "capturing-title";
68
+ }
69
+ else {
70
+ const callout = activeCallout();
71
+ outTokens.push(titleOpenTok(callout.title));
72
+ outTokens.push(titleCloseTok());
73
+ calloutState = "add-body";
74
+ }
75
+ break;
76
+ case "capturing-title":
77
+ if (token.type === "heading_close") {
78
+ outTokens.push(titleCloseTok());
79
+ calloutState = "add-body";
80
+ }
81
+ else {
82
+ outTokens.push(token);
83
+ }
84
+ break;
85
+ case "add-body":
86
+ outTokens.push(contentOpenTok());
87
+ outTokens.push(token);
88
+ calloutState = "capturing-body";
89
+ break;
90
+ case "scanning":
91
+ default:
92
+ if (token.type === kTokDivOpen) {
93
+ divDepth++;
94
+ const callout = parseCallout(token.attrs);
95
+ if (callout) {
96
+ noteStartCallout(callout, divDepth);
97
+ calloutState = "add-title";
98
+ const openCallout = new Token(kTokCalloutOpen, "", 1);
99
+ openCallout.attrs = openCallout.attrs || [];
100
+ openCallout.meta = callout;
101
+ outTokens.push(openCallout);
102
+ }
103
+ else {
104
+ outTokens.push(token);
105
+ }
106
+ }
107
+ else if (token.type === kTokDivClose) {
108
+ if (isCloseCallout(divDepth)) {
109
+ outTokens.push(contentCloseTok());
110
+ outTokens.push(new Token(kTokCalloutClose, "", -1));
111
+ noteCloseCallout();
112
+ }
113
+ else {
114
+ outTokens.push(token);
115
+ }
116
+ divDepth--;
117
+ }
118
+ else {
119
+ outTokens.push(token);
120
+ }
121
+ break;
122
+ }
123
+ }
124
+ state.tokens = outTokens;
125
+ return false;
126
+ });
127
+ md.renderer.rules[kTokCalloutOpen] = renderStartCallout;
128
+ md.renderer.rules[kTokCalloutClose] = renderEndCallout;
129
+ md.renderer.rules[kTokCalloutTitleOpen] = renderStartCalloutTitle;
130
+ md.renderer.rules[kTokCalloutTitleClose] = renderEndCalloutTitle;
131
+ };
132
+ // Render pandoc-style divs
133
+ function renderStartCallout(tokens, idx, options, env, self) {
134
+ const token = tokens[idx];
135
+ const callout = token.meta;
136
+ // Add classes decorating as callout
137
+ token.attrs = addClass(`callout ${callout.clz}`, token.attrs);
138
+ // Add class that reflects the style
139
+ token.attrs = addClass(appearanceClass(callout.appearance), token.attrs);
140
+ return `<div ${self.renderAttrs(token)}>`;
141
+ }
142
+ // Render pandoc-style divs
143
+ function renderEndCallout(tokens, idx, options, env, self) {
144
+ return `</div>`;
145
+ }
146
+ function renderStartCalloutTitle(tokens, idx, options, env, self) {
147
+ const token = tokens[idx];
148
+ const title = readAttrValue("title", token.attrs) || "";
149
+ const startContent = `
150
+ <div class="callout-header">
151
+ <div class="callout-icon-container">
152
+ <i class="callout-icon"></i>
153
+ </div>
154
+ <div class="callout-title-container">${title}
155
+ `;
156
+ return startContent;
157
+ }
158
+ function renderEndCalloutTitle(tokens, idx, options, env, self) {
159
+ return `</div>\n</div>`;
160
+ }
161
+ const calloutAppearance = (val) => {
162
+ if (val) {
163
+ switch (val) {
164
+ case "minimal":
165
+ return "minimal";
166
+ case "simple":
167
+ return "simple";
168
+ case "default":
169
+ default:
170
+ return "default";
171
+ }
172
+ }
173
+ else {
174
+ return "default";
175
+ }
176
+ };
177
+ const parseCallout = (attrs) => {
178
+ if (attrs === null) {
179
+ return undefined;
180
+ }
181
+ const classAttr = attrs.find((attr) => { return attr[0] === "class"; });
182
+ if (!classAttr) {
183
+ return undefined;
184
+ }
185
+ const classes = classAttr[1].split(" ");
186
+ const calloutClass = classes.find((clz) => {
187
+ return clz.startsWith('callout-');
188
+ });
189
+ if (calloutClass) {
190
+ const type = calloutClass.replace(kCalloutPrefix, "");
191
+ const title = readAttrValue("title", attrs) || type.slice(0, 1).toUpperCase() + type.slice(1);
192
+ ;
193
+ const appearance = calloutAppearance(readAttrValue("appearance", attrs));
194
+ return {
195
+ type: type || "note",
196
+ clz: calloutClass,
197
+ title,
198
+ appearance
199
+ };
200
+ }
201
+ else {
202
+ return undefined;
203
+ }
204
+ };
205
+ const appearanceClass = (appearance) => {
206
+ let style = appearance || "default";
207
+ return `callout-style-${style}`;
208
+ };
@@ -0,0 +1 @@
1
+ {"version":3,"file":"callouts.js","sourceRoot":"","sources":["../../src/plugins/callouts.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,MAAM,uBAAuB,CAAC;AAC1C,OAAO,EAAE,QAAQ,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAC9D,OAAO,EAAgB,YAAY,EAAE,WAAW,EAAE,MAAM,QAAQ,CAAC;AAGjE,MAAM,eAAe,GAAG,qBAAqB,CAAC;AAC9C,MAAM,gBAAgB,GAAG,sBAAsB,CAAC;AAEhD,MAAM,oBAAoB,GAAG,2BAA2B,CAAC;AACzD,MAAM,qBAAqB,GAAG,4BAA4B,CAAC;AAE3D,MAAM,sBAAsB,GAAG,6BAA6B,CAAC;AAC7D,MAAM,uBAAuB,GAAG,8BAA8B,CAAC;AAE/D,MAAM,cAAc,GAAG,UAAU,CAAC;AAClC,MAAM,gBAAgB,GAAG,iBAAiB,CAAC;AAW3C,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,EAAc,EAAE,EAAE;IAE9C,2BAA2B;IAC3B,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAChB,gBAAgB,EAChB,CAAC,KAAK,EAAE,EAAE;QACR,MAAM,gBAAgB,GAAG,CAAC,OAAgB,EAAE,KAAa,EAAE,EAAE;YAC3D,IAAI,YAAY,IAAI,CAAC,CA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