@quarto/jupyterlab-quarto 0.2.7 → 0.2.9

Sign up to get free protection for your applications and to get access to all the features.
@@ -147,6 +147,16 @@ function renderFrontMatter(tokens, idx) {
147
147
  }
148
148
  };
149
149
  // Read simple values
150
+ const eatKeys = [
151
+ 'title',
152
+ 'subtitle',
153
+ 'abstract',
154
+ 'date',
155
+ 'date-modified',
156
+ 'doi',
157
+ 'author',
158
+ 'authors'
159
+ ];
150
160
  titleBlock.title = readStr('title');
151
161
  titleBlock.subtitle = readStr('subtitle');
152
162
  titleBlock.abstract = readStr('abstract');
@@ -166,9 +176,29 @@ function renderFrontMatter(tokens, idx) {
166
176
  // decorator
167
177
  const decor = decorator(['Options']);
168
178
  titleLines.push(decor);
169
- // yaml
170
- const yamlDump = yaml.dump(frontMatter);
171
- const otherYamlRendered = `<pre class="quarto-frontmatter-container"><code class="cm-s-jupyter language-yaml quarto-frontmatter">${yamlDump}</code></pre>`;
179
+ // Left over YAML
180
+ // Use the raw YAML string so we don't end up mutating / round tripping the YAML
181
+ let eating = false;
182
+ const outputYaml = [];
183
+ const yamlNoDelimiters = token.markup
184
+ .replace(/---\s*$/, '')
185
+ .replace(/^---\s*/, '');
186
+ for (const line of yamlNoDelimiters.split('\n')) {
187
+ const eatKey = eatKeys.some(k => {
188
+ const match = line.match(RegExp(`^${k}\\s*:`));
189
+ return match !== null;
190
+ });
191
+ if (eatKey) {
192
+ eating = true;
193
+ }
194
+ else {
195
+ if (!eating || line.match(/^\S/)) {
196
+ eating = false;
197
+ outputYaml.push(line);
198
+ }
199
+ }
200
+ }
201
+ const otherYamlRendered = `<pre class="quarto-frontmatter-container"><code class="cm-s-jupyter language-yaml quarto-frontmatter">${outputYaml.join('\n')}</code></pre>`;
172
202
  titleLines.push(otherYamlRendered);
173
203
  }
174
204
  return titleLines.join('\n');
@@ -61,16 +61,22 @@ MathJax = {
61
61
  });
62
62
 
63
63
  const markdownNodes = nodes.filter((node) => {
64
- return node.class.contains("jp-MarkdownCell");
64
+ return node.classList.contains("jp-MarkdownCell");
65
65
  }).forEach((node) => {
66
66
  typesetCellObserver.observe(node, { childList: true, subtree: true });
67
67
  });
68
68
 
69
69
  });
70
70
 
71
- const nbContainer = document.querySelector('.jp-Notebook');
72
- if (nbContainer !== null) {
73
- containerObserver.observe(nbContainer, { childList: true });
71
+ const cellEl = document.querySelector('.jp-Cell');
72
+ if (cellEl !== null) {
73
+ const cellParentEl = cellEl.parentElement;
74
+ containerObserver.observe(cellParentEl, { childList: true });
75
+ } else {
76
+ const nbContainer = document.querySelector('.jp-Notebook');
77
+ if (nbContainer !== null) {
78
+ containerObserver.observe(nbContainer, { childList: true, subtree: true });
79
+ }
74
80
  }
75
81
 
76
82
  const mathEls = document.body.querySelectorAll('.quarto-inline-math, .quarto-display-math');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
- "version": "0.2.7",
3
2
  "name": "@quarto/jupyterlab-quarto",
3
+ "version": "0.2.9",
4
4
  "description": "Jupyter extension to enable authoring of Quarto documents within Jupyterlab Notebooks.",
5
5
  "keywords": [
6
6
  "jupyter",