@quarto/jupyterlab-quarto 0.1.45 → 0.2.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (188) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +45 -12
  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 +1 -2
  6. package/lib/ast/ast.js +4 -3
  7. package/lib/const.d.ts +1 -2
  8. package/lib/const.js +5 -6
  9. package/lib/hooks/codemirror.d.ts +5 -4
  10. package/lib/hooks/codemirror.js +37 -12
  11. package/lib/index.d.ts +2 -3
  12. package/lib/index.js +6 -5
  13. package/lib/manager.d.ts +2 -2
  14. package/lib/manager.js +14 -16
  15. package/lib/plugins/callouts.d.ts +1 -2
  16. package/lib/plugins/callouts.js +59 -58
  17. package/lib/plugins/cites.d.ts +1 -2
  18. package/lib/plugins/cites.js +41 -23
  19. package/lib/plugins/decorator.d.ts +1 -2
  20. package/lib/plugins/decorator.js +11 -12
  21. package/lib/plugins/divs.d.ts +1 -2
  22. package/lib/plugins/divs.js +20 -9
  23. package/lib/plugins/figure-divs.d.ts +1 -2
  24. package/lib/plugins/figure-divs.js +18 -17
  25. package/lib/plugins/figures.d.ts +3 -4
  26. package/lib/plugins/figures.js +30 -31
  27. package/lib/plugins/gridtables/common/gridtables/GetCells.d.ts +5 -6
  28. package/lib/plugins/gridtables/common/gridtables/GetCells.js +6 -8
  29. package/lib/plugins/gridtables/common/gridtables/GetColumnWidths.d.ts +5 -6
  30. package/lib/plugins/gridtables/common/gridtables/GetColumnWidths.js +9 -14
  31. package/lib/plugins/gridtables/common/markdown-it/ColumnAlignments.d.ts +0 -1
  32. package/lib/plugins/gridtables/common/markdown-it/ColumnAlignments.js +0 -1
  33. package/lib/plugins/gridtables/common/markdown-it/EmitTable.d.ts +3 -4
  34. package/lib/plugins/gridtables/common/markdown-it/EmitTable.js +12 -15
  35. package/lib/plugins/gridtables/common/markdown-it/GetCharCodeAtStartOfLine.d.ts +1 -2
  36. package/lib/plugins/gridtables/common/markdown-it/GetCharCodeAtStartOfLine.js +1 -3
  37. package/lib/plugins/gridtables/common/markdown-it/GetLine.d.ts +1 -2
  38. package/lib/plugins/gridtables/common/markdown-it/GetLine.js +0 -1
  39. package/lib/plugins/gridtables/common/markdown-it/ParseTable.d.ts +2 -3
  40. package/lib/plugins/gridtables/common/markdown-it/ParseTable.js +18 -28
  41. package/lib/plugins/gridtables/common/markdown-it/ParseTableResult.d.ts +1 -2
  42. package/lib/plugins/gridtables/common/markdown-it/ParseTableResult.js +0 -1
  43. package/lib/plugins/gridtables/index.d.ts +0 -1
  44. package/lib/plugins/gridtables/index.js +2 -3
  45. package/lib/plugins/gridtables/interfaces/markdown-it/IState.d.ts +1 -2
  46. package/lib/plugins/gridtables/interfaces/markdown-it/IState.js +0 -1
  47. package/lib/plugins/gridtables/interfaces/markdown-it/IToken.d.ts +0 -1
  48. package/lib/plugins/gridtables/interfaces/markdown-it/IToken.js +0 -1
  49. package/lib/plugins/gridtables/interfaces/markdown-it/TRuleFunction.d.ts +1 -2
  50. package/lib/plugins/gridtables/interfaces/markdown-it/TRuleFunction.js +0 -1
  51. package/lib/plugins/gridtables/rules/gridtable.d.ts +2 -3
  52. package/lib/plugins/gridtables/rules/gridtable.js +5 -6
  53. package/lib/plugins/index.d.ts +15 -0
  54. package/lib/plugins/index.js +21 -0
  55. package/lib/plugins/math.d.ts +4 -3
  56. package/lib/plugins/math.js +33 -31
  57. package/lib/plugins/mermaid/index.d.ts +1 -2
  58. package/lib/plugins/mermaid/index.js +19 -14
  59. package/lib/plugins/shortcodes.d.ts +1 -2
  60. package/lib/plugins/shortcodes.js +6 -7
  61. package/lib/plugins/spans.d.ts +1 -2
  62. package/lib/plugins/spans.js +2 -4
  63. package/lib/plugins/table-captions.d.ts +1 -2
  64. package/lib/plugins/table-captions.js +19 -16
  65. package/lib/plugins/utils/html.d.ts +1 -2
  66. package/lib/plugins/utils/html.js +19 -15
  67. package/lib/plugins/utils/markdownit.d.ts +0 -1
  68. package/lib/plugins/utils/markdownit.js +14 -13
  69. package/lib/plugins/utils/tok.d.ts +0 -1
  70. package/lib/plugins/utils/tok.js +12 -13
  71. package/lib/plugins/yaml.d.ts +1 -2
  72. package/lib/plugins/yaml.js +59 -49
  73. package/lib/providers/attrs.d.ts +1 -2
  74. package/lib/providers/attrs.js +5 -6
  75. package/lib/providers/callouts.d.ts +1 -2
  76. package/lib/providers/callouts.js +7 -8
  77. package/lib/providers/cites.d.ts +1 -2
  78. package/lib/providers/cites.js +7 -8
  79. package/lib/providers/decorator.d.ts +1 -2
  80. package/lib/providers/decorator.js +7 -8
  81. package/lib/providers/deflist.d.ts +1 -2
  82. package/lib/providers/deflist.js +5 -6
  83. package/lib/providers/divs.d.ts +1 -2
  84. package/lib/providers/divs.js +9 -10
  85. package/lib/providers/figure-divs.d.ts +1 -2
  86. package/lib/providers/figure-divs.js +5 -6
  87. package/lib/providers/figures.d.ts +1 -2
  88. package/lib/providers/figures.js +5 -6
  89. package/lib/providers/footnotes.d.ts +1 -2
  90. package/lib/providers/footnotes.js +5 -6
  91. package/lib/providers/gridtables.d.ts +1 -2
  92. package/lib/providers/gridtables.js +5 -6
  93. package/lib/providers/math.d.ts +1 -2
  94. package/lib/providers/math.js +12 -13
  95. package/lib/providers/mermaid.d.ts +1 -2
  96. package/lib/providers/mermaid.js +10 -9
  97. package/lib/providers/provider.d.ts +1 -2
  98. package/lib/providers/provider.js +0 -1
  99. package/lib/providers/shortcodes.d.ts +1 -2
  100. package/lib/providers/shortcodes.js +5 -6
  101. package/lib/providers/spans.d.ts +1 -2
  102. package/lib/providers/spans.js +8 -9
  103. package/lib/providers/sub.d.ts +1 -2
  104. package/lib/providers/sub.js +5 -6
  105. package/lib/providers/sup.d.ts +1 -2
  106. package/lib/providers/sup.js +5 -6
  107. package/lib/providers/table-captions.d.ts +1 -2
  108. package/lib/providers/table-captions.js +5 -6
  109. package/lib/providers/tasklists.d.ts +1 -2
  110. package/lib/providers/tasklists.js +5 -6
  111. package/lib/providers/yaml.d.ts +1 -2
  112. package/lib/providers/yaml.js +7 -8
  113. package/lib/types.d.ts +0 -1
  114. package/lib/types.js +0 -1
  115. package/lib/widgets.d.ts +0 -1
  116. package/lib/widgets.js +5 -6
  117. package/package.json +103 -37
  118. package/style/base.css +34 -33
  119. package/style/index.css +1 -1
  120. package/lib/__tests__/index.spec.d.ts +0 -6
  121. package/lib/__tests__/index.spec.js +0 -61
  122. package/lib/__tests__/index.spec.js.map +0 -1
  123. package/lib/__tests__/myextension.spec.d.ts +0 -6
  124. package/lib/__tests__/myextension.spec.js +0 -11
  125. package/lib/__tests__/myextension.spec.js.map +0 -1
  126. package/lib/ast/ast.js.map +0 -1
  127. package/lib/const.js.map +0 -1
  128. package/lib/hooks/codemirror.js.map +0 -1
  129. package/lib/index.js.map +0 -1
  130. package/lib/manager.js.map +0 -1
  131. package/lib/plugins/callouts.js.map +0 -1
  132. package/lib/plugins/cites.js.map +0 -1
  133. package/lib/plugins/decorator.js.map +0 -1
  134. package/lib/plugins/divs.js.map +0 -1
  135. package/lib/plugins/figure-divs.js.map +0 -1
  136. package/lib/plugins/figures.js.map +0 -1
  137. package/lib/plugins/gridtables/common/gridtables/GetCells.js.map +0 -1
  138. package/lib/plugins/gridtables/common/gridtables/GetColumnWidths.js.map +0 -1
  139. package/lib/plugins/gridtables/common/markdown-it/ColumnAlignments.js.map +0 -1
  140. package/lib/plugins/gridtables/common/markdown-it/EmitTable.js.map +0 -1
  141. package/lib/plugins/gridtables/common/markdown-it/GetCharCodeAtStartOfLine.js.map +0 -1
  142. package/lib/plugins/gridtables/common/markdown-it/GetLine.js.map +0 -1
  143. package/lib/plugins/gridtables/common/markdown-it/ParseTable.js.map +0 -1
  144. package/lib/plugins/gridtables/common/markdown-it/ParseTableResult.js.map +0 -1
  145. package/lib/plugins/gridtables/index.js.map +0 -1
  146. package/lib/plugins/gridtables/interfaces/markdown-it/IState.js.map +0 -1
  147. package/lib/plugins/gridtables/interfaces/markdown-it/IToken.js.map +0 -1
  148. package/lib/plugins/gridtables/interfaces/markdown-it/TRuleFunction.js.map +0 -1
  149. package/lib/plugins/gridtables/rules/gridtable.js.map +0 -1
  150. package/lib/plugins/math.js.map +0 -1
  151. package/lib/plugins/mermaid/index.js.map +0 -1
  152. package/lib/plugins/shortcodes.js.map +0 -1
  153. package/lib/plugins/spans.js.map +0 -1
  154. package/lib/plugins/table-captions.js.map +0 -1
  155. package/lib/plugins/utils/html.js.map +0 -1
  156. package/lib/plugins/utils/markdownit.js.map +0 -1
  157. package/lib/plugins/utils/tok.js.map +0 -1
  158. package/lib/plugins/yaml.js.map +0 -1
  159. package/lib/providers/attrs.js.map +0 -1
  160. package/lib/providers/callouts.js.map +0 -1
  161. package/lib/providers/cites.js.map +0 -1
  162. package/lib/providers/decorator.js.map +0 -1
  163. package/lib/providers/deflist.js.map +0 -1
  164. package/lib/providers/divs.js.map +0 -1
  165. package/lib/providers/figure-divs.js.map +0 -1
  166. package/lib/providers/figures.js.map +0 -1
  167. package/lib/providers/footnotes.js.map +0 -1
  168. package/lib/providers/gridtables.js.map +0 -1
  169. package/lib/providers/math.js.map +0 -1
  170. package/lib/providers/mermaid.js.map +0 -1
  171. package/lib/providers/provider.js.map +0 -1
  172. package/lib/providers/shortcodes.js.map +0 -1
  173. package/lib/providers/spans.js.map +0 -1
  174. package/lib/providers/sub.js.map +0 -1
  175. package/lib/providers/sup.js.map +0 -1
  176. package/lib/providers/table-captions.js.map +0 -1
  177. package/lib/providers/tasklists.js.map +0 -1
  178. package/lib/providers/yaml.js.map +0 -1
  179. package/lib/types.js.map +0 -1
  180. package/lib/widgets.js.map +0 -1
  181. package/schema/plugin.json +0 -8
  182. package/src/@types/markdown-it-deflist.d.ts +0 -10
  183. package/src/@types/markdown-it-footnote.d.ts +0 -10
  184. package/src/@types/markdown-it-gridtables.d.ts +0 -10
  185. package/src/@types/markdown-it-implicit-figures.d.ts +0 -10
  186. package/src/@types/markdown-it-sub.d.ts +0 -10
  187. package/src/@types/markdown-it-sup.d.ts +0 -10
  188. package/src/@types/markdown-it-task-lists.d.ts +0 -10
