@quarto/jupyterlab-quarto 0.1.44 → 0.2.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (127) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +48 -15
  3. package/lib/__tests__/jupyterlab_quarto.spec.d.ts +3 -0
  4. package/lib/__tests__/jupyterlab_quarto.spec.js +9 -0
  5. package/lib/ast/ast.d.ts +2 -0
  6. package/lib/ast/ast.js +40 -0
  7. package/lib/const.d.ts +4 -0
  8. package/lib/const.js +11 -0
  9. package/lib/hooks/codemirror.d.ts +5 -0
  10. package/lib/hooks/codemirror.js +77 -0
  11. package/lib/index.d.ts +5 -0
  12. package/lib/index.js +61 -0
  13. package/lib/manager.d.ts +8 -0
  14. package/lib/manager.js +115 -0
  15. package/lib/plugins/callouts.d.ts +2 -0
  16. package/lib/plugins/callouts.js +210 -0
  17. package/lib/plugins/cites.d.ts +2 -0
  18. package/lib/plugins/cites.js +166 -0
  19. package/lib/plugins/decorator.d.ts +2 -0
  20. package/lib/plugins/decorator.js +58 -0
  21. package/lib/plugins/divs.d.ts +5 -0
  22. package/lib/plugins/divs.js +111 -0
  23. package/lib/plugins/figure-divs.d.ts +2 -0
  24. package/lib/plugins/figure-divs.js +54 -0
  25. package/lib/plugins/figures.d.ts +16 -0
  26. package/lib/plugins/figures.js +98 -0
  27. package/lib/plugins/gridtables/common/gridtables/GetCells.d.ts +7 -0
  28. package/lib/plugins/gridtables/common/gridtables/GetCells.js +43 -0
  29. package/lib/plugins/gridtables/common/gridtables/GetColumnWidths.d.ts +7 -0
  30. package/lib/plugins/gridtables/common/gridtables/GetColumnWidths.js +22 -0
  31. package/lib/plugins/gridtables/common/markdown-it/ColumnAlignments.d.ts +7 -0
  32. package/lib/plugins/gridtables/common/markdown-it/ColumnAlignments.js +12 -0
  33. package/lib/plugins/gridtables/common/markdown-it/EmitTable.d.ts +4 -0
  34. package/lib/plugins/gridtables/common/markdown-it/EmitTable.js +64 -0
  35. package/lib/plugins/gridtables/common/markdown-it/GetCharCodeAtStartOfLine.d.ts +8 -0
  36. package/lib/plugins/gridtables/common/markdown-it/GetCharCodeAtStartOfLine.js +17 -0
  37. package/lib/plugins/gridtables/common/markdown-it/GetLine.d.ts +2 -0
  38. package/lib/plugins/gridtables/common/markdown-it/GetLine.js +9 -0
  39. package/lib/plugins/gridtables/common/markdown-it/ParseTable.d.ts +3 -0
  40. package/lib/plugins/gridtables/common/markdown-it/ParseTable.js +152 -0
  41. package/lib/plugins/gridtables/common/markdown-it/ParseTableResult.d.ts +12 -0
  42. package/lib/plugins/gridtables/common/markdown-it/ParseTableResult.js +17 -0
  43. package/lib/plugins/gridtables/index.d.ts +1 -0
  44. package/lib/plugins/gridtables/index.js +10 -0
  45. package/lib/plugins/gridtables/interfaces/markdown-it/IState.d.ts +10 -0
  46. package/lib/plugins/gridtables/interfaces/markdown-it/IState.js +5 -0
  47. package/lib/plugins/gridtables/interfaces/markdown-it/IToken.d.ts +6 -0
  48. package/lib/plugins/gridtables/interfaces/markdown-it/IToken.js +5 -0
  49. package/lib/plugins/gridtables/interfaces/markdown-it/TRuleFunction.d.ts +3 -0
  50. package/lib/plugins/gridtables/interfaces/markdown-it/TRuleFunction.js +5 -0
  51. package/lib/plugins/gridtables/rules/gridtable.d.ts +3 -0
  52. package/lib/plugins/gridtables/rules/gridtable.js +25 -0
  53. package/lib/plugins/index.d.ts +15 -0
  54. package/lib/plugins/index.js +21 -0
  55. package/lib/plugins/math.d.ts +6 -0
  56. package/lib/plugins/math.js +179 -0
  57. package/lib/plugins/mermaid/index.d.ts +4 -0
  58. package/lib/plugins/mermaid/index.js +60 -0
  59. package/lib/plugins/shortcodes.d.ts +3 -0
  60. package/lib/plugins/shortcodes.js +32 -0
  61. package/lib/plugins/spans.d.ts +2 -0
  62. package/lib/plugins/spans.js +37 -0
  63. package/lib/plugins/table-captions.d.ts +2 -0
  64. package/lib/plugins/table-captions.js +72 -0
  65. package/lib/plugins/utils/html.d.ts +11 -0
  66. package/lib/plugins/utils/html.js +50 -0
  67. package/lib/plugins/utils/markdownit.d.ts +15 -0
  68. package/lib/plugins/utils/markdownit.js +46 -0
  69. package/lib/plugins/utils/tok.d.ts +7 -0
  70. package/lib/plugins/utils/tok.js +13 -0
  71. package/lib/plugins/yaml.d.ts +2 -0
  72. package/lib/plugins/yaml.js +330 -0
  73. package/lib/providers/attrs.d.ts +1 -0
  74. package/lib/providers/attrs.js +15 -0
  75. package/lib/providers/callouts.d.ts +1 -0
  76. package/lib/providers/callouts.js +15 -0
  77. package/lib/providers/cites.d.ts +1 -0
  78. package/lib/providers/cites.js +15 -0
  79. package/lib/providers/decorator.d.ts +1 -0
  80. package/lib/providers/decorator.js +15 -0
  81. package/lib/providers/deflist.d.ts +1 -0
  82. package/lib/providers/deflist.js +15 -0
  83. package/lib/providers/divs.d.ts +1 -0
  84. package/lib/providers/divs.js +27 -0
  85. package/lib/providers/figure-divs.d.ts +1 -0
  86. package/lib/providers/figure-divs.js +15 -0
  87. package/lib/providers/figures.d.ts +1 -0
  88. package/lib/providers/figures.js +15 -0
  89. package/lib/providers/footnotes.d.ts +1 -0
  90. package/lib/providers/footnotes.js +15 -0
  91. package/lib/providers/gridtables.d.ts +1 -0
  92. package/lib/providers/gridtables.js +15 -0
  93. package/lib/providers/math.d.ts +1 -0
  94. package/lib/providers/math.js +104 -0
  95. package/lib/providers/mermaid.d.ts +1 -0
  96. package/lib/providers/mermaid.js +17 -0
  97. package/lib/providers/provider.d.ts +3 -0
  98. package/lib/providers/provider.js +12 -0
  99. package/lib/providers/shortcodes.d.ts +1 -0
  100. package/lib/providers/shortcodes.js +15 -0
  101. package/lib/providers/spans.d.ts +1 -0
  102. package/lib/providers/spans.js +15 -0
  103. package/lib/providers/sub.d.ts +1 -0
  104. package/lib/providers/sub.js +15 -0
  105. package/lib/providers/sup.d.ts +1 -0
  106. package/lib/providers/sup.js +15 -0
  107. package/lib/providers/table-captions.d.ts +1 -0
  108. package/lib/providers/table-captions.js +15 -0
  109. package/lib/providers/tasklists.d.ts +1 -0
  110. package/lib/providers/tasklists.js +15 -0
  111. package/lib/providers/yaml.d.ts +1 -0
  112. package/lib/providers/yaml.js +15 -0
  113. package/lib/types.d.ts +43 -0
  114. package/lib/types.js +1 -0
  115. package/lib/widgets.d.ts +14 -0
  116. package/lib/widgets.js +57 -0
  117. package/package.json +105 -39
  118. package/style/base.css +34 -33
  119. package/style/index.css +1 -1
  120. package/schema/plugin.json +0 -8
  121. package/src/@types/markdown-it-deflist.d.ts +0 -10
  122. package/src/@types/markdown-it-footnote.d.ts +0 -10
  123. package/src/@types/markdown-it-gridtables.d.ts +0 -10
  124. package/src/@types/markdown-it-implicit-figures.d.ts +0 -10
  125. package/src/@types/markdown-it-sub.d.ts +0 -10
  126. package/src/@types/markdown-it-sup.d.ts +0 -10
  127. package/src/@types/markdown-it-task-lists.d.ts +0 -10
