@diplodoc/transform 4.75.1 → 4.75.2
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/dist/css/_yfm-only.css.map +1 -1
- package/dist/css/_yfm-only.min.css.map +1 -1
- package/dist/css/base.css.map +1 -1
- package/dist/css/base.min.css.map +1 -1
- package/dist/css/print.css.map +1 -1
- package/dist/css/yfm.css.map +1 -1
- package/dist/css/yfm.min.css.map +1 -1
- package/lib/plugins/table/index.js +6 -6
- package/lib/plugins/table/index.js.map +1 -1
- package/package.json +1 -1
- package/src/transform/plugins/table/index.ts +13 -9
|
@@ -526,7 +526,11 @@ function extractAttributes(state: StateBlock, pos: number): Record<string, strin
|
|
|
526
526
|
* @param {Logger} log - Logger instance for deprecation warnings.
|
|
527
527
|
* @returns {void}
|
|
528
528
|
*/
|
|
529
|
-
function extractAndApplyClassFromToken(
|
|
529
|
+
function extractAndApplyClassFromToken(
|
|
530
|
+
contentToken: Token,
|
|
531
|
+
tdOpenToken: Token,
|
|
532
|
+
log?: Logger,
|
|
533
|
+
): void {
|
|
530
534
|
// Regex to find class attribute in any position within brackets
|
|
531
535
|
const blockRegex = /\s*\{[^}]*}$/;
|
|
532
536
|
const allAttrs = contentToken.content.match(blockRegex);
|
|
@@ -539,7 +543,7 @@ function extractAndApplyClassFromToken(contentToken: Token, tdOpenToken: Token,
|
|
|
539
543
|
|
|
540
544
|
if (attrsClass) {
|
|
541
545
|
if (attrsClass.split(' ').some((c) => c.startsWith('cell-align-'))) {
|
|
542
|
-
log
|
|
546
|
+
log?.warn(
|
|
543
547
|
`Deprecated: use align="..." inside cell attributes "::{align=\\"...\\"}" instead of .cell-align-* class in cell content "{ }"`,
|
|
544
548
|
);
|
|
545
549
|
}
|
|
@@ -562,23 +566,23 @@ const VALID_ALIGN_VALUES: ReadonlySet<string> = new Set([
|
|
|
562
566
|
'bottom-right',
|
|
563
567
|
]);
|
|
564
568
|
|
|
565
|
-
function parseHeaderRows(rawAttrs: TableAttrs, log
|
|
569
|
+
function parseHeaderRows(rawAttrs: TableAttrs, log?: Logger): number | null {
|
|
566
570
|
if (!('header-rows' in rawAttrs)) return null;
|
|
567
571
|
const raw = rawAttrs['header-rows'];
|
|
568
572
|
const trimmed = raw.trim();
|
|
569
573
|
const parsed = Number.parseInt(trimmed, 10);
|
|
570
574
|
if (!Number.isInteger(parsed) || parsed <= 0 || String(parsed) !== trimmed) {
|
|
571
|
-
log
|
|
575
|
+
log?.warn(`Invalid table header-rows value: "${raw}"`);
|
|
572
576
|
return null;
|
|
573
577
|
}
|
|
574
578
|
return parsed;
|
|
575
579
|
}
|
|
576
580
|
|
|
577
|
-
function applyCellAttrs(token: Token, rawAttrs: TableAttrs, log
|
|
581
|
+
function applyCellAttrs(token: Token, rawAttrs: TableAttrs, log?: Logger): void {
|
|
578
582
|
if ('align' in rawAttrs) {
|
|
579
583
|
const value = rawAttrs['align'];
|
|
580
584
|
if (!VALID_ALIGN_VALUES.has(value)) {
|
|
581
|
-
log
|
|
585
|
+
log?.warn(`Unknown table cell align value: "${value}"`);
|
|
582
586
|
}
|
|
583
587
|
token.meta = token.meta || {};
|
|
584
588
|
token.meta.align = value;
|
|
@@ -757,7 +761,7 @@ const yfmTable: MarkdownItPluginCb<YfmTablePluginOptions> = (md, opts) => {
|
|
|
757
761
|
token.meta = token.meta || {};
|
|
758
762
|
token.meta.rawAttrs = tableAttrs;
|
|
759
763
|
|
|
760
|
-
const headerRows = parseHeaderRows(tableAttrs, opts
|
|
764
|
+
const headerRows = parseHeaderRows(tableAttrs, opts?.log);
|
|
761
765
|
if (headerRows !== null) {
|
|
762
766
|
token.meta.headerRows = headerRows;
|
|
763
767
|
token.attrSet('data-header-rows', String(headerRows));
|
|
@@ -808,7 +812,7 @@ const yfmTable: MarkdownItPluginCb<YfmTablePluginOptions> = (md, opts) => {
|
|
|
808
812
|
if (isHeaderRow) {
|
|
809
813
|
token.attrSet('scope', 'col');
|
|
810
814
|
}
|
|
811
|
-
applyCellAttrs(token, cellRawAttrs, opts
|
|
815
|
+
applyCellAttrs(token, cellRawAttrs, opts?.log);
|
|
812
816
|
|
|
813
817
|
const oldTshift = state.tShift[begin.line];
|
|
814
818
|
const oldEMark = state.eMarks[end.line];
|
|
@@ -840,7 +844,7 @@ const yfmTable: MarkdownItPluginCb<YfmTablePluginOptions> = (md, opts) => {
|
|
|
840
844
|
extractAndApplyClassFromToken(
|
|
841
845
|
contentToken,
|
|
842
846
|
rowTokens[rowTokens.length - 1],
|
|
843
|
-
opts
|
|
847
|
+
opts?.log,
|
|
844
848
|
);
|
|
845
849
|
}
|
|
846
850
|
|