@diplodoc/yfmlint 1.2.8 → 1.3.1

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/build/config.d.ts CHANGED
@@ -14,5 +14,6 @@ declare const _default: {
14
14
  YFM008: LogLevels;
15
15
  YFM009: LogLevels;
16
16
  YFM010: LogLevels;
17
+ YFM011: LogLevels;
17
18
  };
18
19
  export default _default;
package/build/index.js CHANGED
@@ -21442,8 +21442,10 @@ var config_default = {
21442
21442
  // Term inside definition not allowed
21443
21443
  YFM009: "warn" /* WARN */,
21444
21444
  // Term definition used not at the end of file
21445
- YFM010: "warn" /* WARN */
21445
+ YFM010: "warn" /* WARN */,
21446
21446
  // Autotitle anchor is missed
21447
+ YFM011: "warn" /* WARN */
21448
+ // Max svg size
21447
21449
  };
21448
21450
 
21449
21451
  // src/rules/index.ts
@@ -21458,7 +21460,8 @@ __export(rules_exports, {
21458
21460
  yfm007: () => yfm007,
21459
21461
  yfm008: () => yfm008,
21460
21462
  yfm009: () => yfm009,
21461
- yfm010: () => yfm010
21463
+ yfm010: () => yfm010,
21464
+ yfm011: () => yfm011
21462
21465
  });
21463
21466
 
21464
21467
  // src/rules/yfm001.ts
@@ -21582,6 +21585,11 @@ var yfm002 = {
21582
21585
  };
21583
21586
 
21584
21587
  // src/rules/yfm003.ts
21588
+ var REASON_DESCRIPTION = {
21589
+ "file-not-found": "File does not exist in the project",
21590
+ "missing-in-toc": "File exists but is not declared in toc",
21591
+ "missing-in-toc-and-file-not-found": "File does not exist and is not declared in toc"
21592
+ };
21585
21593
  var yfm003 = {
21586
21594
  names: ["YFM003", "unreachable-link"],
21587
21595
  description: "Link is unreachable",
@@ -21599,11 +21607,18 @@ var yfm003 = {
21599
21607
  (_a = inline.children) == null ? void 0 : _a.filter((child) => {
21600
21608
  return child.type === "link_open";
21601
21609
  }).forEach((link) => {
21602
- if (link.attrGet("YFM003")) {
21603
- const linkHrefError = `[Unreachable link: "${link.attrGet("href")}"]`;
21610
+ const linkToken = link;
21611
+ const reason = linkToken.attrGet("YFM003");
21612
+ if (reason) {
21613
+ const reasonDescription = typeof reason === "string" && REASON_DESCRIPTION[reason] ? `Reason: ${REASON_DESCRIPTION[reason]}` : "";
21614
+ const context = [
21615
+ `Unreachable link: "${linkToken.attrGet("href")}"`,
21616
+ reasonDescription,
21617
+ `Line: ${link.line}`
21618
+ ].filter(Boolean).join("; ");
21604
21619
  onError({
21605
21620
  lineNumber: link.lineNumber,
21606
- context: linkHrefError + link.line
21621
+ context
21607
21622
  });
21608
21623
  }
21609
21624
  });
@@ -21813,6 +21828,36 @@ var yfm010 = {
21813
21828
  }
21814
21829
  };
21815
21830
 
21831
+ // src/rules/yfm011.ts
21832
+ var yfm011 = {
21833
+ names: ["YFM011", "max-svg-size"],
21834
+ description: "Max svg size",
21835
+ tags: ["image_svg"],
21836
+ parser: "markdownit",
21837
+ function: function YFM011(params2, onError) {
21838
+ const { config } = params2;
21839
+ if (!config) {
21840
+ return;
21841
+ }
21842
+ params2.parsers.markdownit.tokens.filter((token) => {
21843
+ return token.type === "inline";
21844
+ }).forEach((inline) => {
21845
+ var _a;
21846
+ (_a = inline.children) == null ? void 0 : _a.filter((child) => {
21847
+ return child.type === "image";
21848
+ }).forEach((link) => {
21849
+ if (link.attrGet("YFM011")) {
21850
+ const svgSizeError = link.attrGet("YFM011");
21851
+ onError({
21852
+ lineNumber: link.lineNumber,
21853
+ context: svgSizeError + " " + link.line
21854
+ });
21855
+ }
21856
+ });
21857
+ });
21858
+ }
21859
+ };
21860
+
21816
21861
  // src/index.ts
21817
21862
  async function yfmlint(content3, path3, opts) {
21818
21863
  const { lint } = await Promise.resolve().then(() => (init_exports_promise(), exports_promise_exports));