@@ -1,13 +1,13 @@
1
1
  /*
2
- * citation.ts
3
- *
4
- * Copyright (C) 2020-2023 Posit Software, PBC
5
- *
6
- */
7
- const kTokCite = "quarto_cite";
2
+ * citation.ts
3
+ *
4
+ * Copyright (C) 2020-2023 Posit Software, PBC
5
+ *
6
+ */
7
+ const kTokCite = 'quarto_cite';
8
8
  export const citationPlugin = (md) => {
9
9
  // Very simple plugin example that surrounds @text with `code`
10
- md.core.ruler.push('quarto-citation', function replaceAtSymbol(state) {
10
+ md.core.ruler.push('quarto-citation', state => {
11
11
  const tokens = state.tokens;
12
12
  for (const token of tokens) {
13
13
  if (token.type === 'inline' && token.children) {
@@ -19,7 +19,7 @@ export const citationPlugin = (md) => {
19
19
  const content = child.content;
20
20
  const textToken = (text) => {
21
21
  const newToken = new state.Token('text', '', 0);
22
- newToken.content = text.join("");
22
+ newToken.content = text.join('');
23
23
  return newToken;
24
24
  };
25
25
  let text = [];
@@ -34,24 +34,39 @@ export const citationPlugin = (md) => {
34
34
  var _a;
35
35
  if (cite.length) {
36
36
  // Determine the cite style
37
- let style = cite[0] === "-" ? "suppress-author" : "in-text";
37
+ let style = cite[0] === '-' ? 'suppress-author' : 'in-text';
38
38
  if (bracketCount > 0) {
39
- style = "normal";
39
+ style = 'normal';
40
40
  }
41
41
  // The classes
42
- const clz = ["cite", style];
42
+ const clz = ['cite', style];
43
43
  // If the cite ends in punctuation, trim that off and make that text
44
44
  const puncText = [];
45
45
  // Trim off ending punctuation
46
- if ([":", ".", "#", "$", "%", "&", "-", "+", "?", "<", ">", "~", "/", "!"].includes(cite[cite.length - 1])) {
46
+ if ([
47
+ ':',
48
+ '.',
49
+ '#',
50
+ '$',
51
+ '%',
52
+ '&',
53
+ '-',
54
+ '+',
55
+ '?',
56
+ '<',
57
+ '>',
58
+ '~',
59
+ '/',
60
+ '!'
61
+ ].includes(cite[cite.length - 1])) {
47
62
  puncText.push(cite[cite.length - 1]);
48
63
  cite = cite.slice(0, -1);
49
64
  }
50
65
  // Make a cite token
51
66
  const newToken = new state.Token(kTokCite, '', 0);
52
- newToken.content = cite.join("");
67
+ newToken.content = cite.join('');
53
68
  newToken.attrs = newToken.attrs || [];
54
- (_a = newToken.attrs) === null || _a === void 0 ? void 0 : _a.push(["class", clz.join(" ")]);
69
+ (_a = newToken.attrs) === null || _a === void 0 ? void 0 : _a.push(['class', clz.join(' ')]);
55
70
  children.push(newToken);
56
71
  cite = [];
57
72
  if (puncText.length > 0) {
@@ -59,13 +74,15 @@ export const citationPlugin = (md) => {
59
74
  }
60
75
  }
61
76
  };
62
- let capture = "text";
77
+ let capture = 'text';
63
78
  let bracketCount = 0;
64
79
  for (let j = 0; j < content.length; j++) {
65
80
  const char = content.charAt(j);
66
- if (char === "@") {
81
+ if (char === '@') {
67
82
  if ((text.length === 1 && text[0] === '-') ||
68
- text.length > 1 && text[text.length - 1] === "-" && text[text.length - 2] === "[") {
83
+ (text.length > 1 &&
84
+ text[text.length - 1] === '-' &&
85
+ text[text.length - 2] === '[')) {
69
86
  cite.push('-');
70
87
  cite.push(char);
71
88
  text.pop();
@@ -77,14 +94,16 @@ export const citationPlugin = (md) => {
77
94
  cite.push(char);
78
95
  capture = 'cite';
79
96
  }
80
- else if (text[text.length - 1] === '-' && text[text.length - 2] === ' ') {
97
+ else if (text[text.length - 1] === '-' &&
98
+ text[text.length - 2] === ' ') {
81
99
  text = text.slice(0, -1);
82
100
  flushText();
83
101
  cite.push('-');
84
102
  cite.push(char);
85
103
  capture = 'cite';
86
104
  }
87
- else if (text[text.length - 1] === '[' && text[text.length - 2] === ' ') {
105
+ else if (text[text.length - 1] === '[' &&
106
+ text[text.length - 2] === ' ') {
88
107
  flushText();
89
108
  cite.push(char);
90
109
  capture = 'cite';
@@ -102,16 +121,16 @@ export const citationPlugin = (md) => {
102
121
  }
103
122
  }
104
123
  }
105
- else if (char === " ") {
124
+ else if (char === ' ') {
106
125
  capture = 'text';
107
126
  flushCite();
108
127
  text.push(char);
109
128
  }
110
- else if (char === "[") {
129
+ else if (char === '[') {
111
130
  bracketCount++;
112
131
  text.push(char);
113
132
  }
114
- else if (char === "]") {
133
+ else if (char === ']') {
115
134
  bracketCount--;
116
135
  capture = 'text';
117
136
  flushCite();
@@ -145,4 +164,3 @@ function renderCite(tokens, idx, _options, _env, self) {
145
164
  const citeContent = `<code ${self.renderAttrs(token)}>${token.content}</code>`;
146
165
  return citeContent;
147
166
  }
148
- //# sourceMappingURL=cites.js.map
@@ -1,3 +1,2 @@
1
- import type MarkdownIt from "markdown-it/lib";
1
+ import type MarkdownIt from 'markdown-it/lib';
2
2
  export declare const decoratorPlugin: (md: MarkdownIt) => void;
3
- //# sourceMappingURL=decorator.d.ts.map
@@ -1,16 +1,16 @@
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";
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
9
  export const decoratorPlugin = (md) => {
10
- md.core.ruler.push('quarto-decorator', function replaceAtSymbol(state) {
10
+ md.core.ruler.push('quarto-decorator', state => {
11
11
  const outTokens = [];
12
12
  for (const token of state.tokens) {
13
- if (token.type === "fence" && !token.attrs && token.info) {
13
+ if (token.type === 'fence' && !token.attrs && token.info) {
14
14
  outTokens.push(decoratorTokForToken(token));
15
15
  }
16
16
  else if (token.type === kTokHeadingOpen && token.attrs) {
@@ -35,7 +35,7 @@ export const decoratorPlugin = (md) => {
35
35
  md.renderer.rules[kTokDecorator] = renderDecorator;
36
36
  };
37
37
  function decoratorTokForToken(token, options) {
38
- const decoratorTok = new Token(kTokDecorator, "div", 1);
38
+ const decoratorTok = new Token(kTokDecorator, 'div', 1);
39
39
  decoratorTok.attrs = token.attrs;
40
40
  decoratorTok.info = token.info;
41
41
  if (options) {
@@ -56,4 +56,3 @@ function renderDecorator(tokens, idx) {
56
56
  return attributeDecorator(token, decoratorOptions);
57
57
  }
58
58
  }
59
- //# sourceMappingURL=decorator.js.map
@@ -1,6 +1,5 @@
1
- import type MarkdownIt from "markdown-it/lib";
1
+ import type MarkdownIt from 'markdown-it/lib';
2
2
  export declare const kDivRuleName = "pandocDiv";
3
3
  export declare const kTokDivOpen = "pandoc_div_open";
4
4
  export declare const kTokDivClose = "pandoc_div_close";
5
5
  export declare const divPlugin: (md: MarkdownIt) => void;
6
- //# sourceMappingURL=divs.d.ts.map
@@ -1,5 +1,5 @@
1
- import { addClass } from "./utils/markdownit";
2
- export const kDivRuleName = "pandocDiv";
1
+ import { addClass } from './utils/markdownit';
2
+ export const kDivRuleName = 'pandocDiv';
3
3
  export const kTokDivOpen = 'pandoc_div_open';
4
4
  export const kTokDivClose = 'pandoc_div_close';
5
5
  export const divPlugin = (md) => {
@@ -7,16 +7,16 @@ export const divPlugin = (md) => {
7
7
  function renderStartDiv(tokens, idx, _options, _env, self) {
8
8
  // Add a class to designate that this is a quarto dev
9
9
  const token = tokens[idx];
10
- token.attrs = addClass("quarto-div", token.attrs);
10
+ token.attrs = addClass('quarto-div', token.attrs);
11
11
  return `<div ${self.renderAttrs(token)}>`;
12
12
  }
13
13
  // Render pandoc-style divs
14
14
  function renderEndDiv() {
15
- return `</div>`;
15
+ return '</div>';
16
16
  }
17
17
  // TODO Implement a better test during validation run
18
18
  // Handle pandoc-style divs
19
- md.block.ruler.before("fence", kDivRuleName, (state, start, _end, silent) => {
19
+ md.block.ruler.before('fence', kDivRuleName, (state, start, _end, silent) => {
20
20
  // This is a validation run, can ignore
21
21
  if (silent) {
22
22
  return true;
@@ -29,11 +29,14 @@ export const divPlugin = (md) => {
29
29
  // div. Data structure holds key that is the number of colons
30
30
  const divState = state.env.quartoOpenDivs || {};
31
31
  const incrementDivCount = (fence) => {
32
+ var _a;
33
+ state.env.quartoDivLevel = ((_a = state.env.quartoDivLevel) !== null && _a !== void 0 ? _a : 0) + 1;
32
34
  state.env.quartoOpenDivs = state.env.quartoOpenDivs || {};
33
35
  const current = state.env.quartoOpenDivs[fence] || 0;
34
36
  state.env.quartoOpenDivs[fence] = Math.max(0, current + 1);
35
37
  };
36
38
  const decrementDivCount = (fence) => {
39
+ state.env.quartoDivLevel--;
37
40
  state.env.quartoOpenDivs = state.env.quartoOpenDivs || {};
38
41
  const current = state.env.quartoOpenDivs[fence] || 0;
39
42
  state.env.quartoOpenDivs[fence] = Math.max(0, current - 1);
@@ -69,23 +72,32 @@ export const divPlugin = (md) => {
69
72
  // Add to the open count (or set it to 1)
70
73
  incrementDivCount(divFence);
71
74
  // Make an open token
72
- const token = state.push(kTokDivOpen, "div", 1);
75
+ const token = state.push(kTokDivOpen, 'div', 1);
73
76
  token.markup = line;
74
77
  // Allow this to be parsed for attributes by markdown-it-attr
75
- if (attr && attr.startsWith("{")) {
78
+ if (attr && attr.startsWith('{')) {
76
79
  token.info = attr;
77
80
  }
78
81
  else if (attr) {
79
82
  token.info = `{.${attr}}`;
80
83
  }
81
84
  token.block = true;
85
+ token.meta = {
86
+ line: state.line,
87
+ level: state.env.quartoDivLevel
88
+ };
82
89
  }
83
90
  else {
84
91
  // Subtract from the open count (min zero)
92
+ const level = state.env.quartoDivLevel;
85
93
  decrementDivCount(divFence);
86
94
  // Make a close token
87
- const token = state.push(kTokDivClose, "div", -1);
95
+ const token = state.push(kTokDivClose, 'div', -1);
88
96
  token.markup = line;
97
+ token.meta = {
98
+ line: state.line,
99
+ level
100
+ };
89
101
  }
90
102
  state.line = start + 1;
91
103
  return true;
@@ -97,4 +109,3 @@ export const divPlugin = (md) => {
97
109
  md.renderer.rules[kTokDivOpen] = renderStartDiv;
98
110
  md.renderer.rules[kTokDivClose] = renderEndDiv;
99
111
  };
100
- //# sourceMappingURL=divs.js.map
@@ -1,3 +1,2 @@
1
- import MarkdownIt from "markdown-it";
1
+ import MarkdownIt from 'markdown-it';
2
2
  export declare const figureDivsPlugin: (md: MarkdownIt) => void;
3
- //# sourceMappingURL=figure-divs.d.ts.map
@@ -4,23 +4,23 @@
4
4
  * Copyright (C) 2020-2023 Posit Software, PBC
5
5
  *
6
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-";
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
13
  export const figureDivsPlugin = (md) => {
14
14
  // Handle pandoc-style divs
15
- md.core.ruler.push(kFigureDivRuleName, (state) => {
16
- let isFigureDiv = [];
15
+ md.core.ruler.push(kFigureDivRuleName, state => {
16
+ const isFigureDiv = [];
17
17
  for (let i = 0; i < state.tokens.length; i++) {
18
18
  const token = state.tokens[i];
19
19
  if (token.type === kTokDivOpen) {
20
- const id = readAttrValue("id", token.attrs);
20
+ const id = readAttrValue('id', token.attrs);
21
21
  if (id === null || id === void 0 ? void 0 : id.startsWith(kFigurePrefix)) {
22
22
  isFigureDiv.push(true);
23
- mutateToFigureTok(token, "open");
23
+ mutateToFigureTok(token, 'open');
24
24
  }
25
25
  else {
26
26
  // Note the div, but not a figure div
@@ -35,19 +35,20 @@ export const figureDivsPlugin = (md) => {
35
35
  const maybeParaStart = state.tokens[i - 3];
36
36
  const maybeInline = state.tokens[i - 2];
37
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");
38
+ if (maybeParaStart.type === kTokParaOpen &&
39
+ maybeParaEnd.type === kTokParaClose &&
40
+ maybeInline.type === kTokInline) {
41
+ mutateToFigCaption(state.tokens[i - 3], 'open');
42
+ mutateToFigCaption(state.tokens[i - 1], 'close');
41
43
  }
42
44
  }
43
- mutateToFigureTok(token, "close");
45
+ mutateToFigureTok(token, 'close');
44
46
  }
45
47
  }
46
48
  }
47
49
  });
48
50
  };
49
51
  const mutateToFigCaption = (token, type) => {
50
- token.tag = "figcaption";
51
- token.type = type === "open" ? kTokFigCaptionClose : kTokFigCaptionOpen;
52
+ token.tag = 'figcaption';
53
+ token.type = type === 'open' ? kTokFigCaptionClose : kTokFigCaptionOpen;
52
54
  };
53
- //# sourceMappingURL=figure-divs.js.map
@@ -1,5 +1,5 @@
1
- import MarkdownIt from "markdown-it";
2
- import Token from "markdown-it/lib/token";
1
+ import MarkdownIt from 'markdown-it';
2
+ import Token from 'markdown-it/lib/token';
3
3
  export interface FigureOptions {
4
4
  dataType?: boolean;
5
5
  link?: boolean;
@@ -12,6 +12,5 @@ export declare const kTokFigureOpen = "figure_open";
12
12
  export declare const kTokFigureClose = "figure_close";
13
13
  export declare const kTokFigCaptionOpen = "figcaption_open";
14
14
  export declare const kTokFigCaptionClose = "figcaption_close";
15
- export declare const mutateToFigureTok: (token: Token, type: "open" | "close") => void;
15
+ export declare const mutateToFigureTok: (token: Token, type: 'open' | 'close') => void;
16
16
  export declare function figuresPlugin(md: MarkdownIt, options: FigureOptions): void;
17
- //# sourceMappingURL=figures.d.ts.map
@@ -4,24 +4,24 @@
4
4
  * Copyright (C) 2020-2023 Posit Software, PBC
5
5
  *
6
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";
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
12
  export const mutateToFigureTok = (token, type) => {
13
- token.type = type === "open" ? kTokFigureOpen : kTokFigureClose;
14
- token.tag = "figure";
13
+ token.type = type === 'open' ? kTokFigureOpen : kTokFigureClose;
14
+ token.tag = 'figure';
15
15
  };
16
16
  export function figuresPlugin(md, options) {
17
17
  options = options || {};
18
- md.core.ruler.before("linkify", "implicit_figures", (state) => {
18
+ md.core.ruler.before('linkify', 'implicit_figures', state => {
19
19
  // reset tabIndex on md.render()
20
20
  let tabIndex = 1;
21
21
  // do not process first and last token
22
22
  for (let i = 1, l = state.tokens.length; i < l - 1; ++i) {
23
23
  const token = state.tokens[i];
24
- if (token.type !== "inline") {
24
+ if (token.type !== 'inline') {
25
25
  continue;
26
26
  }
27
27
  // children: image alone, or link_open -> image -> link_close
@@ -30,14 +30,14 @@ export function figuresPlugin(md, options) {
30
30
  continue;
31
31
  }
32
32
  // one child, should be img
33
- if (token.children.length === 1 && token.children[0].type !== "image") {
33
+ if (token.children.length === 1 && token.children[0].type !== 'image') {
34
34
  continue;
35
35
  }
36
36
  // three children, should be image enclosed in link
37
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")) {
38
+ (token.children[0].type !== 'link_open' ||
39
+ token.children[1].type !== 'image' ||
40
+ token.children[2].type !== 'link_close')) {
41
41
  continue;
42
42
  }
43
43
  // prev token is paragraph open
@@ -59,41 +59,40 @@ export function figuresPlugin(md, options) {
59
59
  // Next token is paragraph close.
60
60
  // Lets replace the paragraph tokens with figure tokens.
61
61
  const 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"]);
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
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");
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
70
  if (src !== null) {
71
- token.children[0].attrPush(["href", src]);
71
+ token.children[0].attrPush(['href', src]);
72
72
  }
73
- token.children.push(new state.Token("link_close", "a", -1));
73
+ token.children.push(new state.Token('link_close', 'a', -1));
74
74
  }
75
- if (options.figcaption == true) {
75
+ if (options.figcaption === true) {
76
76
  if (image.children && image.children.length) {
77
- token.children.push(new state.Token(kTokFigCaptionOpen, "figcaption", 1));
77
+ token.children.push(new state.Token(kTokFigCaptionOpen, 'figcaption', 1));
78
78
  token.children.splice(token.children.length, 0, ...image.children);
79
- token.children.push(new state.Token(kTokFigCaptionClose, "figcaption", -1));
79
+ token.children.push(new state.Token(kTokFigCaptionClose, 'figcaption', -1));
80
80
  image.children.length = 0;
81
81
  }
82
82
  }
83
83
  if (options.copyAttrs && image.attrs) {
84
- const f = options.copyAttrs === true ? "" : options.copyAttrs;
84
+ const f = options.copyAttrs === true ? '' : options.copyAttrs;
85
85
  figure.attrs = image.attrs.filter(([k]) => k.match(f));
86
86
  }
87
- if (options.tabindex == true) {
87
+ if (options.tabindex === true) {
88
88
  // add a tabindex property
89
89
  // you could use this with css-tricks.com/expanding-images-html5
90
- state.tokens[i - 1].attrPush(["tabindex", String(tabIndex)]);
90
+ state.tokens[i - 1].attrPush(['tabindex', String(tabIndex)]);
91
91
  tabIndex++;
92
92
  }
93
- if (options.lazyLoading == true) {
94
- image.attrPush(["loading", "lazy"]);
93
+ if (options.lazyLoading === true) {
94
+ image.attrPush(['loading', 'lazy']);
95
95
  }
96
96
  }
97
97
  });
98
98
  }
99
- //# sourceMappingURL=figures.js.map
@@ -1,8 +1,7 @@
1
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
- */
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
7
  export default function getCells(lines: string[][]): string[][];
8
- //# sourceMappingURL=GetCells.d.ts.map
@@ -3,19 +3,18 @@
3
3
  * Licensed under the MIT License. See LICENSE in the project root for license information.
4
4
  *--------------------------------------------------------------------------------------------*/
5
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
- */
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
11
  export default function getCells(lines) {
12
12
  const cells = [];
13
13
  for (let i = 0; i < lines[0].length; i++) {
14
14
  let cell = [];
15
15
  for (let j = 0; j < lines.length; j++) {
16
16
  const s = trimEnd(lines[j][i]);
17
- if ((s.length === 0) &&
18
- (cell.length === 0)) {
17
+ if (s.length === 0 && cell.length === 0) {
19
18
  // skip leading empty lines
20
19
  continue;
21
20
  }
@@ -42,4 +41,3 @@ function trimEnd(s) {
42
41
  }
43
42
  return s.slice(0, s.indexOf(trimmed) + trimmed.length);
44
43
  }
45
- //# sourceMappingURL=GetCells.js.map
@@ -1,8 +1,7 @@
1
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
- */
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
7
  export default function getColumnWidths(line: string): number[];
8
- //# sourceMappingURL=GetColumnWidths.d.ts.map
@@ -3,25 +3,20 @@
3
3
  * Licensed under the MIT License. See LICENSE in the project root for license information.
4
4
  *--------------------------------------------------------------------------------------------*/
5
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
- */
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
11
  export default function getColumnWidths(line) {
12
12
  // try to parse as a row separator line
13
- let columnMatch = line
14
- .substr(1)
15
- .match(/[:-][-]+[:-]\+/g);
16
- if (columnMatch == null) {
13
+ let columnMatch = line.substr(1).match(/[:-][-]+[:-]\+/g);
14
+ if (columnMatch === null) {
17
15
  // try to parse as a header separator line
18
- columnMatch = line
19
- .substr(1)
20
- .match(/[:=][=]+[:=]\+/g);
16
+ columnMatch = line.substr(1).match(/[:=][=]+[:=]\+/g);
21
17
  }
22
- if (columnMatch == null) {
18
+ if (columnMatch === null) {
23
19
  return [];
24
20
  }
25
21
  return columnMatch.map(s => s.length);
26
22
  }
27
- //# sourceMappingURL=GetColumnWidths.js.map
@@ -5,4 +5,3 @@ declare enum ColumnAlignments {
5
5
  Right = "right"
6
6
  }
7
7
  export default ColumnAlignments;
8
- //# sourceMappingURL=ColumnAlignments.d.ts.map
@@ -10,4 +10,3 @@ var ColumnAlignments;
10
10
  ColumnAlignments["Right"] = "right";
11
11
  })(ColumnAlignments || (ColumnAlignments = {}));
12
12
  export default ColumnAlignments;
13
- //# sourceMappingURL=ColumnAlignments.js.map
@@ -1,5 +1,4 @@
1
- import * as MarkdownIt from "markdown-it";
2
- import IState from "../../interfaces/markdown-it/IState";
3
- import ParseTableResult from "./ParseTableResult";
1
+ import * as MarkdownIt from 'markdown-it';
2
+ import IState from '../../interfaces/markdown-it/IState';
3
+ import ParseTableResult from './ParseTableResult';
4
4
  export default function emitTable(md: MarkdownIt, state: IState, result: ParseTableResult): void;
5
- //# sourceMappingURL=EmitTable.d.ts.map