@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.
- package/LICENSE +1 -1
- package/README.md +45 -12
- package/lib/__tests__/jupyterlab-quarto.spec.d.ts +3 -0
- package/lib/__tests__/jupyterlab-quarto.spec.js +9 -0
- package/lib/ast/ast.d.ts +1 -2
- package/lib/ast/ast.js +4 -3
- package/lib/const.d.ts +1 -2
- package/lib/const.js +5 -6
- package/lib/hooks/codemirror.d.ts +5 -4
- package/lib/hooks/codemirror.js +37 -12
- package/lib/index.d.ts +2 -3
- package/lib/index.js +6 -5
- package/lib/manager.d.ts +2 -2
- package/lib/manager.js +14 -16
- package/lib/plugins/callouts.d.ts +1 -2
- package/lib/plugins/callouts.js +59 -58
- package/lib/plugins/cites.d.ts +1 -2
- package/lib/plugins/cites.js +41 -23
- package/lib/plugins/decorator.d.ts +1 -2
- package/lib/plugins/decorator.js +11 -12
- package/lib/plugins/divs.d.ts +1 -2
- package/lib/plugins/divs.js +20 -9
- package/lib/plugins/figure-divs.d.ts +1 -2
- package/lib/plugins/figure-divs.js +18 -17
- package/lib/plugins/figures.d.ts +3 -4
- package/lib/plugins/figures.js +30 -31
- package/lib/plugins/gridtables/common/gridtables/GetCells.d.ts +5 -6
- package/lib/plugins/gridtables/common/gridtables/GetCells.js +6 -8
- package/lib/plugins/gridtables/common/gridtables/GetColumnWidths.d.ts +5 -6
- package/lib/plugins/gridtables/common/gridtables/GetColumnWidths.js +9 -14
- package/lib/plugins/gridtables/common/markdown-it/ColumnAlignments.d.ts +0 -1
- package/lib/plugins/gridtables/common/markdown-it/ColumnAlignments.js +0 -1
- package/lib/plugins/gridtables/common/markdown-it/EmitTable.d.ts +3 -4
- package/lib/plugins/gridtables/common/markdown-it/EmitTable.js +12 -15
- package/lib/plugins/gridtables/common/markdown-it/GetCharCodeAtStartOfLine.d.ts +1 -2
- package/lib/plugins/gridtables/common/markdown-it/GetCharCodeAtStartOfLine.js +1 -3
- package/lib/plugins/gridtables/common/markdown-it/GetLine.d.ts +1 -2
- package/lib/plugins/gridtables/common/markdown-it/GetLine.js +0 -1
- package/lib/plugins/gridtables/common/markdown-it/ParseTable.d.ts +2 -3
- package/lib/plugins/gridtables/common/markdown-it/ParseTable.js +18 -28
- package/lib/plugins/gridtables/common/markdown-it/ParseTableResult.d.ts +1 -2
- package/lib/plugins/gridtables/common/markdown-it/ParseTableResult.js +0 -1
- package/lib/plugins/gridtables/index.d.ts +0 -1
- package/lib/plugins/gridtables/index.js +2 -3
- package/lib/plugins/gridtables/interfaces/markdown-it/IState.d.ts +1 -2
- package/lib/plugins/gridtables/interfaces/markdown-it/IState.js +0 -1
- package/lib/plugins/gridtables/interfaces/markdown-it/IToken.d.ts +0 -1
- package/lib/plugins/gridtables/interfaces/markdown-it/IToken.js +0 -1
- package/lib/plugins/gridtables/interfaces/markdown-it/TRuleFunction.d.ts +1 -2
- package/lib/plugins/gridtables/interfaces/markdown-it/TRuleFunction.js +0 -1
- package/lib/plugins/gridtables/rules/gridtable.d.ts +2 -3
- package/lib/plugins/gridtables/rules/gridtable.js +5 -6
- package/lib/plugins/index.d.ts +15 -0
- package/lib/plugins/index.js +21 -0
- package/lib/plugins/math.d.ts +4 -3
- package/lib/plugins/math.js +33 -31
- package/lib/plugins/mermaid/index.d.ts +1 -2
- package/lib/plugins/mermaid/index.js +19 -14
- package/lib/plugins/shortcodes.d.ts +1 -2
- package/lib/plugins/shortcodes.js +6 -7
- package/lib/plugins/spans.d.ts +1 -2
- package/lib/plugins/spans.js +2 -4
- package/lib/plugins/table-captions.d.ts +1 -2
- package/lib/plugins/table-captions.js +19 -16
- package/lib/plugins/utils/html.d.ts +1 -2
- package/lib/plugins/utils/html.js +19 -15
- package/lib/plugins/utils/markdownit.d.ts +0 -1
- package/lib/plugins/utils/markdownit.js +14 -13
- package/lib/plugins/utils/tok.d.ts +0 -1
- package/lib/plugins/utils/tok.js +12 -13
- package/lib/plugins/yaml.d.ts +1 -2
- package/lib/plugins/yaml.js +59 -49
- package/lib/providers/attrs.d.ts +1 -2
- package/lib/providers/attrs.js +5 -6
- package/lib/providers/callouts.d.ts +1 -2
- package/lib/providers/callouts.js +7 -8
- package/lib/providers/cites.d.ts +1 -2
- package/lib/providers/cites.js +7 -8
- package/lib/providers/decorator.d.ts +1 -2
- package/lib/providers/decorator.js +7 -8
- package/lib/providers/deflist.d.ts +1 -2
- package/lib/providers/deflist.js +5 -6
- package/lib/providers/divs.d.ts +1 -2
- package/lib/providers/divs.js +9 -10
- package/lib/providers/figure-divs.d.ts +1 -2
- package/lib/providers/figure-divs.js +5 -6
- package/lib/providers/figures.d.ts +1 -2
- package/lib/providers/figures.js +5 -6
- package/lib/providers/footnotes.d.ts +1 -2
- package/lib/providers/footnotes.js +5 -6
- package/lib/providers/gridtables.d.ts +1 -2
- package/lib/providers/gridtables.js +5 -6
- package/lib/providers/math.d.ts +1 -2
- package/lib/providers/math.js +12 -13
- package/lib/providers/mermaid.d.ts +1 -2
- package/lib/providers/mermaid.js +10 -9
- package/lib/providers/provider.d.ts +1 -2
- package/lib/providers/provider.js +0 -1
- package/lib/providers/shortcodes.d.ts +1 -2
- package/lib/providers/shortcodes.js +5 -6
- package/lib/providers/spans.d.ts +1 -2
- package/lib/providers/spans.js +8 -9
- package/lib/providers/sub.d.ts +1 -2
- package/lib/providers/sub.js +5 -6
- package/lib/providers/sup.d.ts +1 -2
- package/lib/providers/sup.js +5 -6
- package/lib/providers/table-captions.d.ts +1 -2
- package/lib/providers/table-captions.js +5 -6
- package/lib/providers/tasklists.d.ts +1 -2
- package/lib/providers/tasklists.js +5 -6
- package/lib/providers/yaml.d.ts +1 -2
- package/lib/providers/yaml.js +7 -8
- package/lib/types.d.ts +0 -1
- package/lib/types.js +0 -1
- package/lib/widgets.d.ts +0 -1
- package/lib/widgets.js +5 -6
- package/package.json +103 -37
- package/style/base.css +34 -33
- package/style/index.css +1 -1
- package/lib/__tests__/index.spec.d.ts +0 -6
- package/lib/__tests__/index.spec.js +0 -61
- package/lib/__tests__/index.spec.js.map +0 -1
- package/lib/__tests__/myextension.spec.d.ts +0 -6
- package/lib/__tests__/myextension.spec.js +0 -11
- package/lib/__tests__/myextension.spec.js.map +0 -1
- package/lib/ast/ast.js.map +0 -1
- package/lib/const.js.map +0 -1
- package/lib/hooks/codemirror.js.map +0 -1
- package/lib/index.js.map +0 -1
- package/lib/manager.js.map +0 -1
- package/lib/plugins/callouts.js.map +0 -1
- package/lib/plugins/cites.js.map +0 -1
- package/lib/plugins/decorator.js.map +0 -1
- package/lib/plugins/divs.js.map +0 -1
- package/lib/plugins/figure-divs.js.map +0 -1
- package/lib/plugins/figures.js.map +0 -1
- package/lib/plugins/gridtables/common/gridtables/GetCells.js.map +0 -1
- package/lib/plugins/gridtables/common/gridtables/GetColumnWidths.js.map +0 -1
- package/lib/plugins/gridtables/common/markdown-it/ColumnAlignments.js.map +0 -1
- package/lib/plugins/gridtables/common/markdown-it/EmitTable.js.map +0 -1
- package/lib/plugins/gridtables/common/markdown-it/GetCharCodeAtStartOfLine.js.map +0 -1
- package/lib/plugins/gridtables/common/markdown-it/GetLine.js.map +0 -1
- package/lib/plugins/gridtables/common/markdown-it/ParseTable.js.map +0 -1
- package/lib/plugins/gridtables/common/markdown-it/ParseTableResult.js.map +0 -1
- package/lib/plugins/gridtables/index.js.map +0 -1
- package/lib/plugins/gridtables/interfaces/markdown-it/IState.js.map +0 -1
- package/lib/plugins/gridtables/interfaces/markdown-it/IToken.js.map +0 -1
- package/lib/plugins/gridtables/interfaces/markdown-it/TRuleFunction.js.map +0 -1
- package/lib/plugins/gridtables/rules/gridtable.js.map +0 -1
- package/lib/plugins/math.js.map +0 -1
- package/lib/plugins/mermaid/index.js.map +0 -1
- package/lib/plugins/shortcodes.js.map +0 -1
- package/lib/plugins/spans.js.map +0 -1
- package/lib/plugins/table-captions.js.map +0 -1
- package/lib/plugins/utils/html.js.map +0 -1
- package/lib/plugins/utils/markdownit.js.map +0 -1
- package/lib/plugins/utils/tok.js.map +0 -1
- package/lib/plugins/yaml.js.map +0 -1
- package/lib/providers/attrs.js.map +0 -1
- package/lib/providers/callouts.js.map +0 -1
- package/lib/providers/cites.js.map +0 -1
- package/lib/providers/decorator.js.map +0 -1
- package/lib/providers/deflist.js.map +0 -1
- package/lib/providers/divs.js.map +0 -1
- package/lib/providers/figure-divs.js.map +0 -1
- package/lib/providers/figures.js.map +0 -1
- package/lib/providers/footnotes.js.map +0 -1
- package/lib/providers/gridtables.js.map +0 -1
- package/lib/providers/math.js.map +0 -1
- package/lib/providers/mermaid.js.map +0 -1
- package/lib/providers/provider.js.map +0 -1
- package/lib/providers/shortcodes.js.map +0 -1
- package/lib/providers/spans.js.map +0 -1
- package/lib/providers/sub.js.map +0 -1
- package/lib/providers/sup.js.map +0 -1
- package/lib/providers/table-captions.js.map +0 -1
- package/lib/providers/tasklists.js.map +0 -1
- package/lib/providers/yaml.js.map +0 -1
- package/lib/types.js.map +0 -1
- package/lib/widgets.js.map +0 -1
- package/schema/plugin.json +0 -8
- package/src/@types/markdown-it-deflist.d.ts +0 -10
- package/src/@types/markdown-it-footnote.d.ts +0 -10
- package/src/@types/markdown-it-gridtables.d.ts +0 -10
- package/src/@types/markdown-it-implicit-figures.d.ts +0 -10
- package/src/@types/markdown-it-sub.d.ts +0 -10
- package/src/@types/markdown-it-sup.d.ts +0 -10
- package/src/@types/markdown-it-task-lists.d.ts +0 -10
@@ -1,9 +1,9 @@
|
|
1
|
-
import { escapeHtml } from
|
2
|
-
export const kShortcode =
|
1
|
+
import { escapeHtml } from 'markdown-it/lib/common/utils';
|
2
|
+
export const kShortcode = 'shortcode';
|
3
3
|
export const shortcodePlugin = (md) => {
|
4
4
|
const shortcode = (state, silent) => {
|
5
5
|
// {{< shortcode >}}
|
6
|
-
if (state.src.slice(state.pos, state.pos + 3) !==
|
6
|
+
if (state.src.slice(state.pos, state.pos + 3) !== '{{<') {
|
7
7
|
return false;
|
8
8
|
}
|
9
9
|
const shortcodeEndRegex = />}}/g;
|
@@ -14,14 +14,14 @@ export const shortcodePlugin = (md) => {
|
|
14
14
|
}
|
15
15
|
const shortcodeContent = state.src.slice(state.pos + 3, state.pos + end);
|
16
16
|
if (!silent) {
|
17
|
-
const token = state.push(
|
18
|
-
token.markup =
|
17
|
+
const token = state.push('shortcode', 'shortcode', 0);
|
18
|
+
token.markup = '';
|
19
19
|
token.content = shortcodeContent;
|
20
20
|
}
|
21
21
|
state.pos += end + 3;
|
22
22
|
return true;
|
23
23
|
};
|
24
|
-
md.inline.ruler.after(
|
24
|
+
md.inline.ruler.after('escape', kShortcode, shortcode);
|
25
25
|
const renderShortcode = (tokens, idx) => {
|
26
26
|
const token = tokens[idx];
|
27
27
|
const content = token.content;
|
@@ -30,4 +30,3 @@ export const shortcodePlugin = (md) => {
|
|
30
30
|
};
|
31
31
|
md.renderer.rules[kShortcode] = renderShortcode;
|
32
32
|
};
|
33
|
-
//# sourceMappingURL=shortcodes.js.map
|
package/lib/plugins/spans.d.ts
CHANGED
package/lib/plugins/spans.js
CHANGED
@@ -7,7 +7,7 @@
|
|
7
7
|
export function spansPlugin(md) {
|
8
8
|
function span(state) {
|
9
9
|
const max = state.posMax;
|
10
|
-
if (state.src.charCodeAt(state.pos) !==
|
10
|
+
if (state.src.charCodeAt(state.pos) !== 0x5b) {
|
11
11
|
// opening [
|
12
12
|
return false;
|
13
13
|
}
|
@@ -18,7 +18,7 @@ export function spansPlugin(md) {
|
|
18
18
|
return false;
|
19
19
|
}
|
20
20
|
const pos = labelEnd + 1;
|
21
|
-
if (pos < max && state.src.charCodeAt(pos) ===
|
21
|
+
if (pos < max && state.src.charCodeAt(pos) === 0x7b /* { */) {
|
22
22
|
// probably found span
|
23
23
|
state.pos = labelStart;
|
24
24
|
state.posMax = labelEnd;
|
@@ -33,7 +33,5 @@ export function spansPlugin(md) {
|
|
33
33
|
return false;
|
34
34
|
}
|
35
35
|
}
|
36
|
-
;
|
37
36
|
md.inline.ruler.push('quarto-spans', span);
|
38
37
|
}
|
39
|
-
//# sourceMappingURL=spans.js.map
|
@@ -4,10 +4,10 @@
|
|
4
4
|
* Copyright (C) 2020-2023 Posit Software, PBC
|
5
5
|
*
|
6
6
|
*/
|
7
|
-
import { kTokInline, kTokParaClose, kTokParaOpen, kTokTableClose, kTokTableOpen, kTokText } from
|
8
|
-
const kTableCaptionRule =
|
7
|
+
import { kTokInline, kTokParaClose, kTokParaOpen, kTokTableClose, kTokTableOpen, kTokText } from './utils/tok';
|
8
|
+
const kTableCaptionRule = 'quarto-table-captions';
|
9
9
|
export const tableCaptionPlugin = (md) => {
|
10
|
-
md.core.ruler.push(kTableCaptionRule,
|
10
|
+
md.core.ruler.push(kTableCaptionRule, state => {
|
11
11
|
const tableIdxs = [];
|
12
12
|
const tablePoss = [];
|
13
13
|
// Identify tables that we'd like to process
|
@@ -29,8 +29,8 @@ export const tableCaptionPlugin = (md) => {
|
|
29
29
|
}
|
30
30
|
}
|
31
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
|
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
34
|
for (const tablePos of tablePoss) {
|
35
35
|
resolveTableCaption(state.tokens, tablePos.start, tablePos.end);
|
36
36
|
}
|
@@ -39,31 +39,34 @@ export const tableCaptionPlugin = (md) => {
|
|
39
39
|
function resolveTableCaption(tokens, tblStartPos, tblEndPos) {
|
40
40
|
// Must have at least three tokens past the table end
|
41
41
|
if (tokens.length > tblEndPos + 3) {
|
42
|
-
if (tokens[tblEndPos + 1].type === kTokParaOpen
|
43
|
-
|
44
|
-
|
42
|
+
if (tokens[tblEndPos + 1].type === kTokParaOpen &&
|
43
|
+
tokens[tblEndPos + 2].type === kTokInline &&
|
44
|
+
tokens[tblEndPos + 3].type === kTokParaClose) {
|
45
45
|
const maybeCaption = tokens[tblEndPos + 2];
|
46
|
-
const isText = maybeCaption.children !== null &&
|
47
|
-
|
46
|
+
const isText = maybeCaption.children !== null &&
|
47
|
+
maybeCaption.children.length > 0 &&
|
48
|
+
maybeCaption.children[0].type === kTokText;
|
49
|
+
const maybeCaptionText = isText && maybeCaption.children ? maybeCaption.children[0].content : '';
|
48
50
|
const match = maybeCaptionText.match(/^:\s([^{}]*)(?:\{.*\}){0,1}$/);
|
49
51
|
if (match && match[1]) {
|
50
52
|
// Carve out the existing tokens
|
51
53
|
const capTokens = tokens.splice(tblEndPos + 1, 3);
|
52
54
|
// We have the caption, remove the paragraph and return
|
53
55
|
// the caption
|
54
|
-
capTokens[0].type =
|
55
|
-
capTokens[0].tag =
|
56
|
+
capTokens[0].type = 'table_caption';
|
57
|
+
capTokens[0].tag = 'caption';
|
56
58
|
// Forward any attributes from the caption up to the table
|
57
59
|
tokens[tblStartPos].attrs = capTokens[0].attrs;
|
58
60
|
capTokens[0].attrs = [];
|
59
61
|
// Trim the content
|
60
|
-
capTokens[1].children[
|
62
|
+
if (capTokens[1].children && capTokens[1].children.length > 0) {
|
63
|
+
capTokens[1].children[0].content = match[1];
|
64
|
+
}
|
61
65
|
// Close the caption
|
62
|
-
capTokens[2].type =
|
63
|
-
capTokens[2].tag =
|
66
|
+
capTokens[2].type = 'table_caption';
|
67
|
+
capTokens[2].tag = 'caption';
|
64
68
|
tokens.splice(tblStartPos + 1, 0, ...capTokens);
|
65
69
|
}
|
66
70
|
}
|
67
71
|
}
|
68
72
|
}
|
69
|
-
//# sourceMappingURL=table-captions.js.map
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import Token from
|
1
|
+
import Token from 'markdown-it/lib/token';
|
2
2
|
export interface DecoratorOptions {
|
3
3
|
customClass?: string;
|
4
4
|
hide: {
|
@@ -9,4 +9,3 @@ export interface DecoratorOptions {
|
|
9
9
|
}
|
10
10
|
export declare const decorator: (contents: string[], customClass?: string) => string;
|
11
11
|
export declare const attributeDecorator: (token: Token, options?: DecoratorOptions) => string;
|
12
|
-
//# sourceMappingURL=html.d.ts.map
|
@@ -1,41 +1,46 @@
|
|
1
1
|
/*
|
2
|
-
* html.ts
|
3
|
-
*
|
4
|
-
* Copyright (C) 2020-2023 Posit Software, PBC
|
5
|
-
*
|
6
|
-
*/
|
7
|
-
import { readAttrValue } from
|
2
|
+
* html.ts
|
3
|
+
*
|
4
|
+
* Copyright (C) 2020-2023 Posit Software, PBC
|
5
|
+
*
|
6
|
+
*/
|
7
|
+
import { readAttrValue } from './markdownit';
|
8
8
|
export const decorator = (contents, customClass) => {
|
9
9
|
if (contents.length > 0) {
|
10
10
|
// Provide a decorator with the attributes
|
11
|
-
return `<div class="quarto-attribute-decorator${customClass ? ' ' + customClass :
|
11
|
+
return `<div class="quarto-attribute-decorator${customClass ? ' ' + customClass : ''}">${contents.map(decoratorSpan).join('')}</div>`;
|
12
12
|
}
|
13
13
|
else {
|
14
14
|
// There is no decorator - no attributes
|
15
|
-
return
|
15
|
+
return '';
|
16
16
|
}
|
17
17
|
};
|
18
18
|
export const attributeDecorator = (token, options) => {
|
19
19
|
var _a;
|
20
20
|
// id
|
21
|
-
const id = readAttrValue(
|
21
|
+
const id = readAttrValue('id', token.attrs);
|
22
22
|
// classes
|
23
|
-
const clz = readAttrValue(
|
23
|
+
const clz = readAttrValue('class', token.attrs);
|
24
24
|
// other attributes
|
25
|
-
const otherAttrs = (_a = token.attrs) === null || _a === void 0 ? void 0 : _a.filter(
|
25
|
+
const otherAttrs = (_a = token.attrs) === null || _a === void 0 ? void 0 : _a.filter(attr => {
|
26
|
+
return attr[0] !== 'id' && attr[0] !== 'class';
|
27
|
+
});
|
26
28
|
// Create a decorator for the div
|
27
29
|
const contents = [];
|
28
30
|
if (id && !(options === null || options === void 0 ? void 0 : options.hide.id)) {
|
29
31
|
contents.push(`#${id}`);
|
30
32
|
}
|
31
33
|
if (clz && !(options === null || options === void 0 ? void 0 : options.hide.classes)) {
|
32
|
-
const clzStr = clz
|
34
|
+
const clzStr = clz
|
35
|
+
.split(' ')
|
36
|
+
.map(cls => `.${cls}`)
|
37
|
+
.join(' ');
|
33
38
|
contents.push(clzStr);
|
34
39
|
}
|
35
40
|
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(
|
41
|
+
const otherAttrStr = otherAttrs === null || otherAttrs === void 0 ? void 0 : otherAttrs.map(attr => {
|
37
42
|
return `${attr[0]}="${attr[1]}"`;
|
38
|
-
}).join(
|
43
|
+
}).join(' ');
|
39
44
|
contents.push(otherAttrStr);
|
40
45
|
}
|
41
46
|
return decorator(contents, options === null || options === void 0 ? void 0 : options.customClass);
|
@@ -43,4 +48,3 @@ export const attributeDecorator = (token, options) => {
|
|
43
48
|
const decoratorSpan = (contents) => {
|
44
49
|
return `<span class="quarto-attribute-decorator-content">${contents}</span>`;
|
45
50
|
};
|
46
|
-
//# sourceMappingURL=html.js.map
|
@@ -1,45 +1,46 @@
|
|
1
1
|
/*
|
2
|
-
* markdownit.ts
|
3
|
-
*
|
4
|
-
* Copyright (C) 2020-2023 Posit Software, PBC
|
5
|
-
*
|
6
|
-
*/
|
2
|
+
* markdownit.ts
|
3
|
+
*
|
4
|
+
* Copyright (C) 2020-2023 Posit Software, PBC
|
5
|
+
*
|
6
|
+
*/
|
7
7
|
export const hasClass = (clz, attrs) => {
|
8
8
|
if (attrs === null) {
|
9
9
|
return false;
|
10
10
|
}
|
11
|
-
const classes = readAttrValue(
|
11
|
+
const classes = readAttrValue('class', attrs);
|
12
12
|
if (classes === null) {
|
13
13
|
return false;
|
14
14
|
}
|
15
15
|
else {
|
16
|
-
return classes === null || classes === void 0 ? void 0 : classes.split(
|
16
|
+
return classes === null || classes === void 0 ? void 0 : classes.split(' ').includes(clz);
|
17
17
|
}
|
18
18
|
};
|
19
19
|
export const readAttrValue = (name, attrs) => {
|
20
20
|
if (attrs === null) {
|
21
21
|
return undefined;
|
22
22
|
}
|
23
|
-
const attr = attrs.find(
|
23
|
+
const attr = attrs.find(attr => {
|
24
|
+
return attr[0] === name;
|
25
|
+
});
|
24
26
|
return attr ? attr[1] : undefined;
|
25
27
|
};
|
26
28
|
export const addClass = (clz, attrs) => {
|
27
29
|
if (attrs === null) {
|
28
30
|
attrs = [];
|
29
|
-
attrs.push([
|
31
|
+
attrs.push(['class', clz]);
|
30
32
|
return attrs;
|
31
33
|
}
|
32
34
|
else {
|
33
|
-
const clzIdx = attrs.findIndex(
|
35
|
+
const clzIdx = attrs.findIndex(attr => attr[0] === 'class');
|
34
36
|
if (clzIdx >= 0) {
|
35
37
|
const currentClz = attrs[clzIdx];
|
36
|
-
attrs[clzIdx] = [
|
38
|
+
attrs[clzIdx] = ['class', `${currentClz[1]} ${clz}`.trim()];
|
37
39
|
return attrs;
|
38
40
|
}
|
39
41
|
else {
|
40
|
-
attrs.push([
|
42
|
+
attrs.push(['class', clz]);
|
41
43
|
return attrs;
|
42
44
|
}
|
43
45
|
}
|
44
46
|
};
|
45
|
-
//# sourceMappingURL=markdownit.js.map
|
package/lib/plugins/utils/tok.js
CHANGED
@@ -1,14 +1,13 @@
|
|
1
1
|
/*
|
2
|
-
* tok.ts
|
3
|
-
*
|
4
|
-
* Copyright (C) 2020-2023 Posit Software, PBC
|
5
|
-
*
|
6
|
-
*/
|
7
|
-
export const kTokParaOpen =
|
8
|
-
export const kTokParaClose =
|
9
|
-
export const kTokInline =
|
10
|
-
export const kTokTableOpen =
|
11
|
-
export const kTokTableClose =
|
12
|
-
export const kTokText =
|
13
|
-
export const kTokHeadingOpen =
|
14
|
-
//# sourceMappingURL=tok.js.map
|
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';
|
package/lib/plugins/yaml.d.ts
CHANGED
package/lib/plugins/yaml.js
CHANGED
@@ -13,14 +13,14 @@
|
|
13
13
|
* AGPL (http://www.gnu.org/licenses/agpl-3.0.txt) for more details.
|
14
14
|
*
|
15
15
|
*/
|
16
|
-
import * as yaml from
|
17
|
-
import { decorator } from
|
16
|
+
import * as yaml from 'js-yaml';
|
17
|
+
import { decorator } from './utils/html';
|
18
18
|
// Typescript version of https://github.com/parksb/markdown-it-front-matter
|
19
19
|
// TODO: Rationalize this with quarto-core/src/markdownit-yaml.ts
|
20
20
|
// This is a copy with rendering added - the core tokenizing function is identical (or should be)
|
21
21
|
const kTokFrontMatter = 'front_matter';
|
22
22
|
export function yamlPlugin(md, cb) {
|
23
|
-
const min_markers = 3, marker_str =
|
23
|
+
const min_markers = 3, marker_str = '-', marker_char = marker_str.charCodeAt(0), marker_len = marker_str.length;
|
24
24
|
function frontMatter(state, startLine, endLine, silent) {
|
25
25
|
let pos, nextLine, start_content, user_closed = false, start = state.bMarks[startLine] + state.tShift[startLine], max = state.eMarks[startLine];
|
26
26
|
// Check out the first character of the first line quickly,
|
@@ -54,7 +54,7 @@ export function yamlPlugin(md, cb) {
|
|
54
54
|
// also block seems to be autoclosed by end of parent
|
55
55
|
break;
|
56
56
|
}
|
57
|
-
if (state.src.slice(start, max) ===
|
57
|
+
if (state.src.slice(start, max) === '...') {
|
58
58
|
break;
|
59
59
|
}
|
60
60
|
start = state.bMarks[nextLine] + state.tShift[nextLine];
|
@@ -94,12 +94,12 @@ export function yamlPlugin(md, cb) {
|
|
94
94
|
// Ensure that we have real yaml here
|
95
95
|
const markup = state.src.slice(startLine, pos);
|
96
96
|
const yaml = parseFrontMatterStr(markup);
|
97
|
-
const isYamlBlock = yaml !== null && typeof
|
97
|
+
const isYamlBlock = yaml !== null && typeof yaml === 'object';
|
98
98
|
// If this is yaml, render it
|
99
99
|
if (isYamlBlock && user_closed) {
|
100
100
|
const old_parent = state.parentType;
|
101
101
|
const old_line_max = state.lineMax;
|
102
|
-
const token = state.push(kTokFrontMatter,
|
102
|
+
const token = state.push(kTokFrontMatter, '', 0);
|
103
103
|
token.hidden = true;
|
104
104
|
token.markup = markup;
|
105
105
|
token.block = true;
|
@@ -119,8 +119,8 @@ export function yamlPlugin(md, cb) {
|
|
119
119
|
return false;
|
120
120
|
}
|
121
121
|
}
|
122
|
-
md.block.ruler.before(
|
123
|
-
alt: [
|
122
|
+
md.block.ruler.before('table', kTokFrontMatter, frontMatter, {
|
123
|
+
alt: ['paragraph', 'reference', 'blockquote', 'list']
|
124
124
|
});
|
125
125
|
// Add rendering
|
126
126
|
md.renderer.rules[kTokFrontMatter] = renderFrontMatter;
|
@@ -130,14 +130,14 @@ function renderFrontMatter(tokens, idx) {
|
|
130
130
|
// Parse the markup
|
131
131
|
const frontUnknown = parseFrontMatterStr(token.markup);
|
132
132
|
// Extract important content
|
133
|
-
if (typeof
|
133
|
+
if (typeof frontUnknown === 'object') {
|
134
134
|
const titleBlock = {};
|
135
135
|
const frontMatter = frontUnknown;
|
136
136
|
const readStr = (key) => {
|
137
137
|
if (frontMatter[key] === undefined) {
|
138
138
|
return undefined;
|
139
139
|
}
|
140
|
-
else if (typeof
|
140
|
+
else if (typeof frontMatter[key] === 'string') {
|
141
141
|
const val = frontMatter[key];
|
142
142
|
delete frontMatter[key];
|
143
143
|
return val;
|
@@ -147,12 +147,12 @@ function renderFrontMatter(tokens, idx) {
|
|
147
147
|
}
|
148
148
|
};
|
149
149
|
// Read simple values
|
150
|
-
titleBlock.title = readStr(
|
151
|
-
titleBlock.subtitle = readStr(
|
152
|
-
titleBlock.abstract = readStr(
|
153
|
-
titleBlock.date = readStr(
|
154
|
-
titleBlock.modified = readStr(
|
155
|
-
titleBlock.doi = readStr(
|
150
|
+
titleBlock.title = readStr('title');
|
151
|
+
titleBlock.subtitle = readStr('subtitle');
|
152
|
+
titleBlock.abstract = readStr('abstract');
|
153
|
+
titleBlock.date = readStr('date');
|
154
|
+
titleBlock.modified = readStr('date-modified');
|
155
|
+
titleBlock.doi = readStr('doi');
|
156
156
|
// Read Authors
|
157
157
|
titleBlock.authors = parseAuthor(frontMatter.author || frontMatter.authors);
|
158
158
|
delete frontMatter.author;
|
@@ -164,22 +164,22 @@ function renderFrontMatter(tokens, idx) {
|
|
164
164
|
titleLines.push(titleRendered);
|
165
165
|
if (Object.keys(frontMatter).length > 0) {
|
166
166
|
// decorator
|
167
|
-
const decor = decorator([
|
167
|
+
const decor = decorator(['Options']);
|
168
168
|
titleLines.push(decor);
|
169
169
|
// yaml
|
170
170
|
const yamlDump = yaml.dump(frontMatter);
|
171
171
|
const otherYamlRendered = `<pre class="quarto-frontmatter-container"><code class="cm-s-jupyter language-yaml quarto-frontmatter">${yamlDump}</code></pre>`;
|
172
172
|
titleLines.push(otherYamlRendered);
|
173
173
|
}
|
174
|
-
return titleLines.join(
|
174
|
+
return titleLines.join('\n');
|
175
175
|
}
|
176
176
|
else {
|
177
|
-
return
|
177
|
+
return '';
|
178
178
|
}
|
179
179
|
}
|
180
180
|
// TODO: Use core function instead
|
181
181
|
function parseFrontMatterStr(str) {
|
182
|
-
str = str.replace(/---\s*$/,
|
182
|
+
str = str.replace(/---\s*$/, '');
|
183
183
|
try {
|
184
184
|
return yaml.load(str, { schema: yaml.FAILSAFE_SCHEMA });
|
185
185
|
}
|
@@ -212,9 +212,11 @@ function renderTitle(titleBlock) {
|
|
212
212
|
names.push({ value: author.name, padded: i > 0 });
|
213
213
|
}
|
214
214
|
// Place empty rows to allow affiliations to line up
|
215
|
-
const emptyCount = author.affil
|
215
|
+
const emptyCount = author.affil
|
216
|
+
? Math.max(author.affil.length - 1, 0)
|
217
|
+
: 0;
|
216
218
|
for (let j = 0; j < emptyCount; j++) {
|
217
|
-
names.push({ value:
|
219
|
+
names.push({ value: ' ' });
|
218
220
|
}
|
219
221
|
// Collect affilations
|
220
222
|
if (author.affil) {
|
@@ -222,26 +224,30 @@ function renderTitle(titleBlock) {
|
|
222
224
|
const affil = author.affil[k];
|
223
225
|
affils.push({
|
224
226
|
value: affil,
|
225
|
-
padded: i > 0 && k
|
227
|
+
padded: i > 0 && k === 0
|
226
228
|
});
|
227
229
|
}
|
228
230
|
}
|
229
231
|
}
|
230
|
-
const authLabel = names.length === 1 ?
|
232
|
+
const authLabel = names.length === 1 ? 'Author' : 'Authors';
|
231
233
|
metadataBlocks.push(renderDocMeta(authLabel, names));
|
232
234
|
if (affils.length > 0) {
|
233
|
-
const affilLabel = affils.length === 1 ?
|
235
|
+
const affilLabel = affils.length === 1 ? 'Affiliation' : 'Affiliations';
|
234
236
|
metadataBlocks.push(renderDocMeta(affilLabel, affils));
|
235
237
|
}
|
236
238
|
}
|
237
239
|
if (titleBlock.date) {
|
238
|
-
metadataBlocks.push(renderDocMeta(
|
240
|
+
metadataBlocks.push(renderDocMeta('Date', [{ value: titleBlock.date }]));
|
239
241
|
}
|
240
242
|
if (titleBlock.modified) {
|
241
|
-
metadataBlocks.push(renderDocMeta(
|
243
|
+
metadataBlocks.push(renderDocMeta('Modified', [{ value: titleBlock.modified }]));
|
242
244
|
}
|
243
245
|
if (titleBlock.doi) {
|
244
|
-
metadataBlocks.push(renderDocMeta(
|
246
|
+
metadataBlocks.push(renderDocMeta('DOI', [
|
247
|
+
{
|
248
|
+
value: `<a href="https://doi.org/${titleBlock.doi}">${titleBlock.doi}</a>`
|
249
|
+
}
|
250
|
+
]));
|
245
251
|
}
|
246
252
|
if (metadataBlocks.length > 0) {
|
247
253
|
rendered.push(renderDocMetas(metadataBlocks));
|
@@ -249,38 +255,41 @@ function renderTitle(titleBlock) {
|
|
249
255
|
if (titleBlock.abstract) {
|
250
256
|
rendered.push(`<p class="quarto-abstract">${titleBlock.abstract}</p>`);
|
251
257
|
}
|
252
|
-
return rendered.join(
|
258
|
+
return rendered.join('\n');
|
253
259
|
}
|
254
260
|
function renderDocMetas(docMetas) {
|
255
261
|
const rendered = [];
|
256
|
-
rendered.push(
|
257
|
-
docMetas.forEach(
|
258
|
-
|
259
|
-
|
262
|
+
rendered.push('<div class="quarto-meta-block">');
|
263
|
+
docMetas.forEach(docMeta => {
|
264
|
+
rendered.push(docMeta);
|
265
|
+
});
|
266
|
+
rendered.push('</div>');
|
267
|
+
return rendered.join('\n');
|
260
268
|
}
|
261
269
|
function renderDocMeta(label, vals) {
|
262
270
|
const rendered = [];
|
263
|
-
rendered.push(
|
271
|
+
rendered.push('<div class="quarto-meta">');
|
264
272
|
rendered.push(`<p class="quarto-meta-title">${label}</p>`);
|
265
|
-
vals.forEach(
|
266
|
-
const clz = val.padded ?
|
273
|
+
vals.forEach(val => {
|
274
|
+
const clz = val.padded ? ' class="quarto-meta-padded"' : '';
|
267
275
|
rendered.push(`<p${clz}>${val.value}</p>`);
|
268
276
|
});
|
269
|
-
rendered.push(
|
270
|
-
return rendered.join(
|
277
|
+
rendered.push('</div>');
|
278
|
+
return rendered.join('\n');
|
271
279
|
}
|
272
280
|
function parseAuthor(author) {
|
281
|
+
var _a;
|
273
282
|
const authorsRaw = Array.isArray(author) ? author : [author];
|
274
283
|
const authors = [];
|
275
284
|
for (const authorRaw of authorsRaw) {
|
276
|
-
if (typeof
|
285
|
+
if (typeof authorRaw === 'string') {
|
277
286
|
authors.push({
|
278
287
|
name: authorRaw
|
279
288
|
});
|
280
289
|
}
|
281
|
-
else if (typeof
|
290
|
+
else if (typeof authorRaw === 'object') {
|
282
291
|
const str = (key, defaultValue) => {
|
283
|
-
if (typeof
|
292
|
+
if (typeof authorRaw[key] === 'string') {
|
284
293
|
return authorRaw[key];
|
285
294
|
}
|
286
295
|
else {
|
@@ -288,33 +297,34 @@ function parseAuthor(author) {
|
|
288
297
|
}
|
289
298
|
};
|
290
299
|
const affiliations = [];
|
291
|
-
const affiliationSimple = str(
|
300
|
+
const affiliationSimple = str('affiliation');
|
292
301
|
if (affiliationSimple) {
|
293
302
|
affiliations.push(affiliationSimple);
|
294
303
|
}
|
295
304
|
else if (authorRaw.affiliations) {
|
296
|
-
const affils = Array.isArray(authorRaw.affiliations)
|
305
|
+
const affils = Array.isArray(authorRaw.affiliations)
|
306
|
+
? authorRaw.affiliations
|
307
|
+
: [authorRaw.affiliations];
|
297
308
|
affils.forEach((affilRaw) => {
|
298
|
-
if (typeof
|
309
|
+
if (typeof affilRaw === 'string') {
|
299
310
|
affiliations.push(affilRaw);
|
300
311
|
// eslint-disable-next-line no-constant-condition
|
301
312
|
}
|
302
|
-
else if (typeof (affilRaw ===
|
313
|
+
else if (typeof (affilRaw === 'object')) {
|
303
314
|
const affilRecord = affilRaw;
|
304
315
|
const name = affilRecord.name;
|
305
|
-
if (typeof
|
316
|
+
if (typeof name === 'string') {
|
306
317
|
affiliations.push(name);
|
307
318
|
}
|
308
319
|
}
|
309
320
|
});
|
310
321
|
}
|
311
322
|
authors.push({
|
312
|
-
name: str(
|
313
|
-
orcid: str(
|
323
|
+
name: (_a = str('name', '')) !== null && _a !== void 0 ? _a : '',
|
324
|
+
orcid: str('orcid'),
|
314
325
|
affil: affiliations
|
315
326
|
});
|
316
327
|
}
|
317
328
|
}
|
318
329
|
return authors;
|
319
330
|
}
|
320
|
-
//# sourceMappingURL=yaml.js.map
|
package/lib/providers/attrs.d.ts
CHANGED
@@ -1,2 +1 @@
|
|
1
|
-
export declare const attrs: import("@jupyterlab/application").JupyterFrontEndPlugin<void
|
2
|
-
//# sourceMappingURL=attrs.d.ts.map
|
1
|
+
export declare const attrs: import("@jupyterlab/application").JupyterFrontEndPlugin<void>;
|
package/lib/providers/attrs.js
CHANGED
@@ -1,9 +1,9 @@
|
|
1
1
|
/*
|
2
|
-
* attrs.ts
|
3
|
-
*
|
4
|
-
* Copyright (C) 2020-2023 Posit Software, PBC
|
5
|
-
*
|
6
|
-
*/
|
2
|
+
* attrs.ts
|
3
|
+
*
|
4
|
+
* Copyright (C) 2020-2023 Posit Software, PBC
|
5
|
+
*
|
6
|
+
*/
|
7
7
|
import { markdownItExtension } from './provider';
|
8
8
|
export const attrs = markdownItExtension({
|
9
9
|
id: '@quarto/attributes',
|
@@ -13,4 +13,3 @@ export const attrs = markdownItExtension({
|
|
13
13
|
return [plugin.default];
|
14
14
|
}
|
15
15
|
});
|
16
|
-
//# sourceMappingURL=attrs.js.map
|
@@ -1,2 +1 @@
|
|
1
|
-
export declare const callouts: import("@jupyterlab/application").JupyterFrontEndPlugin<void
|
2
|
-
//# sourceMappingURL=callouts.d.ts.map
|
1
|
+
export declare const callouts: import("@jupyterlab/application").JupyterFrontEndPlugin<void>;
|