@quarto/jupyterlab-quarto 0.1.45 → 0.2.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +1 -1
- package/README.md +48 -15
- 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 +105 -39
- 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
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
* Copyright (c) Bas Verweij. All rights reserved.
|
|
3
3
|
* Licensed under the MIT License. See LICENSE in the project root for license information.
|
|
4
4
|
*--------------------------------------------------------------------------------------------*/
|
|
5
|
-
import getCells from
|
|
6
|
-
import ColumnAlignments from
|
|
5
|
+
import getCells from '../gridtables/GetCells';
|
|
6
|
+
import ColumnAlignments from './ColumnAlignments';
|
|
7
7
|
export default function emitTable(md, state, result) {
|
|
8
8
|
let offsets = result.SeparatorLineOffsets;
|
|
9
9
|
let token = state.push('table_open', 'table', 1);
|
|
@@ -21,42 +21,40 @@ export default function emitTable(md, state, result) {
|
|
|
21
21
|
token = state.push('tbody_open', 'tbody', 1);
|
|
22
22
|
token.map = [offsets[0], offsets[offsets.length - 1]];
|
|
23
23
|
for (let i = 0; i < result.RowLines.length; i++) {
|
|
24
|
-
|
|
24
|
+
const cells = getCells(result.RowLines[i]);
|
|
25
25
|
processRow(md, state, 'td', result.ColumnAlignments, offsets[i], offsets[i + 1], cells);
|
|
26
26
|
}
|
|
27
27
|
state.push('tbody_close', 'tbody', -1);
|
|
28
28
|
state.push('table_close', 'table', -1);
|
|
29
29
|
}
|
|
30
30
|
function processRow(md, state, tag, columnAlignments, lineBegin, lineEnd, cells) {
|
|
31
|
-
|
|
31
|
+
const token = state.push('tr_open', 'tr', 1);
|
|
32
32
|
token.map = [lineBegin, lineEnd];
|
|
33
33
|
for (let i = 0; i < cells.length; i++) {
|
|
34
|
-
|
|
34
|
+
const token = state.push(tag + '_open', tag, 1);
|
|
35
35
|
token.map = [lineBegin + 1, lineEnd - 1];
|
|
36
36
|
if (columnAlignments[i] !== ColumnAlignments.None) {
|
|
37
|
-
token.attrSet(
|
|
37
|
+
token.attrSet('style', `text-align: ${columnAlignments[i]};`);
|
|
38
38
|
}
|
|
39
39
|
if (cells[i].length === 0) {
|
|
40
40
|
// empty cell
|
|
41
41
|
}
|
|
42
42
|
else if (cells[i].length === 1) {
|
|
43
43
|
// single line cell -> emit as inline markdown
|
|
44
|
-
|
|
44
|
+
const token = state.push('inline', '', 0);
|
|
45
45
|
token.content = cells[i][0].trim();
|
|
46
46
|
token.children = [];
|
|
47
47
|
}
|
|
48
48
|
else {
|
|
49
49
|
// multi line cell -> render and emit as html
|
|
50
|
-
let cell = md
|
|
51
|
-
.render(cells[i].join('\r\n'))
|
|
52
|
-
.trim();
|
|
50
|
+
let cell = md.render(cells[i].join('\r\n')).trim();
|
|
53
51
|
// remove single p tag because we're in a table cell
|
|
54
|
-
if (
|
|
55
|
-
|
|
56
|
-
|
|
52
|
+
if (cell.slice(0, 3) === '<p>' &&
|
|
53
|
+
cell.slice(-4) === '</p>' &&
|
|
54
|
+
cell.indexOf('<p>', 3) === -1) {
|
|
57
55
|
cell = cell.slice(3, cell.length - 4);
|
|
58
56
|
}
|
|
59
|
-
|
|
57
|
+
const token = state.push('html_block', '', 0);
|
|
60
58
|
token.content = cell;
|
|
61
59
|
token.children = [];
|
|
62
60
|
}
|
|
@@ -64,4 +62,3 @@ function processRow(md, state, tag, columnAlignments, lineBegin, lineEnd, cells)
|
|
|
64
62
|
}
|
|
65
63
|
state.push('tr_close', 'tr', -1);
|
|
66
64
|
}
|
|
67
|
-
//# sourceMappingURL=EmitTable.js.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import IState from
|
|
1
|
+
import IState from '../../interfaces/markdown-it/IState';
|
|
2
2
|
/**
|
|
3
3
|
* Returns the char code of the character at the start of the current line,
|
|
4
4
|
* or -1 if this is not available (e.g. on an empty line).
|
|
@@ -6,4 +6,3 @@ import IState from "../../interfaces/markdown-it/IState";
|
|
|
6
6
|
* @param state The Markdown It state.
|
|
7
7
|
*/
|
|
8
8
|
export default function getCharCodeAtStartOfLine(state: IState, line: number): number;
|
|
9
|
-
//# sourceMappingURL=GetCharCodeAtStartOfLine.d.ts.map
|
|
@@ -9,11 +9,9 @@
|
|
|
9
9
|
* @param state The Markdown It state.
|
|
10
10
|
*/
|
|
11
11
|
export default function getCharCodeAtStartOfLine(state, line) {
|
|
12
|
-
const pos = state.bMarks[line] +
|
|
13
|
-
state.tShift[line];
|
|
12
|
+
const pos = state.bMarks[line] + state.tShift[line];
|
|
14
13
|
if (pos >= state.eMarks[line]) {
|
|
15
14
|
return -1;
|
|
16
15
|
}
|
|
17
16
|
return state.src.charCodeAt(pos);
|
|
18
17
|
}
|
|
19
|
-
//# sourceMappingURL=GetCharCodeAtStartOfLine.js.map
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import IState from
|
|
2
|
-
import ParseTableResult from
|
|
1
|
+
import IState from '../../interfaces/markdown-it/IState';
|
|
2
|
+
import ParseTableResult from './ParseTableResult';
|
|
3
3
|
export default function parseTable(state: IState, startLine: number, endLine: number): ParseTableResult;
|
|
4
|
-
//# sourceMappingURL=ParseTable.d.ts.map
|
|
@@ -2,11 +2,11 @@
|
|
|
2
2
|
* Copyright (c) Bas Verweij. All rights reserved.
|
|
3
3
|
* Licensed under the MIT License. See LICENSE in the project root for license information.
|
|
4
4
|
*--------------------------------------------------------------------------------------------*/
|
|
5
|
-
import wcwidth from
|
|
6
|
-
import getColumnWidths from
|
|
7
|
-
import ColumnAlignments from
|
|
8
|
-
import getLine from
|
|
9
|
-
import ParseTableResult from
|
|
5
|
+
import wcwidth from 'wcwidth';
|
|
6
|
+
import getColumnWidths from '../gridtables/GetColumnWidths';
|
|
7
|
+
import ColumnAlignments from './ColumnAlignments';
|
|
8
|
+
import getLine from './GetLine';
|
|
9
|
+
import ParseTableResult from './ParseTableResult';
|
|
10
10
|
export default function parseTable(state, startLine, endLine) {
|
|
11
11
|
const result = new ParseTableResult();
|
|
12
12
|
let rowLine = getLine(state, startLine);
|
|
@@ -20,8 +20,7 @@ export default function parseTable(state, startLine, endLine) {
|
|
|
20
20
|
return result;
|
|
21
21
|
}
|
|
22
22
|
// initialize column alignments
|
|
23
|
-
result.ColumnAlignments = result.ColumnWidths
|
|
24
|
-
.map(_ => ColumnAlignments.None);
|
|
23
|
+
result.ColumnAlignments = result.ColumnWidths.map(() => ColumnAlignments.None);
|
|
25
24
|
if (rowLine.indexOf(':') >= 0) {
|
|
26
25
|
// column alignment specifiers present in first row line
|
|
27
26
|
result.HeaderLess = true;
|
|
@@ -32,21 +31,16 @@ export default function parseTable(state, startLine, endLine) {
|
|
|
32
31
|
}
|
|
33
32
|
// create header line matcher
|
|
34
33
|
const headerLineMatcher = new RegExp('^\\+' +
|
|
35
|
-
result.ColumnWidths
|
|
36
|
-
.map(w => `[=:][=]{${w - 3}}[=:]\\+`)
|
|
37
|
-
.join('') +
|
|
34
|
+
result.ColumnWidths.map(w => `[=:][=]{${w - 3}}[=:]\\+`).join('') +
|
|
38
35
|
'$');
|
|
39
36
|
// build column offsets
|
|
40
37
|
result.ColumnOffsets = [0];
|
|
41
38
|
for (let i = 0; i < result.ColumnWidths.length - 1; i++) {
|
|
42
|
-
result.ColumnOffsets.push(result.ColumnOffsets[i] +
|
|
43
|
-
result.ColumnWidths[i]);
|
|
39
|
+
result.ColumnOffsets.push(result.ColumnOffsets[i] + result.ColumnWidths[i]);
|
|
44
40
|
}
|
|
45
41
|
// create cell line matcher
|
|
46
42
|
const cellLineMatcher = new RegExp('^\\|' +
|
|
47
|
-
result.ColumnWidths
|
|
48
|
-
.map(w => `([^|]{${Math.ceil((w - 1) / 2)},${w - 1}})\\|`)
|
|
49
|
-
.join('') +
|
|
43
|
+
result.ColumnWidths.map(w => `([^|]{${Math.ceil((w - 1) / 2)},${w - 1}})\\|`).join('') +
|
|
50
44
|
'$');
|
|
51
45
|
// save first separator line offset
|
|
52
46
|
result.SeparatorLineOffsets.push(startLine);
|
|
@@ -55,8 +49,8 @@ export default function parseTable(state, startLine, endLine) {
|
|
|
55
49
|
let currentLine = startLine + 1;
|
|
56
50
|
for (; currentLine <= endLine; currentLine++) {
|
|
57
51
|
const line = getLine(state, currentLine);
|
|
58
|
-
if (line.charCodeAt(0) ===
|
|
59
|
-
|
|
52
|
+
if (line.charCodeAt(0) === 0x2b) {
|
|
53
|
+
// '+'
|
|
60
54
|
// separator line
|
|
61
55
|
if (currentRow.length === 0) {
|
|
62
56
|
// no row lines since last separator -> invalid table
|
|
@@ -71,11 +65,9 @@ export default function parseTable(state, startLine, endLine) {
|
|
|
71
65
|
result.HeaderLess = true;
|
|
72
66
|
}
|
|
73
67
|
}
|
|
74
|
-
else if (!result.HeaderLess &&
|
|
75
|
-
line.match(headerLineMatcher)) {
|
|
68
|
+
else if (!result.HeaderLess && line.match(headerLineMatcher)) {
|
|
76
69
|
// found header line
|
|
77
|
-
if (result.HeaderLines.length > 0 ||
|
|
78
|
-
result.RowLines.length > 0) {
|
|
70
|
+
if (result.HeaderLines.length > 0 || result.RowLines.length > 0) {
|
|
79
71
|
// header already found, or not the first row -> invalid table
|
|
80
72
|
return result;
|
|
81
73
|
}
|
|
@@ -93,8 +85,8 @@ export default function parseTable(state, startLine, endLine) {
|
|
|
93
85
|
// reset current row
|
|
94
86
|
currentRow = [];
|
|
95
87
|
}
|
|
96
|
-
else if (line.charCodeAt(0) ===
|
|
97
|
-
|
|
88
|
+
else if (line.charCodeAt(0) === 0x7c) {
|
|
89
|
+
// '|'
|
|
98
90
|
// cell line
|
|
99
91
|
const matches = line.match(cellLineMatcher);
|
|
100
92
|
if (matches === null) {
|
|
@@ -112,8 +104,7 @@ export default function parseTable(state, startLine, endLine) {
|
|
|
112
104
|
else {
|
|
113
105
|
// not a separator or cell line, check if we have a complete table
|
|
114
106
|
if (currentRow.length === 0 &&
|
|
115
|
-
(
|
|
116
|
-
(result.RowLines.length > 0))) {
|
|
107
|
+
(result.HeaderLines.length > 0 || result.RowLines.length > 0)) {
|
|
117
108
|
// found a complete table
|
|
118
109
|
break;
|
|
119
110
|
}
|
|
@@ -125,7 +116,7 @@ export default function parseTable(state, startLine, endLine) {
|
|
|
125
116
|
return result;
|
|
126
117
|
}
|
|
127
118
|
function getColumnAlignments(line, columnWidths) {
|
|
128
|
-
|
|
119
|
+
const alignments = [];
|
|
129
120
|
let left = 1;
|
|
130
121
|
let right = -1;
|
|
131
122
|
for (let i = 0; i < columnWidths.length; i++) {
|
|
@@ -149,7 +140,7 @@ function getColumnAlignments(line, columnWidths) {
|
|
|
149
140
|
}
|
|
150
141
|
function validateColumnWidths(matches, columnWidths) {
|
|
151
142
|
const cells = [];
|
|
152
|
-
for (
|
|
143
|
+
for (let i = 0; i < columnWidths.length; i++) {
|
|
153
144
|
const cell = matches[i + 1];
|
|
154
145
|
const columnWidth = wcwidth(cell) + 1; // add 1 for separator
|
|
155
146
|
if (columnWidth !== columnWidths[i]) {
|
|
@@ -159,4 +150,3 @@ function validateColumnWidths(matches, columnWidths) {
|
|
|
159
150
|
}
|
|
160
151
|
return cells;
|
|
161
152
|
}
|
|
162
|
-
//# sourceMappingURL=ParseTable.js.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import ColumnAlignments from
|
|
1
|
+
import ColumnAlignments from './ColumnAlignments';
|
|
2
2
|
export default class ParseTableResult {
|
|
3
3
|
Success: boolean;
|
|
4
4
|
ColumnWidths: number[];
|
|
@@ -10,4 +10,3 @@ export default class ParseTableResult {
|
|
|
10
10
|
SeparatorLineOffsets: number[];
|
|
11
11
|
CurrentLine: number;
|
|
12
12
|
}
|
|
13
|
-
//# sourceMappingURL=ParseTableResult.d.ts.map
|
|
@@ -2,10 +2,9 @@
|
|
|
2
2
|
* Copyright (c) Bas Verweij. All rights reserved.
|
|
3
3
|
* Licensed under the MIT License. See LICENSE in the project root for license information.
|
|
4
4
|
*--------------------------------------------------------------------------------------------*/
|
|
5
|
-
import gridTableRule from
|
|
5
|
+
import gridTableRule from './rules/gridtable';
|
|
6
6
|
export default function gridTableRulePlugin(
|
|
7
7
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
8
8
|
md) {
|
|
9
|
-
md.block.ruler.before(
|
|
9
|
+
md.block.ruler.before('table', 'gridtable', gridTableRule(md));
|
|
10
10
|
}
|
|
11
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import IToken from
|
|
1
|
+
import IToken from './IToken';
|
|
2
2
|
export default interface IState {
|
|
3
3
|
src: string;
|
|
4
4
|
bMarks: number[];
|
|
@@ -8,4 +8,3 @@ export default interface IState {
|
|
|
8
8
|
line: number;
|
|
9
9
|
push(action: string, tag: string, level: number): IToken;
|
|
10
10
|
}
|
|
11
|
-
//# sourceMappingURL=IState.d.ts.map
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import * as MarkdownIt from
|
|
2
|
-
import TRuleFunction from
|
|
1
|
+
import * as MarkdownIt from 'markdown-it';
|
|
2
|
+
import TRuleFunction from '../interfaces/markdown-it/TRuleFunction';
|
|
3
3
|
export default function gridTableRule(md: MarkdownIt): TRuleFunction;
|
|
4
|
-
//# sourceMappingURL=gridtable.d.ts.map
|
|
@@ -2,16 +2,16 @@
|
|
|
2
2
|
* Copyright (c) Bas Verweij. All rights reserved.
|
|
3
3
|
* Licensed under the MIT License. See LICENSE in the project root for license information.
|
|
4
4
|
*--------------------------------------------------------------------------------------------*/
|
|
5
|
-
import emitTable from
|
|
6
|
-
import getCharCodeAtStartOfLine from
|
|
7
|
-
import parseTable from
|
|
5
|
+
import emitTable from '../common/markdown-it/EmitTable';
|
|
6
|
+
import getCharCodeAtStartOfLine from '../common/markdown-it/GetCharCodeAtStartOfLine';
|
|
7
|
+
import parseTable from '../common/markdown-it/ParseTable';
|
|
8
8
|
export default function gridTableRule(md) {
|
|
9
9
|
return function (state, startLine, endLine, silent) {
|
|
10
|
-
if (getCharCodeAtStartOfLine(state, startLine) !==
|
|
10
|
+
if (getCharCodeAtStartOfLine(state, startLine) !== 0x2b) {
|
|
11
11
|
// line does not start with a '+'
|
|
12
12
|
return false;
|
|
13
13
|
}
|
|
14
|
-
|
|
14
|
+
const parseResult = parseTable(state, startLine, endLine);
|
|
15
15
|
if (!parseResult.Success) {
|
|
16
16
|
return false;
|
|
17
17
|
}
|
|
@@ -23,4 +23,3 @@ export default function gridTableRule(md) {
|
|
|
23
23
|
return true;
|
|
24
24
|
};
|
|
25
25
|
}
|
|
26
|
-
//# sourceMappingURL=gridtable.js.map
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import gridTableRulePlugin from './gridtables';
|
|
2
|
+
export { gridTableRulePlugin };
|
|
3
|
+
import mermaidPlugin from './mermaid';
|
|
4
|
+
export { mermaidPlugin };
|
|
5
|
+
export * from './callouts';
|
|
6
|
+
export * from './cites';
|
|
7
|
+
export * from './decorator';
|
|
8
|
+
export * from './divs';
|
|
9
|
+
export * from './figure-divs';
|
|
10
|
+
export * from './figures';
|
|
11
|
+
export * from './math';
|
|
12
|
+
export * from './shortcodes';
|
|
13
|
+
export * from './spans';
|
|
14
|
+
export * from './table-captions';
|
|
15
|
+
export * from './yaml';
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* index.ts
|
|
3
|
+
*
|
|
4
|
+
* Copyright (C) 2020-2023 Posit Software, PBC
|
|
5
|
+
*
|
|
6
|
+
*/
|
|
7
|
+
import gridTableRulePlugin from './gridtables';
|
|
8
|
+
export { gridTableRulePlugin };
|
|
9
|
+
import mermaidPlugin from './mermaid';
|
|
10
|
+
export { mermaidPlugin };
|
|
11
|
+
export * from './callouts';
|
|
12
|
+
export * from './cites';
|
|
13
|
+
export * from './decorator';
|
|
14
|
+
export * from './divs';
|
|
15
|
+
export * from './figure-divs';
|
|
16
|
+
export * from './figures';
|
|
17
|
+
export * from './math';
|
|
18
|
+
export * from './shortcodes';
|
|
19
|
+
export * from './spans';
|
|
20
|
+
export * from './table-captions';
|
|
21
|
+
export * from './yaml';
|
package/lib/plugins/math.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import type MarkdownIt from
|
|
1
|
+
import type MarkdownIt from 'markdown-it';
|
|
2
2
|
export declare const kTokMathBlock = "math_block";
|
|
3
3
|
export declare const kTokMathInline = "math_inline";
|
|
4
|
-
export declare function mathjaxPlugin(md: MarkdownIt
|
|
5
|
-
|
|
4
|
+
export declare function mathjaxPlugin(md: MarkdownIt, options?: {
|
|
5
|
+
enableInlines?: boolean;
|
|
6
|
+
}): void;
|
package/lib/plugins/math.js
CHANGED
|
@@ -4,8 +4,8 @@
|
|
|
4
4
|
* Copyright (C) 2020-2023 Posit Software, PBC
|
|
5
5
|
*
|
|
6
6
|
*/
|
|
7
|
-
export const kTokMathBlock =
|
|
8
|
-
export const kTokMathInline =
|
|
7
|
+
export const kTokMathBlock = 'math_block';
|
|
8
|
+
export const kTokMathInline = 'math_inline';
|
|
9
9
|
function renderMath(content, convertOptions) {
|
|
10
10
|
if (convertOptions.display) {
|
|
11
11
|
return `<div class='quarto-display-math'>\\[${content}\\]</div>`;
|
|
@@ -33,17 +33,17 @@ function isValidDelim(state, pos) {
|
|
|
33
33
|
}
|
|
34
34
|
return {
|
|
35
35
|
can_open: can_open,
|
|
36
|
-
can_close: can_close
|
|
36
|
+
can_close: can_close
|
|
37
37
|
};
|
|
38
38
|
}
|
|
39
39
|
function math_inline(state, silent) {
|
|
40
|
-
if (state.src[state.pos] !==
|
|
40
|
+
if (state.src[state.pos] !== '$') {
|
|
41
41
|
return false;
|
|
42
42
|
}
|
|
43
43
|
let res = isValidDelim(state, state.pos);
|
|
44
44
|
if (!res.can_open) {
|
|
45
45
|
if (!silent) {
|
|
46
|
-
state.pending +=
|
|
46
|
+
state.pending += '$';
|
|
47
47
|
}
|
|
48
48
|
state.pos += 1;
|
|
49
49
|
return true;
|
|
@@ -54,15 +54,15 @@ function math_inline(state, silent) {
|
|
|
54
54
|
// we have found an opening delimieter already.
|
|
55
55
|
const start = state.pos + 1;
|
|
56
56
|
let match = start;
|
|
57
|
-
while ((match = state.src.indexOf(
|
|
57
|
+
while ((match = state.src.indexOf('$', match)) !== -1) {
|
|
58
58
|
// Found potential $, look for escapes, pos will point to
|
|
59
59
|
// first non escape when complete
|
|
60
60
|
let pos = match - 1;
|
|
61
|
-
while (state.src[pos] ===
|
|
61
|
+
while (state.src[pos] === '\\') {
|
|
62
62
|
pos -= 1;
|
|
63
63
|
}
|
|
64
64
|
// Even number of escapes, potential closing delimiter found
|
|
65
|
-
if ((match - pos) % 2
|
|
65
|
+
if ((match - pos) % 2 === 1) {
|
|
66
66
|
break;
|
|
67
67
|
}
|
|
68
68
|
match += 1;
|
|
@@ -70,7 +70,7 @@ function math_inline(state, silent) {
|
|
|
70
70
|
// No closing delimter found. Consume $ and continue.
|
|
71
71
|
if (match === -1) {
|
|
72
72
|
if (!silent) {
|
|
73
|
-
state.pending +=
|
|
73
|
+
state.pending += '$';
|
|
74
74
|
}
|
|
75
75
|
state.pos = start;
|
|
76
76
|
return true;
|
|
@@ -78,7 +78,7 @@ function math_inline(state, silent) {
|
|
|
78
78
|
// Check if we have empty content, ie: $$. Do not parse.
|
|
79
79
|
if (match - start === 0) {
|
|
80
80
|
if (!silent) {
|
|
81
|
-
state.pending +=
|
|
81
|
+
state.pending += '$$';
|
|
82
82
|
}
|
|
83
83
|
state.pos = start + 1;
|
|
84
84
|
return true;
|
|
@@ -87,14 +87,14 @@ function math_inline(state, silent) {
|
|
|
87
87
|
res = isValidDelim(state, match);
|
|
88
88
|
if (!res.can_close) {
|
|
89
89
|
if (!silent) {
|
|
90
|
-
state.pending +=
|
|
90
|
+
state.pending += '$';
|
|
91
91
|
}
|
|
92
92
|
state.pos = start;
|
|
93
93
|
return true;
|
|
94
94
|
}
|
|
95
95
|
if (!silent) {
|
|
96
|
-
const token = state.push(
|
|
97
|
-
token.markup =
|
|
96
|
+
const token = state.push('math_inline', 'math', 0);
|
|
97
|
+
token.markup = '$';
|
|
98
98
|
token.content = state.src.slice(start, match);
|
|
99
99
|
}
|
|
100
100
|
state.pos = match + 1;
|
|
@@ -102,11 +102,11 @@ function math_inline(state, silent) {
|
|
|
102
102
|
}
|
|
103
103
|
function math_block(state, start, end, silent) {
|
|
104
104
|
let next, lastPos;
|
|
105
|
-
let found = false, pos = state.bMarks[start] + state.tShift[start], max = state.eMarks[start], lastLine =
|
|
105
|
+
let found = false, pos = state.bMarks[start] + state.tShift[start], max = state.eMarks[start], lastLine = '';
|
|
106
106
|
if (pos + 2 > max) {
|
|
107
107
|
return false;
|
|
108
108
|
}
|
|
109
|
-
if (state.src.slice(pos, pos + 2) !==
|
|
109
|
+
if (state.src.slice(pos, pos + 2) !== '$$') {
|
|
110
110
|
return false;
|
|
111
111
|
}
|
|
112
112
|
pos += 2;
|
|
@@ -114,7 +114,7 @@ function math_block(state, start, end, silent) {
|
|
|
114
114
|
if (silent) {
|
|
115
115
|
return true;
|
|
116
116
|
}
|
|
117
|
-
if (firstLine.trim().slice(-2) ===
|
|
117
|
+
if (firstLine.trim().slice(-2) === '$$') {
|
|
118
118
|
// Single line expression
|
|
119
119
|
firstLine = firstLine.trim().slice(0, -2);
|
|
120
120
|
found = true;
|
|
@@ -134,44 +134,46 @@ function math_block(state, start, end, silent) {
|
|
|
134
134
|
const line = state.src.slice(pos, max).trim();
|
|
135
135
|
const match = line.match(/^\$\$\s*(\{.*\})?\s*$/);
|
|
136
136
|
if (match) {
|
|
137
|
-
lastPos = state.src.slice(0, max).lastIndexOf(
|
|
137
|
+
lastPos = state.src.slice(0, max).lastIndexOf('$$');
|
|
138
138
|
lastLine = state.src.slice(pos, lastPos);
|
|
139
139
|
attrStr = match[1];
|
|
140
140
|
found = true;
|
|
141
141
|
}
|
|
142
142
|
}
|
|
143
143
|
state.line = next + 1;
|
|
144
|
-
const token = state.push(kTokMathBlock,
|
|
144
|
+
const token = state.push(kTokMathBlock, 'math', 0);
|
|
145
145
|
token.block = true;
|
|
146
146
|
if (attrStr) {
|
|
147
147
|
token.info = attrStr;
|
|
148
148
|
}
|
|
149
149
|
token.content =
|
|
150
|
-
(firstLine && firstLine.trim() ? firstLine +
|
|
150
|
+
(firstLine && firstLine.trim() ? firstLine + '\n' : '') +
|
|
151
151
|
state.getLines(start + 1, next, state.tShift[start], true) +
|
|
152
|
-
(lastLine && lastLine.trim() ? lastLine :
|
|
152
|
+
(lastLine && lastLine.trim() ? lastLine : '');
|
|
153
153
|
token.map = [start, state.line];
|
|
154
|
-
token.markup =
|
|
154
|
+
token.markup = '$$';
|
|
155
155
|
return true;
|
|
156
156
|
}
|
|
157
|
-
export function mathjaxPlugin(md) {
|
|
157
|
+
export function mathjaxPlugin(md, options) {
|
|
158
158
|
// Default options
|
|
159
|
+
options = options || {};
|
|
160
|
+
const enableInlines = options.enableInlines !== undefined ? options.enableInlines : true;
|
|
159
161
|
const convertOptions = {
|
|
160
162
|
display: false
|
|
161
163
|
};
|
|
162
164
|
// set MathJax as the renderer for markdown-it-simplemath
|
|
163
|
-
md.inline.ruler.after(
|
|
164
|
-
md.block.ruler.after(
|
|
165
|
-
alt: [
|
|
165
|
+
md.inline.ruler.after('escape', kTokMathInline, math_inline);
|
|
166
|
+
md.block.ruler.after('blockquote', kTokMathBlock, math_block, {
|
|
167
|
+
alt: ['paragraph', 'reference', 'blockquote', 'list']
|
|
166
168
|
});
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
169
|
+
if (enableInlines) {
|
|
170
|
+
md.renderer.rules.math_inline = function (tokens, idx) {
|
|
171
|
+
convertOptions.display = false;
|
|
172
|
+
return renderMath(tokens[idx].content, convertOptions);
|
|
173
|
+
};
|
|
174
|
+
}
|
|
171
175
|
md.renderer.rules.math_block = function (tokens, idx) {
|
|
172
176
|
convertOptions.display = true;
|
|
173
177
|
return renderMath(tokens[idx].content, convertOptions);
|
|
174
178
|
};
|
|
175
179
|
}
|
|
176
|
-
;
|
|
177
|
-
//# sourceMappingURL=math.js.map
|
|
@@ -1,21 +1,24 @@
|
|
|
1
|
-
import Mermaid from
|
|
1
|
+
import Mermaid from 'mermaid';
|
|
2
2
|
export default function mermaidPlugin(md, options) {
|
|
3
|
-
const kLang =
|
|
4
|
-
const kContainer =
|
|
3
|
+
const kLang = 'mermaid';
|
|
4
|
+
const kContainer = 'quarto-mermaid';
|
|
5
5
|
Mermaid.initialize({
|
|
6
|
-
securityLevel:
|
|
7
|
-
theme: options.dark ?
|
|
8
|
-
...options
|
|
6
|
+
securityLevel: 'loose',
|
|
7
|
+
theme: options.dark ? 'dark' : 'default',
|
|
8
|
+
...options
|
|
9
9
|
});
|
|
10
10
|
const defaultFenceRenderer = md.renderer.rules.fence;
|
|
11
11
|
// Render custom code types as SVGs, letting the fence parser do all the heavy lifting.
|
|
12
12
|
function mermaidFenceRenderer(tokens, idx, options, env, slf) {
|
|
13
13
|
const token = tokens[idx];
|
|
14
|
-
if (token.info === kLang ||
|
|
15
|
-
|
|
14
|
+
if (token.info === kLang ||
|
|
15
|
+
(token.attrs !== null &&
|
|
16
|
+
token.attrs.length === 1 &&
|
|
17
|
+
token.attrs[0][0] === kLang)) {
|
|
18
|
+
let imageHTML = '';
|
|
16
19
|
const imageAttrs = [];
|
|
17
20
|
// Create element to render into
|
|
18
|
-
const element = document.createElement(
|
|
21
|
+
const element = document.createElement('div');
|
|
19
22
|
document.body.appendChild(element);
|
|
20
23
|
// Render with Mermaid
|
|
21
24
|
try {
|
|
@@ -24,8 +27,8 @@ export default function mermaidPlugin(md, options) {
|
|
|
24
27
|
const mermaidEl = document.getElementById(kContainer);
|
|
25
28
|
if (mermaidEl !== null) {
|
|
26
29
|
imageAttrs.push([
|
|
27
|
-
|
|
28
|
-
`max-width:${mermaidEl.style.maxWidth};max-height:${mermaidEl.style.maxHeight}
|
|
30
|
+
'style',
|
|
31
|
+
`max-width:${mermaidEl.style.maxWidth};max-height:${mermaidEl.style.maxHeight}`
|
|
29
32
|
]);
|
|
30
33
|
}
|
|
31
34
|
// Store HTML
|
|
@@ -39,7 +42,10 @@ export default function mermaidPlugin(md, options) {
|
|
|
39
42
|
element.remove();
|
|
40
43
|
}
|
|
41
44
|
// Store encoded image data
|
|
42
|
-
imageAttrs.push([
|
|
45
|
+
imageAttrs.push([
|
|
46
|
+
'src',
|
|
47
|
+
`data:image/svg+xml,${encodeURIComponent(imageHTML)}`
|
|
48
|
+
]);
|
|
43
49
|
return `<img ${slf.renderAttrs({ attrs: imageAttrs })}>`;
|
|
44
50
|
}
|
|
45
51
|
else {
|
|
@@ -47,9 +53,8 @@ export default function mermaidPlugin(md, options) {
|
|
|
47
53
|
return defaultFenceRenderer(tokens, idx, options, env, slf);
|
|
48
54
|
}
|
|
49
55
|
// Missing fence renderer!
|
|
50
|
-
return
|
|
56
|
+
return '';
|
|
51
57
|
}
|
|
52
58
|
}
|
|
53
59
|
md.renderer.rules.fence = mermaidFenceRenderer;
|
|
54
60
|
}
|
|
55
|
-
//# sourceMappingURL=index.js.map
|