@quarto/jupyterlab-quarto 0.1.44 → 0.1.45

Sign up to get free protection for your applications and to get access to all the features.
Files changed (172) hide show
  1. package/lib/__tests__/index.spec.d.ts +6 -0
  2. package/lib/__tests__/index.spec.js +61 -0
  3. package/lib/__tests__/index.spec.js.map +1 -0
  4. package/lib/__tests__/myextension.spec.d.ts +6 -0
  5. package/lib/__tests__/myextension.spec.js +11 -0
  6. package/lib/__tests__/myextension.spec.js.map +1 -0
  7. package/lib/ast/ast.d.ts +3 -0
  8. package/lib/ast/ast.js +39 -0
  9. package/lib/ast/ast.js.map +1 -0
  10. package/lib/const.d.ts +5 -0
  11. package/lib/const.js +12 -0
  12. package/lib/const.js.map +1 -0
  13. package/lib/hooks/codemirror.d.ts +4 -0
  14. package/lib/hooks/codemirror.js +52 -0
  15. package/lib/hooks/codemirror.js.map +1 -0
  16. package/lib/index.d.ts +6 -0
  17. package/lib/index.js +60 -0
  18. package/lib/index.js.map +1 -0
  19. package/lib/manager.d.ts +8 -0
  20. package/lib/manager.js +117 -0
  21. package/lib/manager.js.map +1 -0
  22. package/lib/plugins/callouts.d.ts +3 -0
  23. package/lib/plugins/callouts.js +209 -0
  24. package/lib/plugins/callouts.js.map +1 -0
  25. package/lib/plugins/cites.d.ts +3 -0
  26. package/lib/plugins/cites.js +148 -0
  27. package/lib/plugins/cites.js.map +1 -0
  28. package/lib/plugins/decorator.d.ts +3 -0
  29. package/lib/plugins/decorator.js +59 -0
  30. package/lib/plugins/decorator.js.map +1 -0
  31. package/lib/plugins/divs.d.ts +6 -0
  32. package/lib/plugins/divs.js +100 -0
  33. package/lib/plugins/divs.js.map +1 -0
  34. package/lib/plugins/figure-divs.d.ts +3 -0
  35. package/lib/plugins/figure-divs.js +53 -0
  36. package/lib/plugins/figure-divs.js.map +1 -0
  37. package/lib/plugins/figures.d.ts +17 -0
  38. package/lib/plugins/figures.js +99 -0
  39. package/lib/plugins/figures.js.map +1 -0
  40. package/lib/plugins/gridtables/common/gridtables/GetCells.d.ts +8 -0
  41. package/lib/plugins/gridtables/common/gridtables/GetCells.js +45 -0
  42. package/lib/plugins/gridtables/common/gridtables/GetCells.js.map +1 -0
  43. package/lib/plugins/gridtables/common/gridtables/GetColumnWidths.d.ts +8 -0
  44. package/lib/plugins/gridtables/common/gridtables/GetColumnWidths.js +27 -0
  45. package/lib/plugins/gridtables/common/gridtables/GetColumnWidths.js.map +1 -0
  46. package/lib/plugins/gridtables/common/markdown-it/ColumnAlignments.d.ts +8 -0
  47. package/lib/plugins/gridtables/common/markdown-it/ColumnAlignments.js +13 -0
  48. package/lib/plugins/gridtables/common/markdown-it/ColumnAlignments.js.map +1 -0
  49. package/lib/plugins/gridtables/common/markdown-it/EmitTable.d.ts +5 -0
  50. package/lib/plugins/gridtables/common/markdown-it/EmitTable.js +67 -0
  51. package/lib/plugins/gridtables/common/markdown-it/EmitTable.js.map +1 -0
  52. package/lib/plugins/gridtables/common/markdown-it/GetCharCodeAtStartOfLine.d.ts +9 -0
  53. package/lib/plugins/gridtables/common/markdown-it/GetCharCodeAtStartOfLine.js +19 -0
  54. package/lib/plugins/gridtables/common/markdown-it/GetCharCodeAtStartOfLine.js.map +1 -0
  55. package/lib/plugins/gridtables/common/markdown-it/GetLine.d.ts +3 -0
  56. package/lib/plugins/gridtables/common/markdown-it/GetLine.js +10 -0
  57. package/lib/plugins/gridtables/common/markdown-it/GetLine.js.map +1 -0
  58. package/lib/plugins/gridtables/common/markdown-it/ParseTable.d.ts +4 -0
  59. package/lib/plugins/gridtables/common/markdown-it/ParseTable.js +162 -0
  60. package/lib/plugins/gridtables/common/markdown-it/ParseTable.js.map +1 -0
  61. package/lib/plugins/gridtables/common/markdown-it/ParseTableResult.d.ts +13 -0
  62. package/lib/plugins/gridtables/common/markdown-it/ParseTableResult.js +18 -0
  63. package/lib/plugins/gridtables/common/markdown-it/ParseTableResult.js.map +1 -0
  64. package/lib/plugins/gridtables/index.d.ts +2 -0
  65. package/lib/plugins/gridtables/index.js +11 -0
  66. package/lib/plugins/gridtables/index.js.map +1 -0
  67. package/lib/plugins/gridtables/interfaces/markdown-it/IState.d.ts +11 -0
  68. package/lib/plugins/gridtables/interfaces/markdown-it/IState.js +6 -0
  69. package/lib/plugins/gridtables/interfaces/markdown-it/IState.js.map +1 -0
  70. package/lib/plugins/gridtables/interfaces/markdown-it/IToken.d.ts +7 -0
  71. package/lib/plugins/gridtables/interfaces/markdown-it/IToken.js +6 -0
  72. package/lib/plugins/gridtables/interfaces/markdown-it/IToken.js.map +1 -0
  73. package/lib/plugins/gridtables/interfaces/markdown-it/TRuleFunction.d.ts +4 -0
  74. package/lib/plugins/gridtables/interfaces/markdown-it/TRuleFunction.js +6 -0
  75. package/lib/plugins/gridtables/interfaces/markdown-it/TRuleFunction.js.map +1 -0
  76. package/lib/plugins/gridtables/rules/gridtable.d.ts +4 -0
  77. package/lib/plugins/gridtables/rules/gridtable.js +26 -0
  78. package/lib/plugins/gridtables/rules/gridtable.js.map +1 -0
  79. package/lib/plugins/math.d.ts +5 -0
  80. package/lib/plugins/math.js +177 -0
  81. package/lib/plugins/math.js.map +1 -0
  82. package/lib/plugins/mermaid/index.d.ts +5 -0
  83. package/lib/plugins/mermaid/index.js +55 -0
  84. package/lib/plugins/mermaid/index.js.map +1 -0
  85. package/lib/plugins/shortcodes.d.ts +4 -0
  86. package/lib/plugins/shortcodes.js +33 -0
  87. package/lib/plugins/shortcodes.js.map +1 -0
  88. package/lib/plugins/spans.d.ts +3 -0
  89. package/lib/plugins/spans.js +39 -0
  90. package/lib/plugins/spans.js.map +1 -0
  91. package/lib/plugins/table-captions.d.ts +3 -0
  92. package/lib/plugins/table-captions.js +69 -0
  93. package/lib/plugins/table-captions.js.map +1 -0
  94. package/lib/plugins/utils/html.d.ts +12 -0
  95. package/lib/plugins/utils/html.js +46 -0
  96. package/lib/plugins/utils/html.js.map +1 -0
  97. package/lib/plugins/utils/markdownit.d.ts +16 -0
  98. package/lib/plugins/utils/markdownit.js +45 -0
  99. package/lib/plugins/utils/markdownit.js.map +1 -0
  100. package/lib/plugins/utils/tok.d.ts +8 -0
  101. package/lib/plugins/utils/tok.js +14 -0
  102. package/lib/plugins/utils/tok.js.map +1 -0
  103. package/lib/plugins/yaml.d.ts +3 -0
  104. package/lib/plugins/yaml.js +320 -0
  105. package/lib/plugins/yaml.js.map +1 -0
  106. package/lib/providers/attrs.d.ts +2 -0
  107. package/lib/providers/attrs.js +16 -0
  108. package/lib/providers/attrs.js.map +1 -0
  109. package/lib/providers/callouts.d.ts +2 -0
  110. package/lib/providers/callouts.js +16 -0
  111. package/lib/providers/callouts.js.map +1 -0
  112. package/lib/providers/cites.d.ts +2 -0
  113. package/lib/providers/cites.js +16 -0
  114. package/lib/providers/cites.js.map +1 -0
  115. package/lib/providers/decorator.d.ts +2 -0
  116. package/lib/providers/decorator.js +16 -0
  117. package/lib/providers/decorator.js.map +1 -0
  118. package/lib/providers/deflist.d.ts +2 -0
  119. package/lib/providers/deflist.js +16 -0
  120. package/lib/providers/deflist.js.map +1 -0
  121. package/lib/providers/divs.d.ts +2 -0
  122. package/lib/providers/divs.js +28 -0
  123. package/lib/providers/divs.js.map +1 -0
  124. package/lib/providers/figure-divs.d.ts +2 -0
  125. package/lib/providers/figure-divs.js +16 -0
  126. package/lib/providers/figure-divs.js.map +1 -0
  127. package/lib/providers/figures.d.ts +2 -0
  128. package/lib/providers/figures.js +16 -0
  129. package/lib/providers/figures.js.map +1 -0
  130. package/lib/providers/footnotes.d.ts +2 -0
  131. package/lib/providers/footnotes.js +16 -0
  132. package/lib/providers/footnotes.js.map +1 -0
  133. package/lib/providers/gridtables.d.ts +2 -0
  134. package/lib/providers/gridtables.js +16 -0
  135. package/lib/providers/gridtables.js.map +1 -0
  136. package/lib/providers/math.d.ts +2 -0
  137. package/lib/providers/math.js +105 -0
  138. package/lib/providers/math.js.map +1 -0
  139. package/lib/providers/mermaid.d.ts +2 -0
  140. package/lib/providers/mermaid.js +16 -0
  141. package/lib/providers/mermaid.js.map +1 -0
  142. package/lib/providers/provider.d.ts +4 -0
  143. package/lib/providers/provider.js +13 -0
  144. package/lib/providers/provider.js.map +1 -0
  145. package/lib/providers/shortcodes.d.ts +2 -0
  146. package/lib/providers/shortcodes.js +16 -0
  147. package/lib/providers/shortcodes.js.map +1 -0
  148. package/lib/providers/spans.d.ts +2 -0
  149. package/lib/providers/spans.js +16 -0
  150. package/lib/providers/spans.js.map +1 -0
  151. package/lib/providers/sub.d.ts +2 -0
  152. package/lib/providers/sub.js +16 -0
  153. package/lib/providers/sub.js.map +1 -0
  154. package/lib/providers/sup.d.ts +2 -0
  155. package/lib/providers/sup.js +16 -0
  156. package/lib/providers/sup.js.map +1 -0
  157. package/lib/providers/table-captions.d.ts +2 -0
  158. package/lib/providers/table-captions.js +16 -0
  159. package/lib/providers/table-captions.js.map +1 -0
  160. package/lib/providers/tasklists.d.ts +2 -0
  161. package/lib/providers/tasklists.js +16 -0
  162. package/lib/providers/tasklists.js.map +1 -0
  163. package/lib/providers/yaml.d.ts +2 -0
  164. package/lib/providers/yaml.js +16 -0
  165. package/lib/providers/yaml.js.map +1 -0
  166. package/lib/types.d.ts +44 -0
  167. package/lib/types.js +2 -0
  168. package/lib/types.js.map +1 -0
  169. package/lib/widgets.d.ts +15 -0
  170. package/lib/widgets.js +58 -0
  171. package/lib/widgets.js.map +1 -0
  172. package/package.json +1 -1
