@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
@@ -0,0 +1,147 @@
1
+ /*
2
+ * citation.ts
3
+ *
4
+ * Copyright (C) 2020-2023 Posit Software, PBC
5
+ *
6
+ */
7
+ const kTokCite = "quarto_cite";
8
+ export const citationPlugin = (md) => {
9
+ // Very simple plugin example that surrounds @text with `code`
10
+ md.core.ruler.push('quarto-citation', function replaceAtSymbol(state) {
11
+ const tokens = state.tokens;
12
+ for (const token of tokens) {
13
+ if (token.type === 'inline' && token.children) {
14
+ // Rebuild the child list
15
+ const children = [];
16
+ for (let i = 0; i < token.children.length; i++) {
17
+ const child = token.children[i];
18
+ if (child.type === 'text') {
19
+ let content = child.content;
20
+ const textToken = (text) => {
21
+ const newToken = new state.Token('text', '', 0);
22
+ newToken.content = text.join("");
23
+ return newToken;
24
+ };
25
+ let text = [];
26
+ const flushText = () => {
27
+ if (text.length) {
28
+ children.push(textToken(text));
29
+ text = [];
30
+ }
31
+ };
32
+ let cite = [];
33
+ const flushCite = () => {
34
+ var _a;
35
+ if (cite.length) {
36
+ // Determine the cite style
37
+ let style = cite[0] === "-" ? "suppress-author" : "in-text";
38
+ if (bracketCount > 0) {
39
+ style = "normal";
40
+ }
41
+ // The classes
42
+ const clz = ["cite", style];
43
+ // If the cite ends in punctuation, trim that off and make that text
44
+ let puncText = [];
45
+ // Trim off ending punctuation
46
+ if ([":", ".", "#", "$", "%", "&", "-", "+", "?", "<", ">", "~", "/", "!"].includes(cite[cite.length - 1])) {
47
+ puncText.push(cite[cite.length - 1]);
48
+ cite = cite.slice(0, -1);
49
+ }
50
+ // Make a cite token
51
+ const newToken = new state.Token(kTokCite, '', 0);
52
+ newToken.content = cite.join("");
53
+ newToken.attrs = newToken.attrs || [];
54
+ (_a = newToken.attrs) === null || _a === void 0 ? void 0 : _a.push(["class", clz.join(" ")]);
55
+ children.push(newToken);
56
+ cite = [];
57
+ if (puncText.length > 0) {
58
+ children.push(textToken(puncText));
59
+ }
60
+ }
61
+ };
62
+ let capture = "text";
63
+ let bracketCount = 0;
64
+ for (let j = 0; j < content.length; j++) {
65
+ const char = content.charAt(j);
66
+ if (char === "@") {
67
+ if ((text.length === 1 && text[0] === '-') ||
68
+ text.length > 1 && text[text.length - 1] === "-" && text[text.length - 2] === "[") {
69
+ cite.push('-');
70
+ cite.push(char);
71
+ text.pop();
72
+ flushText();
73
+ capture = 'cite';
74
+ }
75
+ else if (text[text.length - 1] === ' ') {
76
+ flushText();
77
+ cite.push(char);
78
+ capture = 'cite';
79
+ }
80
+ else if (text[text.length - 1] === '-' && text[text.length - 2] === ' ') {
81
+ text = text.slice(0, -1);
82
+ flushText();
83
+ cite.push('-');
84
+ cite.push(char);
85
+ capture = 'cite';
86
+ }
87
+ else if (text[text.length - 1] === '[' && text[text.length - 2] === ' ') {
88
+ flushText();
89
+ cite.push(char);
90
+ capture = 'cite';
91
+ }
92
+ else if (text.length === 0) {
93
+ cite.push(char);
94
+ capture = 'cite';
95
+ }
96
+ else {
97
+ if (capture === 'cite') {
98
+ cite.push(char);
99
+ }
100
+ else {
101
+ text.push(char);
102
+ }
103
+ }
104
+ }
105
+ else if (char === " ") {
106
+ capture = 'text';
107
+ flushCite();
108
+ text.push(char);
109
+ }
110
+ else if (char === "[") {
111
+ bracketCount++;
112
+ text.push(char);
113
+ }
114
+ else if (char === "]") {
115
+ bracketCount--;
116
+ capture = 'text';
117
+ flushCite();
118
+ text.push(char);
119
+ }
120
+ else {
121
+ if (capture === 'cite') {
122
+ cite.push(char);
123
+ }
124
+ else {
125
+ text.push(char);
126
+ }
127
+ }
128
+ }
129
+ flushCite();
130
+ flushText();
131
+ }
132
+ else {
133
+ children.push(child);
134
+ }
135
+ }
136
+ token.children = children.length > 0 ? children : null;
137
+ }
138
+ }
139
+ });
140
+ md.renderer.rules[kTokCite] = renderCite;
141
+ };
142
+ // Render pandoc-style divs
143
+ function renderCite(tokens, idx, options, env, self) {
144
+ const token = tokens[idx];
145
+ const citeContent = `<code ${self.renderAttrs(token)}>${token.content}</code>`;
146
+ return citeContent;
147
+ }
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cites.js","sourceRoot":"","sources":["../../src/plugins/cites.ts"],"names":[],"mappings":"AAAA;;;;;EAKE;AAOF,MAAM,QAAQ,GAAG,aAAa,CAAC;AAE/B,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,EAAc,EAAE,EAAE;IAE/C,8DAA8D;IAC9D,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,iBAAiB,EAAE,SAAS,eAAe,CAAC,KAAK;QAClE,MAAM,MAAM,GAAG,KAAK,CAAC,MAAM,CAAC;QAE5B,KAAK,MAAM,KAAK,IAAI,MAAM,EAAE;YAC1B,IAAI,KAAK,CAAC,IAAI,KAAK,QAAQ,IAAI,KAAK,CAAC,QAAQ,EAAE;gBAE7C,yBAAyB;gBACzB,MAAM,QAAQ,GAAY,EAAE,CAAC;gBAC7B,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK,CAAC,QAAQ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AM,GAAG,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC;aACxD;SACF;IACH,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,QAAQ,CAAC,KAAK,CAAC,QAAQ,CAAC,GAAG,UAAU,CAAA;AAC1C,CAAC,CAAA;AAGD,2BAA2B;AAC3B,SAAS,UAAU,CAAC,MAAe,EAAE,GAAW,EAAE,OAA2B,EAAE,GAAQ,EAAE,IAAc;IACrG,MAAM,KAAK,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC;IAC1B,MAAM,WAAW,GAAI,SAAS,IAAI,CAAC,WAAW,CAAC,KAAK,CAAC,IAAI,KAAK,CAAC,OAAO,SAAS,CAAC;IAChF,OAAO,WAAW,CAAC;AACrB,CAAC"}
@@ -0,0 +1,3 @@
1
+ import type MarkdownIt from "markdown-it/lib";
2
+ export declare const decoratorPlugin: (md: MarkdownIt) => void;
3
+ //# sourceMappingURL=decorator.d.ts.map
@@ -0,0 +1,58 @@
1
+ import Token from "markdown-it/lib/token";
2
+ import { attributeDecorator, decorator } from "../utils/html";
3
+ import { kTokDivOpen } from "./divs";
4
+ import { kTokFigureOpen } from "./figures";
5
+ import { kTokHeadingOpen, kTokTableOpen } from "../utils/tok";
6
+ import { kTokMathBlock } from "./math";
7
+ const kTokDecorator = "quarto_decorator";
8
+ const kQuartoDecoratorOptions = "quarto-decorator-options";
9
+ export const decoratorPlugin = (md) => {
10
+ md.core.ruler.push('quarto-decorator', function replaceAtSymbol(state) {
11
+ const outTokens = [];
12
+ for (const token of state.tokens) {
13
+ if (token.type === "fence" && !token.attrs && token.info) {
14
+ outTokens.push(decoratorTokForToken(token));
15
+ }
16
+ else if (token.type === kTokHeadingOpen && token.attrs) {
17
+ outTokens.push(decoratorTokForToken(token));
18
+ }
19
+ else if (token.type === kTokDivOpen && token.attrs) {
20
+ outTokens.push(decoratorTokForToken(token));
21
+ }
22
+ else if (token.type === kTokFigureOpen && token.attrs) {
23
+ outTokens.push(decoratorTokForToken(token, { hide: { attributes: true } }));
24
+ }
25
+ else if (token.type === kTokTableOpen && token.attrs) {
26
+ outTokens.push(decoratorTokForToken(token));
27
+ }
28
+ else if (token.type === kTokMathBlock && token.attrs) {
29
+ outTokens.push(decoratorTokForToken(token));
30
+ }
31
+ outTokens.push(token);
32
+ }
33
+ state.tokens = outTokens;
34
+ });
35
+ md.renderer.rules[kTokDecorator] = renderDecorator;
36
+ };
37
+ function decoratorTokForToken(token, options) {
38
+ const decoratorTok = new Token(kTokDecorator, "div", 1);
39
+ decoratorTok.attrs = token.attrs;
40
+ decoratorTok.info = token.info;
41
+ if (options) {
42
+ decoratorTok.meta = decoratorTok.meta || {};
43
+ decoratorTok.meta[kQuartoDecoratorOptions] = options;
44
+ }
45
+ return decoratorTok;
46
+ }
47
+ // Render pandoc-style divs
48
+ function renderDecorator(tokens, idx, options, env, self) {
49
+ var _a;
50
+ const token = tokens[idx];
51
+ const decoratorOptions = (_a = token.meta) === null || _a === void 0 ? void 0 : _a[kQuartoDecoratorOptions];
52
+ if (token.info) {
53
+ return decorator([token.info]);
54
+ }
55
+ else {
56
+ return attributeDecorator(token, decoratorOptions);
57
+ }
58
+ }
@@ -0,0 +1 @@
1
+ {"version":3,"file":"decorator.js","sourceRoot":"","sources":["../../src/plugins/decorator.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,MAAM,uBAAuB,CAAA;AAEzC,OAAO,EAAE,kBAAkB,EAAE,SAAS,EAAoB,MAAM,eAAe,CAAC;AAChF,OAAO,EAAE,WAAW,EAAE,MAAM,QAAQ,CAAC;AACrC,OAAO,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAC3C,OAAO,EAAE,eAAe,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAC9D,OAAO,EAAE,aAAa,EAAE,MAAM,QAAQ,CAAC;AAGvC,MAAM,aAAa,GAAG,kBAAkB,CAAC;AACzC,MAAM,uBAAuB,GAAG,0BAA0B,CAAC;AAG3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;YACD,SAAS,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;SACvB;QACD,KAAK,CAAC,MAAM,GAAG,SAAS,CAAC;IAC3B,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,QAAQ,CAAC,KAAK,CAAC,aAAa,CAAC,GAAG,eAAe,CAAA;AACpD,CAAC,CAAA;AAED,SAAS,oBAAoB,CAAC,KAAY,EAAE,OAA0B;IACpE,MAAM,YAAY,GAAG,IAAI,KAAK,CAAC,aAAa,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC;IACxD,YAAY,CAAC,KAAK,GAAG,KAAK,CAAC,KAAK,CAAC;IACjC,YAAY,CAAC,IAAI,GAAG,KAAK,CAAC,IAAI,CAAC;IAC/B,IAAI,OAAO,EAAE;QACX,YAAY,CAAC,IAAI,GAAG,YAAY,CAAC,IAAI,IAAI,EAAE,CAAC;QAC5C,YAAY,CAAC,IAAI,CAAC,uBAAuB,CAAC,GAAG,OAAO,CAAC;KACtD;IACD,OAAO,YAAY,CAAC;AACtB,CAAC;AAGD,2BAA2B;AAC3B,SAAS,eAAe,CAAC,MAAe,EAAE,GAAW,EAAE,OAA2B,EAAE,GAAQ,EAAE,IAAc;;IAC1G,MAAM,KAAK,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC;IAC1B,MAAM,gBAAgB,SAAG,KAAK,CAAC,IAAI,0CAAG,uBAAuB,CAAC,CAAC;IAC/D,IAAI,KAAK,CAAC,IAAI,EAAE;QACd,OAAO,SAAS,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAE;KACjC;SAAM;QACL,OAAO,kBAAkB,CAAC,KAAK,EAAE,gBAAgB,CAAC,CAAC;KACpD;AACH,CAAC"}
@@ -0,0 +1,6 @@
1
+ import type MarkdownIt from "markdown-it/lib";
2
+ export declare const kDivRuleName = "pandocDiv";
3
+ export declare const kTokDivOpen = "pandoc_div_open";
4
+ export declare const kTokDivClose = "pandoc_div_close";
5
+ export declare const divPlugin: (md: MarkdownIt) => void;
6
+ //# sourceMappingURL=divs.d.ts.map
@@ -0,0 +1,99 @@
1
+ import { addClass } from "../utils/markdownit";
2
+ export const kDivRuleName = "pandocDiv";
3
+ export const kTokDivOpen = 'pandoc_div_open';
4
+ export const kTokDivClose = 'pandoc_div_close';
5
+ export const divPlugin = (md) => {
6
+ // Render pandoc-style divs
7
+ function renderStartDiv(tokens, idx, options, env, self) {
8
+ // Add a class to designate that this is a quarto dev
9
+ const token = tokens[idx];
10
+ token.attrs = addClass("quarto-div", token.attrs);
11
+ return `<div ${self.renderAttrs(token)}>`;
12
+ }
13
+ // Render pandoc-style divs
14
+ function renderEndDiv(tokens, idx, options, env, self) {
15
+ return `</div>`;
16
+ }
17
+ // TODO Implement a better test during validation run
18
+ // Handle pandoc-style divs
19
+ md.block.ruler.before("fence", kDivRuleName, (state, start, end, silent) => {
20
+ // This is a validation run, can ignore
21
+ if (silent) {
22
+ return true;
23
+ }
24
+ // Get the line for parsing
25
+ const lineStart = state.bMarks[start] + state.tShift[start];
26
+ const lineEnd = state.eMarks[start];
27
+ const line = state.src.slice(lineStart, lineEnd);
28
+ // The current state of the divs (e.g. is there an open)
29
+ // div. Data structure holds key that is the number of colons
30
+ const divState = state.env.quartoOpenDivs || {};
31
+ const incrementDivCount = (fence) => {
32
+ state.env.quartoOpenDivs = state.env.quartoOpenDivs || {};
33
+ const current = state.env.quartoOpenDivs[fence] || 0;
34
+ state.env.quartoOpenDivs[fence] = Math.max(0, current + 1);
35
+ };
36
+ const decrementDivCount = (fence) => {
37
+ state.env.quartoOpenDivs = state.env.quartoOpenDivs || {};
38
+ const current = state.env.quartoOpenDivs[fence] || 0;
39
+ state.env.quartoOpenDivs[fence] = Math.max(0, current - 1);
40
+ };
41
+ // Three or more colons followed by a an optional brace with attributes
42
+ const divBraceRegex = /^(:::+)\s*(?:(\{[\s\S]+?\}))?$/;
43
+ // Three or more colons followed by a string with no braces
44
+ const divNoBraceRegex = /^(:::+)\s*(?:([^\{\}\s]+?))?$/;
45
+ const matchers = [divBraceRegex, divNoBraceRegex];
46
+ let match;
47
+ for (const matcher of matchers) {
48
+ match = matcher.exec(line);
49
+ if (match) {
50
+ break;
51
+ }
52
+ }
53
+ if (match) {
54
+ // There is a div here, is one already open?
55
+ const divFence = match[1];
56
+ const attr = match[2];
57
+ // Is this open?
58
+ let isOpenDiv = false;
59
+ const openCount = divState[divFence];
60
+ if (!openCount || openCount === 0) {
61
+ // There isn't an existing open div at this level (number of colons)
62
+ isOpenDiv = true;
63
+ }
64
+ else if (attr) {
65
+ // If it has attributes it is always open
66
+ isOpenDiv = true;
67
+ }
68
+ if (isOpenDiv) {
69
+ // Add to the open count (or set it to 1)
70
+ incrementDivCount(divFence);
71
+ // Make an open token
72
+ const token = state.push(kTokDivOpen, "div", 1);
73
+ token.markup = line;
74
+ // Allow this to be parsed for attributes by markdown-it-attr
75
+ if (attr && attr.startsWith("{")) {
76
+ token.info = attr;
77
+ }
78
+ else if (attr) {
79
+ token.info = `{.${attr}}`;
80
+ }
81
+ token.block = true;
82
+ }
83
+ else {
84
+ // Subtract from the open count (min zero)
85
+ decrementDivCount(divFence);
86
+ // Make a close token
87
+ const token = state.push(kTokDivClose, "div", -1);
88
+ token.markup = line;
89
+ }
90
+ state.line = start + 1;
91
+ return true;
92
+ }
93
+ else {
94
+ return false;
95
+ }
96
+ }, { alt: [] });
97
+ md.renderer.rules[kTokDivOpen] = renderStartDiv;
98
+ md.renderer.rules[kTokDivClose] = renderEndDiv;
99
+ };
@@ -0,0 +1 @@
1
+ {"version":3,"file":"divs.js","sourceRoot":"","sources":["../../src/plugins/divs.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAE/C,MAAM,CAAC,MAAM,YAAY,GAAG,WAAW,CAAC;AAExC,MAAM,CAAC,MAAM,WAAW,GAAG,iBAAiB,CAAC;AAC7C,MAAM,CAAC,MAAM,YAAY,GAAG,kBAAkB,CAAC;AAE/C,MAAM,CA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AAY,CAAC,GAAG,YAAY,CAAA;AAChD,CAAC,CAAA"}
@@ -0,0 +1,3 @@
1
+ import MarkdownIt from "markdown-it";
2
+ export declare const figureDivsPlugin: (md: MarkdownIt) => void;
3
+ //# sourceMappingURL=figure-divs.d.ts.map
@@ -0,0 +1,52 @@
1
+ /*
2
+ * figure-divs.ts
3
+ *
4
+ * Copyright (C) 2020-2023 Posit Software, PBC
5
+ *
6
+ */
7
+ import { readAttrValue } from "../utils/markdownit";
8
+ import { kTokInline, kTokParaClose, kTokParaOpen } from "../utils/tok";
9
+ import { kTokDivClose, kTokDivOpen } from "./divs";
10
+ import { kTokFigCaptionClose, kTokFigCaptionOpen, mutateToFigureTok } from "./figures";
11
+ const kFigureDivRuleName = "quarto-figure-divs";
12
+ const kFigurePrefix = "fig-";
13
+ export const figureDivsPlugin = (md) => {
14
+ // Handle pandoc-style divs
15
+ md.core.ruler.push(kFigureDivRuleName, (state) => {
16
+ let isFigureDiv = [];
17
+ for (let i = 0; i < state.tokens.length; i++) {
18
+ const token = state.tokens[i];
19
+ if (token.type === kTokDivOpen) {
20
+ const id = readAttrValue("id", token.attrs);
21
+ if (id === null || id === void 0 ? void 0 : id.startsWith(kFigurePrefix)) {
22
+ isFigureDiv.push(true);
23
+ mutateToFigureTok(token, "open");
24
+ }
25
+ else {
26
+ // Note the div, but not a figure div
27
+ isFigureDiv.push(false);
28
+ }
29
+ }
30
+ else if (token.type === kTokDivClose) {
31
+ const isFigDiv = isFigureDiv.pop();
32
+ if (isFigDiv) {
33
+ // If the preview token is paragraph, use that as the caption
34
+ if (i - 3 >= 0) {
35
+ const maybeParaStart = state.tokens[i - 3];
36
+ const maybeInline = state.tokens[i - 2];
37
+ const maybeParaEnd = state.tokens[i - 1];
38
+ if (maybeParaStart.type === kTokParaOpen && maybeParaEnd.type === kTokParaClose && maybeInline.type === kTokInline) {
39
+ mutateToFigCaption(state.tokens[i - 3], "open");
40
+ mutateToFigCaption(state.tokens[i - 1], "close");
41
+ }
42
+ }
43
+ mutateToFigureTok(token, "close");
44
+ }
45
+ }
46
+ }
47
+ });
48
+ };
49
+ const mutateToFigCaption = (token, type) => {
50
+ token.tag = "figcaption";
51
+ token.type = type === "open" ? kTokFigCaptionClose : kTokFigCaptionOpen;
52
+ };
@@ -0,0 +1 @@
1
+ {"version":3,"file":"figure-divs.js","sourceRoot":"","sources":["../../src/plugins/figure-divs.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,EAAE,UAAU,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AACvE,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,QAAQ,CAAC;AACnD,OAAO,EAAE,mBAAmB,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAC;AAGvF,MAAM,kBAAkB,GAAG,oBAAoB,CAAC;AAChD,MAAM,aAAa,GAAG,MAAM,CAAC;AAG7B,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,EAAc,EAAE,EAAE;IAEjD,2BAA2B;IAC3B,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAChB,kBAAkB,EAClB,CAAC,KAAK,EAAE,EAAE;QAER,IAAI,WAAW,GAAc,EAAE,CAAC;QAEhC,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,WAAW,EAAE;gBAC9B,MAAM,EAAE,GAAG,aAAa,CAAC,IAAI,EAAE,KAAK,CAAC,KAAK,CAAC,CAAC;gBAC5C,IAAI,EAAE,aAAF,EAAE,uBAAF,EAAE,CAAE,UAAU,CAAC,aAAa,GAAG;oBACjC,WAAW,CAAC,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AAC,kBAAkB,CAAC;AAC1E,CAAC,CAAA"}
@@ -0,0 +1,17 @@
1
+ import MarkdownIt from "markdown-it";
2
+ import Token from "markdown-it/lib/token";
3
+ export interface FigureOptions {
4
+ dataType?: boolean;
5
+ link?: boolean;
6
+ figcaption?: boolean;
7
+ copyAttrs?: boolean;
8
+ tabindex?: boolean;
9
+ lazyLoading?: boolean;
10
+ }
11
+ export declare const kTokFigureOpen = "figure_open";
12
+ export declare const kTokFigureClose = "figure_close";
13
+ export declare const kTokFigCaptionOpen = "figcaption_open";
14
+ export declare const kTokFigCaptionClose = "figcaption_close";
15
+ export declare const mutateToFigureTok: (token: Token, type: "open" | "close") => void;
16
+ export declare function figuresPlugin(md: MarkdownIt, options: FigureOptions): void;
17
+ //# sourceMappingURL=figures.d.ts.map
@@ -0,0 +1,98 @@
1
+ /*
2
+ * figures.ts
3
+ *
4
+ * Copyright (C) 2020-2023 Posit Software, PBC
5
+ *
6
+ */
7
+ import { kTokParaClose, kTokParaOpen } from "../utils/tok";
8
+ export const kTokFigureOpen = "figure_open";
9
+ export const kTokFigureClose = "figure_close";
10
+ export const kTokFigCaptionOpen = "figcaption_open";
11
+ export const kTokFigCaptionClose = "figcaption_close";
12
+ export const mutateToFigureTok = (token, type) => {
13
+ token.type = type === "open" ? kTokFigureOpen : kTokFigureClose;
14
+ token.tag = "figure";
15
+ };
16
+ export function figuresPlugin(md, options) {
17
+ options = options || {};
18
+ md.core.ruler.before("linkify", "implicit_figures", (state) => {
19
+ // reset tabIndex on md.render()
20
+ var tabIndex = 1;
21
+ // do not process first and last token
22
+ for (var i = 1, l = state.tokens.length; i < l - 1; ++i) {
23
+ var token = state.tokens[i];
24
+ if (token.type !== "inline") {
25
+ continue;
26
+ }
27
+ // children: image alone, or link_open -> image -> link_close
28
+ if (!token.children ||
29
+ (token.children.length !== 1 && token.children.length !== 3)) {
30
+ continue;
31
+ }
32
+ // one child, should be img
33
+ if (token.children.length === 1 && token.children[0].type !== "image") {
34
+ continue;
35
+ }
36
+ // three children, should be image enclosed in link
37
+ if (token.children.length === 3 &&
38
+ (token.children[0].type !== "link_open" ||
39
+ token.children[1].type !== "image" ||
40
+ token.children[2].type !== "link_close")) {
41
+ continue;
42
+ }
43
+ // prev token is paragraph open
44
+ if (i !== 0 && state.tokens[i - 1].type !== kTokParaOpen) {
45
+ continue;
46
+ }
47
+ // next token is paragraph close
48
+ if (i !== l - 1 && state.tokens[i + 1].type !== kTokParaClose) {
49
+ continue;
50
+ }
51
+ // The image
52
+ var image = token.children.length === 1 ? token.children[0] : token.children[1];
53
+ // The image must have a caption to count as a figure
54
+ if (!image.children || image.children.length === 0) {
55
+ continue;
56
+ }
57
+ // We have inline token containing an image only.
58
+ // Previous token is paragraph open.
59
+ // Next token is paragraph close.
60
+ // Lets replace the paragraph tokens with figure tokens.
61
+ var figure = state.tokens[i - 1];
62
+ mutateToFigureTok(figure, "open");
63
+ mutateToFigureTok(state.tokens[i + 1], "close");
64
+ if (options.dataType == true) {
65
+ state.tokens[i - 1].attrPush(["data-type", "image"]);
66
+ }
67
+ if (options.link == true && token.children.length === 1) {
68
+ token.children.unshift(new state.Token("link_open", "a", 1));
69
+ const src = image.attrGet("src");
70
+ if (src !== null) {
71
+ token.children[0].attrPush(["href", src]);
72
+ }
73
+ token.children.push(new state.Token("link_close", "a", -1));
74
+ }
75
+ if (options.figcaption == true) {
76
+ if (image.children && image.children.length) {
77
+ token.children.push(new state.Token(kTokFigCaptionOpen, "figcaption", 1));
78
+ token.children.splice(token.children.length, 0, ...image.children);
79
+ token.children.push(new state.Token(kTokFigCaptionClose, "figcaption", -1));
80
+ image.children.length = 0;
81
+ }
82
+ }
83
+ if (options.copyAttrs && image.attrs) {
84
+ const f = options.copyAttrs === true ? "" : options.copyAttrs;
85
+ figure.attrs = image.attrs.filter(([k, v]) => k.match(f));
86
+ }
87
+ if (options.tabindex == true) {
88
+ // add a tabindex property
89
+ // you could use this with css-tricks.com/expanding-images-html5
90
+ state.tokens[i - 1].attrPush(["tabindex", String(tabIndex)]);
91
+ tabIndex++;
92
+ }
93
+ if (options.lazyLoading == true) {
94
+ image.attrPush(["loading", "lazy"]);
95
+ }
96
+ }
97
+ });
98
+ }
@@ -0,0 +1 @@
1
+ {"version":3,"file":"figures.js","sourceRoot":"","sources":["../../src/plugins/figures.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH,OAAO,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAW3D,MAAM,CAAC,MAAM,cAAc,GAAG,aAAa,CAAC;AAC5C,MAAM,CAAC,MAAM,eAAe,GAAG,cAAc,CAAC;AAE9C,MAAM,CAAC,MAAM,kBAAkB,GAAG,iBAAiB,CAAC;AACpD,MAAM,CAAC,MAAM,mBAAmB,GAAG,kBAAkB,CAAC;AAEtD,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC,KAAY,EAAE,IAAsB,EAAE,EAAE;IACxE,KAAK,CAAC,IAAI,GAAG,IAAI,KAAK,MAAM,CAAC,CAAC,CAAC,cAAc,CAAC,CAAC,CAAC,eAAe,CAAC;IAChE,KAAK,CAAC,GAAG,GAAG,QAAQ,CAAC;AACvB,CAAC,CAAA;AAED,MAAM,UAAU,aAAa,CAAC,EAAc,EAAE,OAAsB;IAClE,OAAO,GAAG,OAAO,IAAI,EAAE,CAAC;IAExB,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,SAAS,EAAE,kBAAkB,EAAE,CAAC,KAAK,EAAE,EAAE;QAC5D,gCAAgC;QAChC,IAAI,QAAQ,GAAG,CAAC,CAAC;QAEjB,sCAAsC;QACtC,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,EAAE,CAAC,EAAE;YACvD,IAAI,KAAK,GAAG,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;YAE5B,IAAI,KAAK,CAA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C,CAAC;AACL,CAAC"}
@@ -0,0 +1,8 @@
1
+ /**
2
+ * getCells parses the lines found for a certain row, and transforms these to
3
+ * the separate cell lines.
4
+ *
5
+ * @param lines The lines for the row.
6
+ */
7
+ export default function getCells(lines: string[][]): string[][];
8
+ //# sourceMappingURL=GetCells.d.ts.map
@@ -0,0 +1,44 @@
1
+ /*---------------------------------------------------------------------------------------------
2
+ * Copyright (c) Bas Verweij. All rights reserved.
3
+ * Licensed under the MIT License. See LICENSE in the project root for license information.
4
+ *--------------------------------------------------------------------------------------------*/
5
+ /**
6
+ * getCells parses the lines found for a certain row, and transforms these to
7
+ * the separate cell lines.
8
+ *
9
+ * @param lines The lines for the row.
10
+ */
11
+ export default function getCells(lines) {
12
+ const cells = [];
13
+ for (let i = 0; i < lines[0].length; i++) {
14
+ let cell = [];
15
+ for (let j = 0; j < lines.length; j++) {
16
+ const s = trimEnd(lines[j][i]);
17
+ if ((s.length === 0) &&
18
+ (cell.length === 0)) {
19
+ // skip leading empty lines
20
+ continue;
21
+ }
22
+ cell.push(s);
23
+ }
24
+ // remove trailing empty lines
25
+ let j = cell.length - 1;
26
+ for (; j >= 0; j--) {
27
+ if (cell[j].length > 0) {
28
+ break;
29
+ }
30
+ }
31
+ if (j < cell.length - 1) {
32
+ cell = cell.slice(0, j + 1);
33
+ }
34
+ cells.push(cell);
35
+ }
36
+ return cells;
37
+ }
38
+ function trimEnd(s) {
39
+ const trimmed = s.trim();
40
+ if (trimmed.length === 0) {
41
+ return '';
42
+ }
43
+ return s.slice(0, s.indexOf(trimmed) + trimmed.length);
44
+ }
@@ -0,0 +1 @@
1
+ {"version":3,"file":"GetCells.js","sourceRoot":"","sources":["../../../../../src/plugins/gridtables/common/gridtables/GetCells.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAEhG;;;;;EAKE;AACF,MAAM,CAAC,OAAO,UAAU,QAAQ,CAC5B,KAAiB;IAGjB,MAAM,KAAK,GAAG,EAAE,CAAC;IAEjB,KAAK,IAA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AM,CAAC,CAAC;AAC7C,CAAC"}
@@ -0,0 +1,8 @@
1
+ /**
2
+ * getColumnWidths parses the provided line and returns the associated column widths.
3
+ *
4
+ * @param line The separator line to parse for the column widths.
5
+ * @returns The column widths for the provided line, or an empty array if the line is invalid.
6
+ */
7
+ export default function getColumnWidths(line: string): number[];
8
+ //# sourceMappingURL=GetColumnWidths.d.ts.map
@@ -0,0 +1,26 @@
1
+ /*---------------------------------------------------------------------------------------------
2
+ * Copyright (c) Bas Verweij. All rights reserved.
3
+ * Licensed under the MIT License. See LICENSE in the project root for license information.
4
+ *--------------------------------------------------------------------------------------------*/
5
+ /**
6
+ * getColumnWidths parses the provided line and returns the associated column widths.
7
+ *
8
+ * @param line The separator line to parse for the column widths.
9
+ * @returns The column widths for the provided line, or an empty array if the line is invalid.
10
+ */
11
+ export default function getColumnWidths(line) {
12
+ // try to parse as a row separator line
13
+ let columnMatch = line
14
+ .substr(1)
15
+ .match(/[:-][-]+[:-]\+/g);
16
+ if (columnMatch == null) {
17
+ // try to parse as a header separator line
18
+ columnMatch = line
19
+ .substr(1)
20
+ .match(/[:=][=]+[:=]\+/g);
21
+ }
22
+ if (columnMatch == null) {
23
+ return [];
24
+ }
25
+ return columnMatch.map(s => s.length);
26
+ }
@@ -0,0 +1 @@
1
+ {"version":3,"file":"GetColumnWidths.js","sourceRoot":"","sources":["../../../../../src/plugins/gridtables/common/gridtables/GetColumnWidths.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAEhG;;;;;EAKE;AACF,MAAM,CAAC,OAAO,UAAU,eAAe,CACnC,IAAY;IAGZ,uCAAuC;IACvC,IAAI,WAAW,GAAG,IAAI;SACjB,MAAM,CAAC,CAAC,CAAC;SACT,KAAK,CAAC,iBAAiB,CAAC,CAAC;IAE9B,IAAI,WAAW,IAAI,IAAI,EACvB;QACI,0CAA0C;QAC1C,WAAW,GAAG,IAAI;aACb,MAAM,CAAC,CAAC,CAAC;aACT,KAAK,CAAC,iBAAiB,CAAC,CAAC;KACjC;IAED,IAAI,WAAW,IAAI,IAAI,EACvB;QACI,OAAO,EAAE,CAAC;KACb;IAED,OAAO,WAAW,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC;AAC1C,CAAC"}
@@ -0,0 +1,8 @@
1
+ declare enum ColumnAlignments {
2
+ None = "",
3
+ Left = "left",
4
+ Center = "center",
5
+ Right = "right"
6
+ }
7
+ export default ColumnAlignments;
8
+ //# sourceMappingURL=ColumnAlignments.d.ts.map