@quarto/jupyterlab-quarto 0.2.4 → 0.2.8
Sign up to get free protection for your applications and to get access to all the features.
- package/lib/plugins/yaml.js +22 -3
- package/package.json +1 -1
package/lib/plugins/yaml.js
CHANGED
@@ -147,6 +147,7 @@ function renderFrontMatter(tokens, idx) {
|
|
147
147
|
}
|
148
148
|
};
|
149
149
|
// Read simple values
|
150
|
+
const eatKeys = ['title', 'subtitle', 'abstract', 'date', 'date-modified', 'doi', 'author', 'authors'];
|
150
151
|
titleBlock.title = readStr('title');
|
151
152
|
titleBlock.subtitle = readStr('subtitle');
|
152
153
|
titleBlock.abstract = readStr('abstract');
|
@@ -166,9 +167,27 @@ function renderFrontMatter(tokens, idx) {
|
|
166
167
|
// decorator
|
167
168
|
const decor = decorator(['Options']);
|
168
169
|
titleLines.push(decor);
|
169
|
-
//
|
170
|
-
|
171
|
-
|
170
|
+
// Left over YAML
|
171
|
+
// Use the raw YAML string so we don't end up mutating / round tripping the YAML
|
172
|
+
let eating = false;
|
173
|
+
const outputYaml = [];
|
174
|
+
const yamlNoDelimiters = token.markup.replace(/---\s*$/, '').replace(/^---\s*/, '');
|
175
|
+
for (const line of yamlNoDelimiters.split("\n")) {
|
176
|
+
const eatKey = eatKeys.some((k) => {
|
177
|
+
const match = line.match(RegExp(`^${k}\\s*:`));
|
178
|
+
return match !== null;
|
179
|
+
});
|
180
|
+
if (eatKey) {
|
181
|
+
eating = true;
|
182
|
+
}
|
183
|
+
else {
|
184
|
+
if (!eating || line.match(/^\S/)) {
|
185
|
+
eating = false;
|
186
|
+
outputYaml.push(line);
|
187
|
+
}
|
188
|
+
}
|
189
|
+
}
|
190
|
+
const otherYamlRendered = `<pre class="quarto-frontmatter-container"><code class="cm-s-jupyter language-yaml quarto-frontmatter">${outputYaml.join("\n")}</code></pre>`;
|
172
191
|
titleLines.push(otherYamlRendered);
|
173
192
|
}
|
174
193
|
return titleLines.join('\n');
|
package/package.json
CHANGED