@@ -0,0 +1,330 @@
1
+ /*
2
+ * markdownit-yaml.ts
3
+ *
4
+ * Copyright (C) 2022 by Posit Software, PBC
5
+ * Copyright (c) 2016-2020 ParkSB.
6
+ *
7
+ * Unless you have received this program directly from Posit Software pursuant
8
+ * to the terms of a commercial license agreement with Posit Software, then
9
+ * this program is licensed to you under the terms of version 3 of the
10
+ * GNU Affero General Public License. This program is distributed WITHOUT
11
+ * ANY EXPRESS OR IMPLIED WARRANTY, INCLUDING THOSE OF NON-INFRINGEMENT,
12
+ * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Please refer to the
13
+ * AGPL (http://www.gnu.org/licenses/agpl-3.0.txt) for more details.
14
+ *
15
+ */
16
+ import * as yaml from 'js-yaml';
17
+ import { decorator } from './utils/html';
18
+ // Typescript version of https://github.com/parksb/markdown-it-front-matter
19
+ // TODO: Rationalize this with quarto-core/src/markdownit-yaml.ts
20
+ // This is a copy with rendering added - the core tokenizing function is identical (or should be)
21
+ const kTokFrontMatter = 'front_matter';
22
+ export function yamlPlugin(md, cb) {
23
+ const min_markers = 3, marker_str = '-', marker_char = marker_str.charCodeAt(0), marker_len = marker_str.length;
24
+ function frontMatter(state, startLine, endLine, silent) {
25
+ let pos, nextLine, start_content, user_closed = false, start = state.bMarks[startLine] + state.tShift[startLine], max = state.eMarks[startLine];
26
+ // Check out the first character of the first line quickly,
27
+ // this should filter out non-front matter
28
+ if (startLine !== 0 || marker_char !== state.src.charCodeAt(0)) {
29
+ return false;
30
+ }
31
+ // Check out the rest of the marker string
32
+ // while pos <= 3
33
+ for (pos = start + 1; pos <= max; pos++) {
34
+ if (marker_str[(pos - start) % marker_len] !== state.src[pos]) {
35
+ start_content = pos + 1;
36
+ break;
37
+ }
38
+ }
39
+ const marker_count = Math.floor((pos - start) / marker_len);
40
+ if (marker_count < min_markers) {
41
+ return false;
42
+ }
43
+ pos -= (pos - start) % marker_len;
44
+ // Since start is found, we can report success here in validation mode
45
+ if (silent) {
46
+ return true;
47
+ }
48
+ // Search for the end of the block
49
+ nextLine = startLine;
50
+ for (;;) {
51
+ nextLine++;
52
+ if (nextLine >= endLine) {
53
+ // unclosed block should be autoclosed by end of document.
54
+ // also block seems to be autoclosed by end of parent
55
+ break;
56
+ }
57
+ if (state.src.slice(start, max) === '...') {
58
+ break;
59
+ }
60
+ start = state.bMarks[nextLine] + state.tShift[nextLine];
61
+ max = state.eMarks[nextLine];
62
+ if (start < max && state.sCount[nextLine] < state.blkIndent) {
63
+ // non-empty line with negative indent should stop the list:
64
+ // - ```
65
+ // test
66
+ break;
67
+ }
68
+ if (marker_char !== state.src.charCodeAt(start)) {
69
+ continue;
70
+ }
71
+ if (state.sCount[nextLine] - state.blkIndent >= 4) {
72
+ // closing fence should be indented less than 4 spaces
73
+ continue;
74
+ }
75
+ for (pos = start + 1; pos <= max; pos++) {
76
+ if (marker_str[(pos - start) % marker_len] !== state.src[pos]) {
77
+ break;
78
+ }
79
+ }
80
+ // closing code fence must be at least as long as the opening one
81
+ if (Math.floor((pos - start) / marker_len) < marker_count) {
82
+ continue;
83
+ }
84
+ // make sure tail has spaces only
85
+ pos -= (pos - start) % marker_len;
86
+ pos = state.skipSpaces(pos);
87
+ if (pos < max) {
88
+ continue;
89
+ }
90
+ // found!
91
+ user_closed = true;
92
+ break;
93
+ }
94
+ // Ensure that we have real yaml here
95
+ const markup = state.src.slice(startLine, pos);
96
+ const yaml = parseFrontMatterStr(markup);
97
+ const isYamlBlock = yaml !== null && typeof yaml === 'object';
98
+ // If this is yaml, render it
99
+ if (isYamlBlock && user_closed) {
100
+ const old_parent = state.parentType;
101
+ const old_line_max = state.lineMax;
102
+ const token = state.push(kTokFrontMatter, '', 0);
103
+ token.hidden = true;
104
+ token.markup = markup;
105
+ token.block = true;
106
+ token.map = [startLine, pos];
107
+ token.meta = state.src.slice(start_content, start - 1);
108
+ if (cb) {
109
+ cb(token.meta);
110
+ }
111
+ state.parentType = old_parent;
112
+ state.lineMax = old_line_max;
113
+ state.line = nextLine + (user_closed ? 1 : 0);
114
+ return true;
115
+ }
116
+ else {
117
+ // This is not yaml, just continue
118
+ state.line = nextLine + 1;
119
+ return false;
120
+ }
121
+ }
122
+ md.block.ruler.before('table', kTokFrontMatter, frontMatter, {
123
+ alt: ['paragraph', 'reference', 'blockquote', 'list']
124
+ });
125
+ // Add rendering
126
+ md.renderer.rules[kTokFrontMatter] = renderFrontMatter;
127
+ }
128
+ function renderFrontMatter(tokens, idx) {
129
+ const token = tokens[idx];
130
+ // Parse the markup
131
+ const frontUnknown = parseFrontMatterStr(token.markup);
132
+ // Extract important content
133
+ if (typeof frontUnknown === 'object') {
134
+ const titleBlock = {};
135
+ const frontMatter = frontUnknown;
136
+ const readStr = (key) => {
137
+ if (frontMatter[key] === undefined) {
138
+ return undefined;
139
+ }
140
+ else if (typeof frontMatter[key] === 'string') {
141
+ const val = frontMatter[key];
142
+ delete frontMatter[key];
143
+ return val;
144
+ }
145
+ else {
146
+ return undefined;
147
+ }
148
+ };
149
+ // Read simple values
150
+ titleBlock.title = readStr('title');
151
+ titleBlock.subtitle = readStr('subtitle');
152
+ titleBlock.abstract = readStr('abstract');
153
+ titleBlock.date = readStr('date');
154
+ titleBlock.modified = readStr('date-modified');
155
+ titleBlock.doi = readStr('doi');
156
+ // Read Authors
157
+ titleBlock.authors = parseAuthor(frontMatter.author || frontMatter.authors);
158
+ delete frontMatter.author;
159
+ delete frontMatter.authors;
160
+ // The final rendered HTML output
161
+ const titleLines = [];
162
+ // Render the title block and other yaml options
163
+ const titleRendered = renderTitle(titleBlock);
164
+ titleLines.push(titleRendered);
165
+ if (Object.keys(frontMatter).length > 0) {
166
+ // decorator
167
+ const decor = decorator(['Options']);
168
+ titleLines.push(decor);
169
+ // yaml
170
+ const yamlDump = yaml.dump(frontMatter);
171
+ const otherYamlRendered = `<pre class="quarto-frontmatter-container"><code class="cm-s-jupyter language-yaml quarto-frontmatter">${yamlDump}</code></pre>`;
172
+ titleLines.push(otherYamlRendered);
173
+ }
174
+ return titleLines.join('\n');
175
+ }
176
+ else {
177
+ return '';
178
+ }
179
+ }
180
+ // TODO: Use core function instead
181
+ function parseFrontMatterStr(str) {
182
+ str = str.replace(/---\s*$/, '');
183
+ try {
184
+ return yaml.load(str, { schema: yaml.FAILSAFE_SCHEMA });
185
+ }
186
+ catch (error) {
187
+ return undefined;
188
+ }
189
+ }
190
+ function renderTitle(titleBlock) {
191
+ var _a;
192
+ const rendered = [];
193
+ if (titleBlock.title) {
194
+ rendered.push(`<h1>${titleBlock.title}</h1>`);
195
+ }
196
+ if (titleBlock.subtitle) {
197
+ rendered.push(`<p class="quarto-subtitle">${titleBlock.subtitle}</p>`);
198
+ }
199
+ const metadataBlocks = [];
200
+ if (titleBlock.authors && ((_a = titleBlock.authors) === null || _a === void 0 ? void 0 : _a.length) > 0) {
201
+ const names = [];
202
+ const affils = [];
203
+ for (let i = 0; i < titleBlock.authors.length; i++) {
204
+ const author = titleBlock.authors[i];
205
+ if (author.orcid) {
206
+ names.push({
207
+ value: `${author.name}<a href="https://orcid.org/${author.orcid}" class="quarto-orcid"><i></i></a>`,
208
+ padded: i > 0
209
+ });
210
+ }
211
+ else {
212
+ names.push({ value: author.name, padded: i > 0 });
213
+ }
214
+ // Place empty rows to allow affiliations to line up
215
+ const emptyCount = author.affil
216
+ ? Math.max(author.affil.length - 1, 0)
217
+ : 0;
218
+ for (let j = 0; j < emptyCount; j++) {
219
+ names.push({ value: '&nbsp;' });
220
+ }
221
+ // Collect affilations
222
+ if (author.affil) {
223
+ for (let k = 0; k < author.affil.length; k++) {
224
+ const affil = author.affil[k];
225
+ affils.push({
226
+ value: affil,
227
+ padded: i > 0 && k === 0
228
+ });
229
+ }
230
+ }
231
+ }
232
+ const authLabel = names.length === 1 ? 'Author' : 'Authors';
233
+ metadataBlocks.push(renderDocMeta(authLabel, names));
234
+ if (affils.length > 0) {
235
+ const affilLabel = affils.length === 1 ? 'Affiliation' : 'Affiliations';
236
+ metadataBlocks.push(renderDocMeta(affilLabel, affils));
237
+ }
238
+ }
239
+ if (titleBlock.date) {
240
+ metadataBlocks.push(renderDocMeta('Date', [{ value: titleBlock.date }]));
241
+ }
242
+ if (titleBlock.modified) {
243
+ metadataBlocks.push(renderDocMeta('Modified', [{ value: titleBlock.modified }]));
244
+ }
245
+ if (titleBlock.doi) {
246
+ metadataBlocks.push(renderDocMeta('DOI', [
247
+ {
248
+ value: `<a href="https://doi.org/${titleBlock.doi}">${titleBlock.doi}</a>`
249
+ }
250
+ ]));
251
+ }
252
+ if (metadataBlocks.length > 0) {
253
+ rendered.push(renderDocMetas(metadataBlocks));
254
+ }
255
+ if (titleBlock.abstract) {
256
+ rendered.push(`<p class="quarto-abstract">${titleBlock.abstract}</p>`);
257
+ }
258
+ return rendered.join('\n');
259
+ }
260
+ function renderDocMetas(docMetas) {
261
+ const rendered = [];
262
+ rendered.push('<div class="quarto-meta-block">');
263
+ docMetas.forEach(docMeta => {
264
+ rendered.push(docMeta);
265
+ });
266
+ rendered.push('</div>');
267
+ return rendered.join('\n');
268
+ }
269
+ function renderDocMeta(label, vals) {
270
+ const rendered = [];
271
+ rendered.push('<div class="quarto-meta">');
272
+ rendered.push(`<p class="quarto-meta-title">${label}</p>`);
273
+ vals.forEach(val => {
274
+ const clz = val.padded ? ' class="quarto-meta-padded"' : '';
275
+ rendered.push(`<p${clz}>${val.value}</p>`);
276
+ });
277
+ rendered.push('</div>');
278
+ return rendered.join('\n');
279
+ }
280
+ function parseAuthor(author) {
281
+ var _a;
282
+ const authorsRaw = Array.isArray(author) ? author : [author];
283
+ const authors = [];
284
+ for (const authorRaw of authorsRaw) {
285
+ if (typeof authorRaw === 'string') {
286
+ authors.push({
287
+ name: authorRaw
288
+ });
289
+ }
290
+ else if (typeof authorRaw === 'object') {
291
+ const str = (key, defaultValue) => {
292
+ if (typeof authorRaw[key] === 'string') {
293
+ return authorRaw[key];
294
+ }
295
+ else {
296
+ return defaultValue;
297
+ }
298
+ };
299
+ const affiliations = [];
300
+ const affiliationSimple = str('affiliation');
301
+ if (affiliationSimple) {
302
+ affiliations.push(affiliationSimple);
303
+ }
304
+ else if (authorRaw.affiliations) {
305
+ const affils = Array.isArray(authorRaw.affiliations)
306
+ ? authorRaw.affiliations
307
+ : [authorRaw.affiliations];
308
+ affils.forEach((affilRaw) => {
309
+ if (typeof affilRaw === 'string') {
310
+ affiliations.push(affilRaw);
311
+ // eslint-disable-next-line no-constant-condition
312
+ }
313
+ else if (typeof (affilRaw === 'object')) {
314
+ const affilRecord = affilRaw;
315
+ const name = affilRecord.name;
316
+ if (typeof name === 'string') {
317
+ affiliations.push(name);
318
+ }
319
+ }
320
+ });
321
+ }
322
+ authors.push({
323
+ name: (_a = str('name', '')) !== null && _a !== void 0 ? _a : '',
324
+ orcid: str('orcid'),
325
+ affil: affiliations
326
+ });
327
+ }
328
+ }
329
+ return authors;
330
+ }
@@ -0,0 +1 @@
1
+ export declare const attrs: import("@jupyterlab/application").JupyterFrontEndPlugin<void>;
@@ -0,0 +1,15 @@
1
+ /*
2
+ * attrs.ts
3
+ *
4
+ * Copyright (C) 2020-2023 Posit Software, PBC
5
+ *
6
+ */
7
+ import { markdownItExtension } from './provider';
8
+ export const attrs = markdownItExtension({
9
+ id: '@quarto/attributes',
10
+ title: 'Markdown Attributes',
11
+ plugin: async () => {
12
+ const plugin = await import('markdown-it-attrs');
13
+ return [plugin.default];
14
+ }
15
+ });
@@ -0,0 +1 @@
1
+ export declare const callouts: import("@jupyterlab/application").JupyterFrontEndPlugin<void>;
@@ -0,0 +1,15 @@
1
+ /*
2
+ * callouts.ts
3
+ *
4
+ * Copyright (C) 2020-2023 Posit Software, PBC
5
+ *
6
+ */
7
+ import { calloutPlugin } from '../plugins/callouts';
8
+ import { markdownItExtension } from './provider';
9
+ export const callouts = markdownItExtension({
10
+ id: '@quarto/callouts',
11
+ title: 'Quarto callouts',
12
+ plugin: async () => {
13
+ return [calloutPlugin];
14
+ }
15
+ });
@@ -0,0 +1 @@
1
+ export declare const cites: import("@jupyterlab/application").JupyterFrontEndPlugin<void>;
@@ -0,0 +1,15 @@
1
+ /*
2
+ * cites.ts
3
+ *
4
+ * Copyright (C) 2020-2023 Posit Software, PBC
5
+ *
6
+ */
7
+ import { citationPlugin } from '../plugins/cites';
8
+ import { markdownItExtension } from './provider';
9
+ export const cites = markdownItExtension({
10
+ id: '@quarto/cites',
11
+ title: 'Citations',
12
+ plugin: async () => {
13
+ return [citationPlugin];
14
+ }
15
+ });
@@ -0,0 +1 @@
1
+ export declare const decorator: import("@jupyterlab/application").JupyterFrontEndPlugin<void>;
@@ -0,0 +1,15 @@
1
+ /*
2
+ * code.ts
3
+ *
4
+ * Copyright (C) 2020-2023 Posit Software, PBC
5
+ *
6
+ */
7
+ import { decoratorPlugin } from '../plugins/decorator';
8
+ import { markdownItExtension } from './provider';
9
+ export const decorator = markdownItExtension({
10
+ id: '@quarto/fence',
11
+ title: 'Fenced Code Blocks',
12
+ plugin: async () => {
13
+ return [decoratorPlugin];
14
+ }
15
+ });
@@ -0,0 +1 @@
1
+ export declare const deflist: import("@jupyterlab/application").JupyterFrontEndPlugin<void>;
@@ -0,0 +1,15 @@
1
+ /*
2
+ * deflist.ts
3
+ *
4
+ * Copyright (C) 2020-2023 Posit Software, PBC
5
+ *
6
+ */
7
+ import { markdownItExtension } from './provider';
8
+ export const deflist = markdownItExtension({
9
+ id: '@quarto/deflist',
10
+ title: 'Definition Lists',
11
+ plugin: async () => {
12
+ const plugin = await import('markdown-it-deflist');
13
+ return [plugin.default];
14
+ }
15
+ });
@@ -0,0 +1 @@
1
+ export declare const divs: import("@jupyterlab/application").JupyterFrontEndPlugin<void>;
@@ -0,0 +1,27 @@
1
+ /*
2
+ * callouts.ts
3
+ *
4
+ * Copyright (C) 2020-2023 Posit Software, PBC
5
+ *
6
+ */
7
+ import { divPlugin } from '../plugins/divs';
8
+ import { markdownItExtension } from './provider';
9
+ export const divs = markdownItExtension({
10
+ id: '@quarto/divs',
11
+ title: 'Pandoc fenced divs',
12
+ plugin: async () => {
13
+ return [divPlugin];
14
+ },
15
+ hooks: {
16
+ preParse: {
17
+ run: (content) => {
18
+ // Detect close divs that are directly after text (e.g. not back to back whitespace)
19
+ // and add a whitespace. This will cause the close div to become a 'block'
20
+ // rather than appearing as the end of the paragraph block
21
+ const blockedDivs = content.replace(kCloseDivNoBlock, '$1\n\n$2');
22
+ return Promise.resolve(blockedDivs);
23
+ }
24
+ }
25
+ }
26
+ });
27
+ const kCloseDivNoBlock = /([^\s])\n(:::+(?:\{.*\})?)/gm;
@@ -0,0 +1 @@
1
+ export declare const figureDivs: import("@jupyterlab/application").JupyterFrontEndPlugin<void>;
@@ -0,0 +1,15 @@
1
+ /*
2
+ * figure-divs.ts
3
+ *
4
+ * Copyright (C) 2020-2023 Posit Software, PBC
5
+ *
6
+ */
7
+ import { figureDivsPlugin } from '../plugins/figure-divs';
8
+ import { markdownItExtension } from './provider';
9
+ export const figureDivs = markdownItExtension({
10
+ id: '@quarto/figureDivs',
11
+ title: 'Quarto Figure Divs',
12
+ plugin: async () => {
13
+ return [figureDivsPlugin];
14
+ }
15
+ });
@@ -0,0 +1 @@
1
+ export declare const figures: import("@jupyterlab/application").JupyterFrontEndPlugin<void>;
@@ -0,0 +1,15 @@
1
+ /*
2
+ * figures.ts
3
+ *
4
+ * Copyright (C) 2020-2023 Posit Software, PBC
5
+ *
6
+ */
7
+ import { figuresPlugin } from '../plugins/figures';
8
+ import { markdownItExtension } from './provider';
9
+ export const figures = markdownItExtension({
10
+ id: '@quarto/figures',
11
+ title: 'Quarto figures',
12
+ plugin: async () => {
13
+ return [figuresPlugin, { figcaption: true, copyAttrs: true }];
14
+ }
15
+ });
@@ -0,0 +1 @@
1
+ export declare const footnotes: import("@jupyterlab/application").JupyterFrontEndPlugin<void>;
@@ -0,0 +1,15 @@
1
+ /*
2
+ * footnotes.ts
3
+ *
4
+ * Copyright (C) 2020-2023 Posit Software, PBC
5
+ *
6
+ */
7
+ import { markdownItExtension } from './provider';
8
+ export const footnotes = markdownItExtension({
9
+ id: '@quarto/footnotes',
10
+ title: 'Footnotes',
11
+ plugin: async () => {
12
+ const footnotePlugin = await import('markdown-it-footnote');
13
+ return [footnotePlugin.default];
14
+ }
15
+ });
@@ -0,0 +1 @@
1
+ export declare const gridtables: import("@jupyterlab/application").JupyterFrontEndPlugin<void>;
@@ -0,0 +1,15 @@
1
+ /*
2
+ * gridtables.ts
3
+ *
4
+ * Copyright (C) 2020-2023 Posit Software, PBC
5
+ *
6
+ */
7
+ import gridTableRulePlugin from '../plugins/gridtables';
8
+ import { markdownItExtension } from './provider';
9
+ export const gridtables = markdownItExtension({
10
+ id: '@quarto/gridtables',
11
+ title: 'Grid Tables',
12
+ plugin: async () => {
13
+ return [gridTableRulePlugin];
14
+ }
15
+ });
@@ -0,0 +1 @@
1
+ export declare const math: import("@jupyterlab/application").JupyterFrontEndPlugin<void>;
@@ -0,0 +1,104 @@
1
+ /*
2
+ * math.ts
3
+ *
4
+ * Copyright (C) 2020-2023 Posit Software, PBC
5
+ *
6
+ */
7
+ import { mathjaxPlugin } from '../plugins/math';
8
+ import { markdownItExtension } from './provider';
9
+ export const math = markdownItExtension({
10
+ id: '@quarto/math',
11
+ title: 'LaTex Math',
12
+ plugin: async () => {
13
+ return [mathjaxPlugin];
14
+ },
15
+ hooks: {
16
+ postRender: {
17
+ run: (node) => {
18
+ // Inject mathjax
19
+ const mathjaxId = 'MathJax-script';
20
+ const mathJaxScript = document.getElementById(mathjaxId);
21
+ if (!mathJaxScript) {
22
+ const configEl = document.createElement('script');
23
+ configEl.innerText = `
24
+
25
+ MathJax = {
26
+ svg: {
27
+ fontCache: 'global'
28
+ },
29
+ startup: {
30
+ typeset: false,
31
+ pageReady: () => {
32
+ MathJax.startup.promise.then(() => {
33
+
34
+ const typesetMath = (els) => {
35
+ MathJax.startup.promise = MathJax.startup.promise
36
+ .then(() => {
37
+ return MathJax.typesetPromise(els); }
38
+ )
39
+ .catch((err) => console.log('Typeset failed: ' + err.message));
40
+ return MathJax.startup.promise;
41
+ };
42
+
43
+ const typesetCellObserver = new MutationObserver((mutationList, observer) => {
44
+ const els = mutationList.map((list) => list.target);
45
+ const typesetEls = [];
46
+ for (const el of els) {
47
+ const childMathEls = el.querySelectorAll('.quarto-inline-math, .quarto-display-math');
48
+ if (childMathEls && childMathEls.length > 0) {
49
+ typesetEls.push(...childMathEls);
50
+ }
51
+ }
52
+ typesetMath(typesetEls);
53
+ });
54
+
55
+ const containerObserver = new MutationObserver((mutationList, observer) => {
56
+ const nodes = [];
57
+ mutationList.forEach((record) => {
58
+ for (const node of record.addedNodes) {
59
+ nodes.push(node);
60
+ }
61
+ });
62
+
63
+ const markdownNodes = nodes.filter((node) => {
64
+ return node.class.contains("jp-MarkdownCell");
65
+ }).forEach((node) => {
66
+ typesetCellObserver.observe(node, { childList: true, subtree: true });
67
+ });
68
+
69
+ });
70
+
71
+ const nbContainer = document.querySelector('.jp-Notebook');
72
+ if (nbContainer !== null) {
73
+ containerObserver.observe(nbContainer, { childList: true });
74
+ }
75
+
76
+ const mathEls = document.body.querySelectorAll('.quarto-inline-math, .quarto-display-math');
77
+ return typesetMath([...mathEls]).then(() => {
78
+ for (const mathEl of mathEls) {
79
+ typesetCellObserver.observe(mathEl.parentElement, { childList: true, subtree: true });
80
+ }
81
+ });
82
+ });
83
+ },
84
+ }
85
+ };`;
86
+ document.head.appendChild(configEl);
87
+ const polyFillEl = document.createElement('script');
88
+ polyFillEl.setAttribute('src', 'https://polyfill.io/v3/polyfill.min.js?features=es6');
89
+ document.head.appendChild(polyFillEl);
90
+ const scriptEl = document.createElement('script');
91
+ scriptEl.id = mathjaxId;
92
+ scriptEl.setAttribute('src', 'https://cdn.jsdelivr.net/npm/mathjax@3.0.1/es5/tex-mml-chtml.js');
93
+ document.head.appendChild(scriptEl);
94
+ }
95
+ return Promise.resolve();
96
+ }
97
+ }
98
+ }
99
+ });
100
+ /*
101
+ <script src="https://polyfill.io/v3/polyfill.min.js?features=es6"></script>
102
+ <script id="MathJax-script" async src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js"></script>
103
+
104
+ */
@@ -0,0 +1 @@
1
+ export declare const mermaid: import("@jupyterlab/application").JupyterFrontEndPlugin<void>;
@@ -0,0 +1,17 @@
1
+ /*
2
+ * mermaid.ts
3
+ *
4
+ * Copyright (C) 2020-2023 Posit Software, PBC
5
+ *
6
+ */
7
+ import mermaidPlugin from '../plugins/mermaid';
8
+ import { markdownItExtension } from './provider';
9
+ export const mermaid = markdownItExtension({
10
+ id: '@quarto/mermaid',
11
+ title: 'Mermaid',
12
+ plugin: async () => {
13
+ // Figure out whether this is dark mode
14
+ const isDark = document.body.getAttribute('data-jp-theme-light') === 'false';
15
+ return [mermaidPlugin, { dark: isDark }];
16
+ }
17
+ });
@@ -0,0 +1,3 @@
1
+ import { JupyterFrontEndPlugin } from '@jupyterlab/application';
2
+ import { MarkdownItPluginProvider } from '../types';
3
+ export declare function markdownItExtension(provider: MarkdownItPluginProvider): JupyterFrontEndPlugin<void>;