@@ -0,0 +1,177 @@
1
+ /*
2
+ * math.ts
3
+ *
4
+ * Copyright (C) 2020-2023 Posit Software, PBC
5
+ *
6
+ */
7
+ export const kTokMathBlock = "math_block";
8
+ export const kTokMathInline = "math_inline";
9
+ function renderMath(content, convertOptions) {
10
+ if (convertOptions.display) {
11
+ return `<div class='quarto-display-math'>\\[${content}\\]</div>`;
12
+ }
13
+ else {
14
+ return `<span class='quarto-inline-math'>\\(${content}\\)</span>`;
15
+ }
16
+ }
17
+ // Test if potential opening or closing delimieter
18
+ // Assumes that there is a "$" at state.src[pos]
19
+ function isValidDelim(state, pos) {
20
+ const max = state.posMax;
21
+ let can_open = true;
22
+ let can_close = true;
23
+ const prevChar = pos > 0 ? state.src.charCodeAt(pos - 1) : -1, nextChar = pos + 1 <= max ? state.src.charCodeAt(pos + 1) : -1;
24
+ // Check non-whitespace conditions for opening and closing, and
25
+ // check that closing delimeter isn't followed by a number
26
+ if (prevChar === 0x20 /* " " */ ||
27
+ prevChar === 0x09 /* \t */ ||
28
+ (nextChar >= 0x30 /* "0" */ && nextChar <= 0x39) /* "9" */) {
29
+ can_close = false;
30
+ }
31
+ if (nextChar === 0x20 /* " " */ || nextChar === 0x09 /* \t */) {
32
+ can_open = false;
33
+ }
34
+ return {
35
+ can_open: can_open,
36
+ can_close: can_close,
37
+ };
38
+ }
39
+ function math_inline(state, silent) {
40
+ if (state.src[state.pos] !== "$") {
41
+ return false;
42
+ }
43
+ let res = isValidDelim(state, state.pos);
44
+ if (!res.can_open) {
45
+ if (!silent) {
46
+ state.pending += "$";
47
+ }
48
+ state.pos += 1;
49
+ return true;
50
+ }
51
+ // First check for and bypass all properly escaped delimieters
52
+ // This loop will assume that the first leading backtick can not
53
+ // be the first character in state.src, which is known since
54
+ // we have found an opening delimieter already.
55
+ const start = state.pos + 1;
56
+ let match = start;
57
+ while ((match = state.src.indexOf("$", match)) !== -1) {
58
+ // Found potential $, look for escapes, pos will point to
59
+ // first non escape when complete
60
+ let pos = match - 1;
61
+ while (state.src[pos] === "\\") {
62
+ pos -= 1;
63
+ }
64
+ // Even number of escapes, potential closing delimiter found
65
+ if ((match - pos) % 2 == 1) {
66
+ break;
67
+ }
68
+ match += 1;
69
+ }
70
+ // No closing delimter found. Consume $ and continue.
71
+ if (match === -1) {
72
+ if (!silent) {
73
+ state.pending += "$";
74
+ }
75
+ state.pos = start;
76
+ return true;
77
+ }
78
+ // Check if we have empty content, ie: $$. Do not parse.
79
+ if (match - start === 0) {
80
+ if (!silent) {
81
+ state.pending += "$$";
82
+ }
83
+ state.pos = start + 1;
84
+ return true;
85
+ }
86
+ // Check for valid closing delimiter
87
+ res = isValidDelim(state, match);
88
+ if (!res.can_close) {
89
+ if (!silent) {
90
+ state.pending += "$";
91
+ }
92
+ state.pos = start;
93
+ return true;
94
+ }
95
+ if (!silent) {
96
+ const token = state.push("math_inline", "math", 0);
97
+ token.markup = "$";
98
+ token.content = state.src.slice(start, match);
99
+ }
100
+ state.pos = match + 1;
101
+ return true;
102
+ }
103
+ function math_block(state, start, end, silent) {
104
+ let next, lastPos;
105
+ let found = false, pos = state.bMarks[start] + state.tShift[start], max = state.eMarks[start], lastLine = "";
106
+ if (pos + 2 > max) {
107
+ return false;
108
+ }
109
+ if (state.src.slice(pos, pos + 2) !== "$$") {
110
+ return false;
111
+ }
112
+ pos += 2;
113
+ let firstLine = state.src.slice(pos, max);
114
+ if (silent) {
115
+ return true;
116
+ }
117
+ if (firstLine.trim().slice(-2) === "$$") {
118
+ // Single line expression
119
+ firstLine = firstLine.trim().slice(0, -2);
120
+ found = true;
121
+ }
122
+ let attrStr = undefined;
123
+ for (next = start; !found;) {
124
+ next++;
125
+ if (next >= end) {
126
+ break;
127
+ }
128
+ pos = state.bMarks[next] + state.tShift[next];
129
+ max = state.eMarks[next];
130
+ if (pos < max && state.tShift[next] < state.blkIndent) {
131
+ // non-empty line with negative indent should stop the list:
132
+ break;
133
+ }
134
+ const line = state.src.slice(pos, max).trim();
135
+ const match = line.match(/^\$\$\s*(\{.*\})?\s*$/);
136
+ if (match) {
137
+ lastPos = state.src.slice(0, max).lastIndexOf("$$");
138
+ lastLine = state.src.slice(pos, lastPos);
139
+ attrStr = match[1];
140
+ found = true;
141
+ }
142
+ }
143
+ state.line = next + 1;
144
+ const token = state.push(kTokMathBlock, "math", 0);
145
+ token.block = true;
146
+ if (attrStr) {
147
+ token.info = attrStr;
148
+ }
149
+ token.content =
150
+ (firstLine && firstLine.trim() ? firstLine + "\n" : "") +
151
+ state.getLines(start + 1, next, state.tShift[start], true) +
152
+ (lastLine && lastLine.trim() ? lastLine : "");
153
+ token.map = [start, state.line];
154
+ token.markup = "$$";
155
+ return true;
156
+ }
157
+ export function mathjaxPlugin(md) {
158
+ // Default options
159
+ const convertOptions = {
160
+ display: false
161
+ };
162
+ // set MathJax as the renderer for markdown-it-simplemath
163
+ md.inline.ruler.after("escape", kTokMathInline, math_inline);
164
+ md.block.ruler.after("blockquote", kTokMathBlock, math_block, {
165
+ alt: ["paragraph", "reference", "blockquote", "list"],
166
+ });
167
+ md.renderer.rules.math_inline = function (tokens, idx) {
168
+ convertOptions.display = false;
169
+ return renderMath(tokens[idx].content, convertOptions);
170
+ };
171
+ md.renderer.rules.math_block = function (tokens, idx) {
172
+ convertOptions.display = true;
173
+ return renderMath(tokens[idx].content, convertOptions);
174
+ };
175
+ }
176
+ ;
177
+ //# sourceMappingURL=math.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"math.js","sourceRoot":"","sources":["../../src/plugins/math.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAiBH,MAAM,CAAC,MAAM,aAAa,GAAG,YAAY,CAAC;AAC1C,MAAM,CAAC,MAAM,cAAc,GAAG,aAAa,CAAC;AAO5C,SAAS,UAAU,CAAC,OAAe,EAAE,cAA8B;IACjE,IAAI,cAAc,CAAC,OAAO,EAAE;QAC1B,OAAO,uCAAuC,OAAO,WAAW,CAAC;KAClE;SAAM;QACL,OAAO,uCAAuC,OAAO,YAAY,CAAC;KACnE;AACH,CAAC;AAED,kDAAkD;AAClD,gDAAgD;AAChD,SAAS,YAAY,CAAC,KAAkB,EAAE,GAAW;IACnD,MAAM,GAAG,GAAG,KAAK,CAAC,MAAM,CAAC;IACzB,IAAI,QAAQ,GAAG,IAAI,CAAC;IACpB,IAAI,SAAS,GAAG,IAAI,CAAC;IAErB,MAAM,QAAQ,GAAG,GAAG,GAAG,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,UAAU,CAAC,GAAG,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAC3D,QAAQ,GAAG,GAAG,GAAG,C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AA,CAAC"}
@@ -0,0 +1,5 @@
1
+ import MarkdownIt from "markdown-it";
2
+ export default function mermaidPlugin(md: MarkdownIt, options: {
3
+ dark?: boolean;
4
+ }): void;
5
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,55 @@
1
+ import Mermaid from "mermaid";
2
+ export default function mermaidPlugin(md, options) {
3
+ const kLang = "mermaid";
4
+ const kContainer = "quarto-mermaid";
5
+ Mermaid.initialize({
6
+ securityLevel: "loose",
7
+ theme: options.dark ? "dark" : "default",
8
+ ...options,
9
+ });
10
+ const defaultFenceRenderer = md.renderer.rules.fence;
11
+ // Render custom code types as SVGs, letting the fence parser do all the heavy lifting.
12
+ function mermaidFenceRenderer(tokens, idx, options, env, slf) {
13
+ const token = tokens[idx];
14
+ if (token.info === kLang || (token.attrs !== null && token.attrs.length === 1 && token.attrs[0][0] === kLang)) {
15
+ let imageHTML = "";
16
+ const imageAttrs = [];
17
+ // Create element to render into
18
+ const element = document.createElement("div");
19
+ document.body.appendChild(element);
20
+ // Render with Mermaid
21
+ try {
22
+ Mermaid.mermaidAPI.render(kContainer, token.content, (html) => {
23
+ // We need to forcibly extract the max-width/height attributes to set on img tag
24
+ const mermaidEl = document.getElementById(kContainer);
25
+ if (mermaidEl !== null) {
26
+ imageAttrs.push([
27
+ "style",
28
+ `max-width:${mermaidEl.style.maxWidth};max-height:${mermaidEl.style.maxHeight}`,
29
+ ]);
30
+ }
31
+ // Store HTML
32
+ imageHTML = html;
33
+ }, element);
34
+ }
35
+ catch (e) {
36
+ return `<pre>Failed to render mermaid diagram.${e}</pre>`;
37
+ }
38
+ finally {
39
+ element.remove();
40
+ }
41
+ // Store encoded image data
42
+ imageAttrs.push(["src", `data:image/svg+xml,${encodeURIComponent(imageHTML)}`]);
43
+ return `<img ${slf.renderAttrs({ attrs: imageAttrs })}>`;
44
+ }
45
+ else {
46
+ if (defaultFenceRenderer !== undefined) {
47
+ return defaultFenceRenderer(tokens, idx, options, env, slf);
48
+ }
49
+ // Missing fence renderer!
50
+ return "";
51
+ }
52
+ }
53
+ md.renderer.rules.fence = mermaidFenceRenderer;
54
+ }
55
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/plugins/mermaid/index.ts"],"names":[],"mappings":"AAEA,OAAO,OAAO,MAAM,SAAS,CAAC;AAE9B,MAAM,CAAC,OAAO,UAAU,aAAa,CAAC,EAAc,EAAE,OAA0B;IAG9E,MAAM,KAAK,GAAG,SAAS,CAAC;IACxB,MAAM,UAAU,GAAG,gBAAgB,CAAC;IAEpC,OAAO,CAAC,UAAU,CAAC;QACjB,aAAa,EAAE,OAAO;QACtB,KAAK,EAAE,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,SAAS;QACxC,GAAG,OAAO;KACX,CAAC,CAAC;IAEH,MAAM,oBAAoB,GAAG,EAAE,CAAC,QAAQ,CAAC,KAAK,CAAC,KAAK,CAAC;IAErD,uFAAuF;IACvF,SAAS,oBAAoB,CAC3B,MAAa,EACb,GAAW,EACX,OAAY,EACZ,GAAQ,EACR,GAAQ;QAER,MAAM,KAAK,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC;QAC1B,IAAI,KAAK,CAAC,IAAI,KAAK,KAAK,IAAI,CAAC,KAAK,CAAC,KAAK,KAAK,IAAI,IAAI,KAAK,CAAC,KAAK,CAAC,MAAM,KAAK,CAAC,IAAI,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,KAAK,CAAC,EAAG;YAC9G,IAAI,SAAS,GAAG,EAAE,CAAC;YACnB,MAAM,UAAU,GAAe,EAAE,CAAC;YAElC,gCAAgC;YAChC,MAAM,OAAO,GAAG,QAAQ,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC;YAC9C,QAAQ,CAAC,IAAI,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC;YAEnC,sBAAsB;YACtB,IAAI;gBACF,OAAO,CAAC,UAAU,CAAC,MAAM,CACvB,UAAU,EACV,KAAK,CAAC,OAAO,EACb,CAAC,IAAY,EAAE,EAAE;oBACf,gFAAgF;oBAChF,MAAM,SAAS,GAAG,QAAQ,CAAC,cAAc,CAAC,UAAU,CAAC,CAAC;oBACtD,IAAI,SAAS,KAAK,IAAI,EAAE;wBACtB,UAAU,CAAC,IAAI,CAAC;4BACd,OAAO;4BACP,aAAa,SAAS,CAAC,KAAK,CAAC,QAAQ,eAAe,SAAS,CAAC,KAAK,CAAC,SAAS,EAAE;yBAChF,CAAC,CAAC;qBACJ;oBACD,aAAa;oBACb,SAAS,GAAG,IAAI,CAAC;gBACnB,CAAC,EACD,OAAO,CACR,CAAC;aACH;YAAC,OAAO,CAAC,EAAE;gBACV,OAAO,yCAAyC,CAAC,QAAQ,CAAA;aAC1D;oBAAS;gBACR,OAAO,CAAC,MAAM,EAAE,CAAC;aAClB;YAED,2BAA2B;YAC3B,UAAU,CAAC,IAAI,CAAC,CAAC,KAAK,EAAE,sBAAsB,kBAAkB,CAAC,SAAS,CAAC,EAAE,CAAC,CAAC,CAAC;YAChF,OAAO,QAAQ,GAAG,CAAC,WAAW,CAAC,EAAE,KAAK,EAAE,UAAU,EAAE,CAAC,GAAG,CAAC;SAC1D;aAAM;YACL,IAAI,oBAAoB,KAAK,SAAS,EAAE;gBACtC,OAAO,oBAAoB,CAAC,MAAM,EAAE,GAAG,EAAE,OAAO,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC;aAC7D;YACD,0BAA0B;YAC1B,OAAO,EAAE,CAAC;SACX;IACH,CAAC;IACD,EAAE,CAAC,QAAQ,CAAC,KAAK,CAAC,KAAK,GAAG,oBAAoB,CAAC;AACjD,CAAC"}
@@ -0,0 +1,4 @@
1
+ import type MarkdownIt from "markdown-it/lib";
2
+ export declare const kShortcode = "shortcode";
3
+ export declare const shortcodePlugin: (md: MarkdownIt) => void;
4
+ //# sourceMappingURL=shortcodes.d.ts.map
@@ -0,0 +1,33 @@
1
+ import { escapeHtml } from "markdown-it/lib/common/utils";
2
+ export const kShortcode = "shortcode";
3
+ export const shortcodePlugin = (md) => {
4
+ const shortcode = (state, silent) => {
5
+ // {{< shortcode >}}
6
+ if (state.src.slice(state.pos, state.pos + 3) !== "{{<") {
7
+ return false;
8
+ }
9
+ const shortcodeEndRegex = />}}/g;
10
+ // ignore if shortcode doesn't end
11
+ const end = state.src.slice(state.pos).search(shortcodeEndRegex);
12
+ if (end === -1) {
13
+ return false;
14
+ }
15
+ const shortcodeContent = state.src.slice(state.pos + 3, state.pos + end);
16
+ if (!silent) {
17
+ const token = state.push("shortcode", "shortcode", 0);
18
+ token.markup = "";
19
+ token.content = shortcodeContent;
20
+ }
21
+ state.pos += end + 3;
22
+ return true;
23
+ };
24
+ md.inline.ruler.after("escape", kShortcode, shortcode);
25
+ const renderShortcode = (tokens, idx) => {
26
+ const token = tokens[idx];
27
+ const content = token.content;
28
+ // insert shortcode braces and escape content's html entities
29
+ return `<span class="shortcode">${escapeHtml(`{{<${content}>}}`)}</span>`;
30
+ };
31
+ md.renderer.rules[kShortcode] = renderShortcode;
32
+ };
33
+ //# sourceMappingURL=shortcodes.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"shortcodes.js","sourceRoot":"","sources":["../../src/plugins/shortcodes.ts"],"names":[],"mappings":"AAUA,OAAO,EAAE,UAAU,EAAE,MAAM,8BAA8B,CAAC;AAE1D,MAAM,CAAC,MAAM,UAAU,GAAG,WAAW,CAAC;AAEtC,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,EAAc,EAAE,EAAE;IAChD,MAAM,SAAS,GAAG,CAAC,KAAkB,EAAE,MAAe,EAAW,EAAE;QACjE,oBAAoB;QACpB,IAAI,KAAK,CAAC,GAAG,CAAC,KAAK,CAAC,KAAK,CAAC,GAAG,EAAE,KAAK,CAAC,GAAG,GAAG,CAAC,CAAC,KAAK,KAAK,EAAE;YACvD,OAAO,KAAK,CAAC;SACd;QACD,MA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MappingURL=spans.d.ts.map
@@ -0,0 +1,39 @@
1
+ /*
2
+ * span.ts
3
+ *
4
+ * Copyright (C) 2020-2023 Posit Software, PBC
5
+ *
6
+ */
7
+ export function spansPlugin(md) {
8
+ function span(state) {
9
+ const max = state.posMax;
10
+ if (state.src.charCodeAt(state.pos) !== 0x5B) {
11
+ // opening [
12
+ return false;
13
+ }
14
+ const labelStart = state.pos + 1;
15
+ const labelEnd = state.md.helpers.parseLinkLabel(state, state.pos, true);
16
+ if (labelEnd < 0) {
17
+ // parser failed to find closing ]
18
+ return false;
19
+ }
20
+ const pos = labelEnd + 1;
21
+ if (pos < max && state.src.charCodeAt(pos) === 0x7B /* { */) {
22
+ // probably found span
23
+ state.pos = labelStart;
24
+ state.posMax = labelEnd;
25
+ state.push('span_open', 'span', 1);
26
+ state.md.inline.tokenize(state);
27
+ state.push('span_close', 'span', -1);
28
+ state.pos = pos;
29
+ state.posMax = max;
30
+ return true;
31
+ }
32
+ else {
33
+ return false;
34
+ }
35
+ }
36
+ ;
37
+ md.inline.ruler.push('quarto-spans', span);
38
+ }
39
+ //# sourceMappingURL=spans.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"spans.js","sourceRoot":"","sources":["../../src/plugins/spans.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAMH,MAAM,UAAU,WAAW,CAAC,EAAc;IACxC,SAAS,IAAI,CAAC,KAAkB;QAC9B,MAAM,GAAG,GAAG,KAAK,CAAC,MAAM,CAAA;QAExB,IAAI,KAAK,CAAC,GAAG,CAAC,UAAU,CAAC,KAAK,CAAC,GAAG,CAAC,KAAK,IAAI,EAAE;YAC5C,YAAY;YACZ,OAAO,KAAK,CAAC;SACd;QAED,MAAM,UAAU,GAAG,KAAK,CAAC,GAAG,GAAG,CAAC,CAAC;QACjC,MAAM,QAAQ,GAAK,KAAK,CAAC,EAAE,CAAC,OAAO,CAAC,cAAc,CAAC,KAAK,EAAE,KAAK,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC;QAE3E,IAAI,QAAQ,GAAG,CAAC,EAAE;YAChB,kCAAkC;YAClC,OAAO,KAAK,CAAC;SACd;QAED,MAAM,GAAG,GAAG,QAAQ,GAAG,CAAC,CAAC;QACzB,IAAI,GAAG,GAAG,GAAG,IAAI,KAAK,CAAC,GAAG,CAAC,UAAU,CAAC,GAAG,CAAC,KAAK,IAAI,CAAC,OAAO,EAAE;YAC3D,sBAAsB;YAEtB,KAAK,CAAC,GAAG,GAAG,UAAU,CAAC;YACvB,KAAK,CAAC,MAAM,GAAG,QAAQ,CAAC;YAExB,KAAK,CAAC,IAAI,CAAC,WAAW,EAAE,MAAM,EAAE,CAAC,CAAC,CAAC;YACnC,KAAK,CAAC,EAAE,CAAC,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;YAChC,KAAK,CAAC,IAAI,CAAC,YAAY,EAAE,MAAM,EAAE,CAAC,CAAC,CAAC,CAAC;YAErC,KAAK,CAAC,GAAG,GAAG,GAAG,CAAC;YAChB,KAAK,CAAC,MAAM,GAAG,GAAG,CAAC;YACnB,OAAO,IAAI,CAAC;SACb;aAAM;YACL,OAAO,KAAK,CAAC;SACd;IACH,CAAC;IAAA,CAAC;IACF,EAAE,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,cAAc,EAAE,IAAI,CAAC,CAAC;AAC7C,CAAC"}
@@ -0,0 +1,3 @@
1
+ import MarkdownIt from "markdown-it";
2
+ export declare const tableCaptionPlugin: (md: MarkdownIt) => void;
3
+ //# sourceMappingURL=table-captions.d.ts.map
@@ -0,0 +1,69 @@
1
+ /*
2
+ * table-captions.ts
3
+ *
4
+ * Copyright (C) 2020-2023 Posit Software, PBC
5
+ *
6
+ */
7
+ import { kTokInline, kTokParaClose, kTokParaOpen, kTokTableClose, kTokTableOpen, kTokText } from "./utils/tok";
8
+ const kTableCaptionRule = "quarto-table-captions";
9
+ export const tableCaptionPlugin = (md) => {
10
+ md.core.ruler.push(kTableCaptionRule, (state) => {
11
+ const tableIdxs = [];
12
+ const tablePoss = [];
13
+ // Identify tables that we'd like to process
14
+ // The tables must be the bottom first (we will process them bottom to
15
+ // top to ensure that the positions remain accurate as the tokens
16
+ // are mutated
17
+ for (let i = 0; i < state.tokens.length; i++) {
18
+ const token = state.tokens[i];
19
+ if (token.type === kTokTableOpen) {
20
+ tableIdxs.push(i);
21
+ }
22
+ else if (token.type === kTokTableClose) {
23
+ const start = tableIdxs.pop();
24
+ if (start) {
25
+ tablePoss.unshift({
26
+ start,
27
+ end: i
28
+ });
29
+ }
30
+ }
31
+ }
32
+ // Look just past the tables and if there is a paragraph that is
33
+ // a table caption, extract that and place it in the table
34
+ for (const tablePos of tablePoss) {
35
+ resolveTableCaption(state.tokens, tablePos.start, tablePos.end);
36
+ }
37
+ });
38
+ };
39
+ function resolveTableCaption(tokens, tblStartPos, tblEndPos) {
40
+ // Must have at least three tokens past the table end
41
+ if (tokens.length > tblEndPos + 3) {
42
+ if (tokens[tblEndPos + 1].type === kTokParaOpen
43
+ && tokens[tblEndPos + 2].type === kTokInline
44
+ && tokens[tblEndPos + 3].type === kTokParaClose) {
45
+ const maybeCaption = tokens[tblEndPos + 2];
46
+ const isText = maybeCaption.children !== null && maybeCaption.children.length > 0 && maybeCaption.children[0].type === kTokText;
47
+ const maybeCaptionText = isText ? maybeCaption.children[0].content : "";
48
+ const match = maybeCaptionText.match(/^:\s([^{}]*)(?:\{.*\}){0,1}$/);
49
+ if (match && match[1]) {
50
+ // Carve out the existing tokens
51
+ const capTokens = tokens.splice(tblEndPos + 1, 3);
52
+ // We have the caption, remove the paragraph and return
53
+ // the caption
54
+ capTokens[0].type = "table_caption";
55
+ capTokens[0].tag = "caption";
56
+ // Forward any attributes from the caption up to the table
57
+ tokens[tblStartPos].attrs = capTokens[0].attrs;
58
+ capTokens[0].attrs = [];
59
+ // Trim the content
60
+ capTokens[1].children[0].content = match[1];
61
+ // Close the caption
62
+ capTokens[2].type = "table_caption";
63
+ capTokens[2].tag = "caption";
64
+ tokens.splice(tblStartPos + 1, 0, ...capTokens);
65
+ }
66
+ }
67
+ }
68
+ }
69
+ //# sourceMappingURL=table-captions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"table-captions.js","sourceRoot":"","sources":["../../src/plugins/table-captions.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH,OAAO,EAAE,UAAU,EAAE,aAAa,EAAE,YAAY,EAAE,cAAc,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAG/G,MAAM,iBAAiB,GAAG,uBAAuB,CAAC;AAElD,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,EAAc,EAAE,EAAE;IAEnD,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAChB,iBAAiB,EACjB,CAAC,KAAK,EAAE,EAAE;QAER,MAAM,SAAS,GAAa,EAAE,CAAC;QAC/B,MAAM,SAAS,GAAe,EAAE,CAAC;QAEjC,4CAA4C;QAC5C,sEAAsE;QACtE,iEAAiE;QACjE,cAAc;QACd,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;YAC5C,MAAM,KAAK,GAAG,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;YAC9B,IAAI,KAAK,CAAC,IAAI,KAAK,aAAa,EAAE;gBAChC,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;aACnB;iBAAM,IAAI,KAAK,CAAC,IAAI,KAAK,cAAc,EAAE;gBACxC,MAAM,KAAK,GAAG,SAAS,CAAC,GAAG,EAAE,CAAC;gBAC9B,IAAI,KAAK,EAAE;oBACT,SAAS,CAAC,OAAO,CAAC;wBAChB,KAAK;wBACL,GAAG,EAAE,CAAC;qBACP,CAAC,CAAA;iBACH;aACF;SACF;QAED,iEAAiE;QACjE,gEAAgE;QAChE,KAAK,MAAM,QAAQ,IAAI,SAAS,EAAE;YAChC,m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SAAS,CAAC;gBAE7B,0DAA0D;gBAC1D,MAAM,CAAC,WAAW,CAAC,CAAC,KAAK,GAAG,SAAS,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC;gBAC/C,SAAS,CAAC,CAAC,CAAC,CAAC,KAAK,GAAG,EAAE,CAAC;gBAExB,mBAAmB;gBACnB,SAAS,CAAC,CAAC,CAAC,CAAC,QAAS,CAAC,CAAC,CAAC,CAAC,OAAO,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC;gBAE7C,oBAAoB;gBACpB,SAAS,CAAC,CAAC,CAAC,CAAC,IAAI,GAAG,eAAe,CAAC;gBACpC,SAAS,CAAC,CAAC,CAAC,CAAC,GAAG,GAAG,SAAS,CAAC;gBAE7B,MAAM,CAAC,MAAM,CAAC,WAAW,GAAG,CAAC,EAAE,CAAC,EAAE,GAAG,SAAS,CAAC,CAAC;aACjD;SACJ;KACF;AACH,CAAC"}
@@ -0,0 +1,12 @@
1
+ import Token from "markdown-it/lib/token";
2
+ export interface DecoratorOptions {
3
+ customClass?: string;
4
+ hide: {
5
+ id?: boolean;
6
+ classes?: boolean;
7
+ attributes?: boolean;
8
+ };
9
+ }
10
+ export declare const decorator: (contents: string[], customClass?: string) => string;
11
+ export declare const attributeDecorator: (token: Token, options?: DecoratorOptions) => string;
12
+ //# sourceMappingURL=html.d.ts.map
@@ -0,0 +1,46 @@
1
+ /*
2
+ * html.ts
3
+ *
4
+ * Copyright (C) 2020-2023 Posit Software, PBC
5
+ *
6
+ */
7
+ import { readAttrValue } from "./markdownit";
8
+ export const decorator = (contents, customClass) => {
9
+ if (contents.length > 0) {
10
+ // Provide a decorator with the attributes
11
+ return `<div class="quarto-attribute-decorator${customClass ? ' ' + customClass : ""}">${contents.map(decoratorSpan).join("")}</div>`;
12
+ }
13
+ else {
14
+ // There is no decorator - no attributes
15
+ return "";
16
+ }
17
+ };
18
+ export const attributeDecorator = (token, options) => {
19
+ var _a;
20
+ // id
21
+ const id = readAttrValue("id", token.attrs);
22
+ // classes
23
+ const clz = readAttrValue("class", token.attrs);
24
+ // other attributes
25
+ const otherAttrs = (_a = token.attrs) === null || _a === void 0 ? void 0 : _a.filter((attr) => { return attr[0] !== "id" && attr[0] !== "class"; });
26
+ // Create a decorator for the div
27
+ const contents = [];
28
+ if (id && !(options === null || options === void 0 ? void 0 : options.hide.id)) {
29
+ contents.push(`#${id}`);
30
+ }
31
+ if (clz && !(options === null || options === void 0 ? void 0 : options.hide.classes)) {
32
+ const clzStr = clz.split(" ").map((cls) => `.${cls}`).join(" ");
33
+ contents.push(clzStr);
34
+ }
35
+ if (otherAttrs && otherAttrs.length > 0 && !(options === null || options === void 0 ? void 0 : options.hide.attributes)) {
36
+ const otherAttrStr = otherAttrs === null || otherAttrs === void 0 ? void 0 : otherAttrs.map((attr) => {
37
+ return `${attr[0]}="${attr[1]}"`;
38
+ }).join(" ");
39
+ contents.push(otherAttrStr);
40
+ }
41
+ return decorator(contents, options === null || options === void 0 ? void 0 : options.customClass);
42
+ };
43
+ const decoratorSpan = (contents) => {
44
+ return `<span class="quarto-attribute-decorator-content">${contents}</span>`;
45
+ };
46
+ //# sourceMappingURL=html.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"html.js","sourceRoot":"","sources":["../../../src/plugins/utils/html.ts"],"names":[],"mappings":"AAAA;;;;;EAKE;AAGF,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAW7C,MAAM,CAAC,MAAM,SAAS,GAAG,CAAC,QAAkB,EAAE,WAAoB,EAAE,EAAE;IACpE,IAAI,QAAQ,CAAC,MAAM,GAAG,CAAC,EAAE;QACvB,0CAA0C;QAC1C,OAAO,yCAAyC,WAAW,CAAC,CAAC,CAAC,GAAG,GAAG,WAAW,CAAC,CAAC,CAAC,EAAE,KAAK,QAAQ,CAAC,GAAG,CAAC,aAAa,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,QAAQ,CAAA;KACtI;SAAM;QACL,wCAAwC;QACxC,OAAO,EAAE,C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AAV,UAAU,uBAAV,UAAU,CAAE,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE;YAC5C,OAAO,GAAG,IAAI,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC,CAAC,CAAC,GAAG,CAAA;QAClC,CAAC,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC;QACb,QAAQ,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;KAC7B;IACD,OAAO,SAAS,CAAC,QAAQ,EAAE,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,WAAW,CAAC,CAAC;AACnD,CAAC,CAAA;AAED,MAAM,aAAa,GAAG,CAAC,QAAgB,EAAE,EAAE;IACzC,OAAO,oDAAoD,QAAQ,SAAS,CAAA;AAC9E,CAAC,CAAA"}
@@ -0,0 +1,16 @@
1
+ export declare const hasClass: (clz: string, attrs: null | [
2
+ string,
3
+ string
4
+ ][]) => boolean | undefined;
5
+ export declare const readAttrValue: (name: string, attrs: null | [
6
+ string,
7
+ string
8
+ ][]) => string | undefined;
9
+ export declare const addClass: (clz: string, attrs: null | [
10
+ string,
11
+ string
12
+ ][]) => [
13
+ string,
14
+ string
15
+ ][];
16
+ //# sourceMappingURL=markdownit.d.ts.map
@@ -0,0 +1,45 @@
1
+ /*
2
+ * markdownit.ts
3
+ *
4
+ * Copyright (C) 2020-2023 Posit Software, PBC
5
+ *
6
+ */
7
+ export const hasClass = (clz, attrs) => {
8
+ if (attrs === null) {
9
+ return false;
10
+ }
11
+ const classes = readAttrValue("class", attrs);
12
+ if (classes === null) {
13
+ return false;
14
+ }
15
+ else {
16
+ return classes === null || classes === void 0 ? void 0 : classes.split(" ").includes(clz);
17
+ }
18
+ };
19
+ export const readAttrValue = (name, attrs) => {
20
+ if (attrs === null) {
21
+ return undefined;
22
+ }
23
+ const attr = attrs.find((attr) => { return attr[0] === name; });
24
+ return attr ? attr[1] : undefined;
25
+ };
26
+ export const addClass = (clz, attrs) => {
27
+ if (attrs === null) {
28
+ attrs = [];
29
+ attrs.push(["class", clz]);
30
+ return attrs;
31
+ }
32
+ else {
33
+ const clzIdx = attrs.findIndex((attr) => attr[0] === "class");
34
+ if (clzIdx >= 0) {
35
+ const currentClz = attrs[clzIdx];
36
+ attrs[clzIdx] = ["class", `${currentClz[1]} ${clz}`.trim()];
37
+ return attrs;
38
+ }
39
+ else {
40
+ attrs.push(["class", clz]);
41
+ return attrs;
42
+ }
43
+ }
44
+ };
45
+ //# sourceMappingURL=markdownit.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"markdownit.js","sourceRoot":"","sources":["../../../src/plugins/utils/markdownit.ts"],"names":[],"mappings":"AAAA;;;;;EAKE;AAEF,MAAM,CAAC,MAAM,QAAQ,GAAG,CAAC,GAAW,EAAE,KAAgC,EAAE,EAAE;IACxE,IAAI,KAAK,KAAK,IAAI,EAAE;QAClB,OAAO,KAAK,CAAA;KACb;IAED,MAAM,OAAO,GAAG,aAAa,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;IAC9C,IAAI,OAAO,KAAK,IAAI,EAAE;QACpB,OAAO,KAAK,CAAC;KACd;SAAM;QACL,OAAO,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,KAAK,CAAC,GAAG,EAAE,QAAQ,CAAC,GAAG,CAAC,CAAC;KAC1C;AAGH,CAAC,CAAA;AAED,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,IAAY,EAAE,KAAgC,EAAE,EAAE;IAC9E,IAAI,KAAK,KAAK,IAAI,EAAE;QAClB,OAAO,SAAS,CAAC;KAClB;IAED,MAAM,IAAI,GAAG,KAAK,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE,GAAG,OAAO,IAAI,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;IAChE,OAAO,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;AACpC,CAAC,CAAA;AAED,MAAM,CAAC,MAAM,QAAQ,GAAG,CAAC,GAAW,EAAE,KAAgC,EAAsB,EAAE;IAC5F,IAAI,KAAK,KAAK,IAAI,EAAE;QAClB,KAAK,GAAG,EAAE,CAAA;QACV,KAAK,CAAC,IAAI,CAAC,CAAC,OAAO,EAAE,GAAG,CAAC,CAAC,CAAA;QAC1B,OAAO,KAAK,CAAC;KACd;SAAM;QACL,MAAM,MAAM,GAAG,KAAK,CAAC,SAAS,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,OAAO,CAAC,CAAC;QAC9D,IAAI,MAAM,IAAI,CAAC,EAAE;YACf,MAAM,UAAU,GAAG,KAAK,CAAC,MAAM,CAAC,CAAC;YACjC,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC,OAAO,EAAE,GAAG,UAAU,CAAC,CAAC,CAAC,IAAI,GAAG,EAAE,CAAC,IAAI,EAAE,CAAC,CAAC;YAC5D,OAAO,KAAK,CAAC;SACd;aAAM;YACL,KAAK,CAAC,IAAI,CAAC,CAAC,OAAO,EAAE,GAAG,CAAC,CAAC,CAAA;YAC1B,OAAO,KAAK,CAAC;SACd;KACF;AACH,CAAC,CAAA"}
@@ -0,0 +1,8 @@
1
+ export declare const kTokParaOpen = "paragraph_open";
2
+ export declare const kTokParaClose = "paragraph_close";
3
+ export declare const kTokInline = "inline";
4
+ export declare const kTokTableOpen = "table_open";
5
+ export declare const kTokTableClose = "table_close";
6
+ export declare const kTokText = "text";
7
+ export declare const kTokHeadingOpen = "heading_open";
8
+ //# sourceMappingURL=tok.d.ts.map
@@ -0,0 +1,14 @@
1
+ /*
2
+ * tok.ts
3
+ *
4
+ * Copyright (C) 2020-2023 Posit Software, PBC
5
+ *
6
+ */
7
+ export const kTokParaOpen = "paragraph_open";
8
+ export const kTokParaClose = "paragraph_close";
9
+ export const kTokInline = "inline";
10
+ export const kTokTableOpen = "table_open";
11
+ export const kTokTableClose = "table_close";
12
+ export const kTokText = "text";
13
+ export const kTokHeadingOpen = "heading_open";
14
+ //# sourceMappingURL=tok.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tok.js","sourceRoot":"","sources":["../../../src/plugins/utils/tok.ts"],"names":[],"mappings":"AAAA;;;;;EAKE;AAGF,MAAM,CAAC,MAAM,YAAY,GAAG,gBAAgB,CAAC;AAC7C,MAAM,CAAC,MAAM,aAAa,GAAG,iBAAiB,CAAC;AAE/C,MAAM,CAAC,MAAM,UAAU,GAAG,QAAQ,CAAC;AAEnC,MAAM,CAAC,MAAM,aAAa,GAAG,YAAY,CAAC;AAC1C,MAAM,CAAC,MAAM,cAAc,GAAG,aAAa,CAAC;AAE5C,MAAM,CAAC,MAAM,QAAQ,GAAG,MAAM,CAAC;AAE/B,MAAM,CAAC,MAAM,eAAe,GAAG,cAAc,CAAC"}
@@ -0,0 +1,3 @@
1
+ import MarkdownIt from "markdown-it";
2
+ export declare function yamlPlugin(md: MarkdownIt, cb?: (yaml: unknown) => void): void;
3
+ //# sourceMappingURL=yaml.d.ts.map