@zeropress/build-core 0.6.3 → 0.6.5
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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zeropress/build-core",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.5",
|
|
4
4
|
"description": "Shared ZeroPress build core",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -35,9 +35,9 @@
|
|
|
35
35
|
"dependencies": {
|
|
36
36
|
"@zeropress/slug-policy": "0.1.0",
|
|
37
37
|
"@zeropress/preview-data-validator": "0.6.3",
|
|
38
|
-
"@zeropress/theme-validator": "0.6.
|
|
38
|
+
"@zeropress/theme-validator": "0.6.5",
|
|
39
39
|
"highlight.js": "11.11.1",
|
|
40
|
-
"markdown-it": "
|
|
41
|
-
"markdown-it-anchor": "
|
|
40
|
+
"markdown-it": "14.2.0",
|
|
41
|
+
"markdown-it-anchor": "9.2.0"
|
|
42
42
|
}
|
|
43
43
|
}
|
package/src/api/build-site.js
CHANGED
|
@@ -1019,8 +1019,12 @@ function attachCollectionCursors(posts, pages, collections) {
|
|
|
1019
1019
|
return;
|
|
1020
1020
|
}
|
|
1021
1021
|
|
|
1022
|
+
const cursor = buildCollectionCursor(collectionId, collection, items, index);
|
|
1022
1023
|
target.collection_cursors = target.collection_cursors || {};
|
|
1023
|
-
target.collection_cursors[collectionId] =
|
|
1024
|
+
target.collection_cursors[collectionId] = cursor;
|
|
1025
|
+
if (!target.collection_cursor) {
|
|
1026
|
+
target.collection_cursor = cursor;
|
|
1027
|
+
}
|
|
1024
1028
|
});
|
|
1025
1029
|
}
|
|
1026
1030
|
}
|
|
@@ -71,6 +71,7 @@ function createMarkdownRenderer(toc) {
|
|
|
71
71
|
|
|
72
72
|
markdown.use(markdownTaskLists);
|
|
73
73
|
markdown.use(markdownAlerts);
|
|
74
|
+
markdown.use(markdownTableAlignmentClasses);
|
|
74
75
|
markdown.use(anchor, {
|
|
75
76
|
slugify: slugify,
|
|
76
77
|
callback(token, { slug, title }) {
|
|
@@ -91,6 +92,25 @@ function createMarkdownRenderer(toc) {
|
|
|
91
92
|
return markdown;
|
|
92
93
|
}
|
|
93
94
|
|
|
95
|
+
function markdownTableAlignmentClasses(markdown) {
|
|
96
|
+
for (const tokenName of ['th_open', 'td_open']) {
|
|
97
|
+
markdown.renderer.rules[tokenName] = (tokens, index, options, env, self) => {
|
|
98
|
+
const token = tokens[index];
|
|
99
|
+
const styleIndex = token.attrIndex('style');
|
|
100
|
+
if (styleIndex >= 0) {
|
|
101
|
+
const styleValue = token.attrs[styleIndex][1] || '';
|
|
102
|
+
const match = /(?:^|;)\s*text-align\s*:\s*(left|center|right)\s*;?\s*$/i.exec(styleValue);
|
|
103
|
+
if (match) {
|
|
104
|
+
token.attrs.splice(styleIndex, 1);
|
|
105
|
+
addTokenClass(token, `zp-align-${match[1].toLowerCase()}`);
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
return self.renderToken(tokens, index, options);
|
|
110
|
+
};
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
|
|
94
114
|
function markdownTaskLists(markdown) {
|
|
95
115
|
markdown.core.ruler.after('inline', 'zeropress_task_lists', (state) => {
|
|
96
116
|
const listStack = [];
|
|
@@ -370,10 +370,11 @@ export class ControlFlowRenderer {
|
|
|
370
370
|
let alternate = [];
|
|
371
371
|
let nextIndex = startIndex;
|
|
372
372
|
let currentBranch = initialBranch;
|
|
373
|
-
const
|
|
373
|
+
const comparisonStopTags = new Set(['else', 'if', tagName, ...COMPARISON_ELSE_IF_TAGS]);
|
|
374
|
+
const comparisonCloseTags = new Set(['if', tagName]);
|
|
374
375
|
|
|
375
376
|
while (true) {
|
|
376
|
-
const branchResult = this.parseNodes(source, nextIndex,
|
|
377
|
+
const branchResult = this.parseNodes(source, nextIndex, comparisonStopTags, partialArgScope);
|
|
377
378
|
branches.push({
|
|
378
379
|
operator: currentBranch.operator,
|
|
379
380
|
left: currentBranch.left,
|
|
@@ -382,8 +383,8 @@ export class ControlFlowRenderer {
|
|
|
382
383
|
});
|
|
383
384
|
|
|
384
385
|
if (branchResult.stopTag === 'else') {
|
|
385
|
-
const elseResult = this.parseNodes(source, branchResult.nextIndex,
|
|
386
|
-
if (elseResult.stopTag
|
|
386
|
+
const elseResult = this.parseNodes(source, branchResult.nextIndex, comparisonCloseTags, partialArgScope);
|
|
387
|
+
if (!comparisonCloseTags.has(elseResult.stopTag)) {
|
|
387
388
|
throw new Error(`Unclosed ${tagName} block after else`);
|
|
388
389
|
}
|
|
389
390
|
alternate = elseResult.nodes;
|
|
@@ -391,16 +392,19 @@ export class ControlFlowRenderer {
|
|
|
391
392
|
break;
|
|
392
393
|
}
|
|
393
394
|
|
|
394
|
-
|
|
395
|
+
const comparisonElseIfTag = typeof branchResult.stopTag === 'string'
|
|
396
|
+
? getComparisonElseIfTag(branchResult.stopTag)
|
|
397
|
+
: '';
|
|
398
|
+
if (comparisonElseIfTag) {
|
|
395
399
|
currentBranch = this.parseComparisonBranchExpression(
|
|
396
|
-
branchResult.stopTag.slice(`#${
|
|
397
|
-
|
|
400
|
+
branchResult.stopTag.slice(`#${comparisonElseIfTag} `.length).trim(),
|
|
401
|
+
comparisonElseIfTag,
|
|
398
402
|
);
|
|
399
403
|
nextIndex = branchResult.nextIndex;
|
|
400
404
|
continue;
|
|
401
405
|
}
|
|
402
406
|
|
|
403
|
-
if (branchResult.stopTag
|
|
407
|
+
if (comparisonCloseTags.has(branchResult.stopTag)) {
|
|
404
408
|
nextIndex = branchResult.nextIndex;
|
|
405
409
|
break;
|
|
406
410
|
}
|