@diplodoc/transform 4.75.1 → 4.75.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@diplodoc/transform",
3
- "version": "4.75.1",
3
+ "version": "4.75.3",
4
4
  "description": "A simple transformer of text in YFM (Yandex Flavored Markdown) to HTML",
5
5
  "keywords": [
6
6
  "markdown",
@@ -46,10 +46,10 @@
46
46
  "test:playwright:nobuild": "cd e2e && npm run playwright:docker --",
47
47
  "test:playwright": "npm run build && npm run test:playwright:nobuild --",
48
48
  "typecheck": "tsc -p tsconfig.json --noEmit",
49
- "lint": "lint update && lint",
50
- "lint:fix": "lint update && lint fix",
51
- "pre-commit": "lint update && lint-staged",
52
- "prepare": "husky || exit 0"
49
+ "lint": "lint",
50
+ "lint:fix": "lint fix",
51
+ "pre-commit": "lint-staged",
52
+ "prepare": "husky || true"
53
53
  },
54
54
  "dependencies": {
55
55
  "@diplodoc/cut-extension": "^1.1.1",
@@ -78,7 +78,6 @@
78
78
  },
79
79
  "devDependencies": {
80
80
  "@diplodoc/babel-preset": "^1.0.2",
81
- "@diplodoc/lint": "^1.13.2",
82
81
  "@diplodoc/tsconfig": "^1.0.2",
83
82
  "@types/css": "0.0.34",
84
83
  "@types/github-slugger": "^1.3.0",
@@ -102,7 +101,8 @@
102
101
  "sass": "^1.79.0",
103
102
  "terminal-link": "^2.1.1",
104
103
  "typescript": "^5.6.3",
105
- "vitest": "^2.1.8"
104
+ "vitest": "^2.1.8",
105
+ "@diplodoc/infra": "2.0.1"
106
106
  },
107
107
  "peerDependencies": {
108
108
  "highlight.js": "^10.0.3 || ^11"
@@ -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(contentToken: Token, tdOpenToken: Token, log: Logger): void {
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.warn(
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: Logger): number | null {
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.warn(`Invalid table header-rows value: "${raw}"`);
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: Logger): void {
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.warn(`Unknown table cell align value: "${value}"`);
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.log);
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.log);
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.log,
847
+ opts?.log,
844
848
  );
845
849
  }
846
850