@diplodoc/yfmlint 1.6.0 → 1.7.0

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.
@@ -0,0 +1,17 @@
1
+ export declare const NOTE_OPEN_RE: RegExp;
2
+ export declare const NOTE_CLOSE_RE: RegExp;
3
+ export declare const NOTE_STRICT_RE: RegExp;
4
+ export declare const CUT_OPEN_RE: RegExp;
5
+ export declare const CUT_CLOSE_RE: RegExp;
6
+ export declare const CUT_STRICT_RE: RegExp;
7
+ export declare const TABS_OPEN_RE: RegExp;
8
+ export declare const TABS_CLOSE_RE: RegExp;
9
+ export declare const TABS_STRICT_RE: RegExp;
10
+ export declare const INCLUDE_STRICT_RE: RegExp;
11
+ export declare const CHANGELOG_OPEN_RE: RegExp;
12
+ export declare const CHANGELOG_CLOSE_RE: RegExp;
13
+ export declare const IF_OPEN_RE: RegExp;
14
+ export declare const IF_CLOSE_RE: RegExp;
15
+ export declare const FOR_OPEN_RE: RegExp;
16
+ export declare const FOR_CLOSE_RE: RegExp;
17
+ export declare function isKnownDirective(directive: string): boolean;
@@ -10,6 +10,15 @@ export interface IncludeSourceInfo {
10
10
  sourceLineNumber: number;
11
11
  includeChain: IncludeChainEntry[];
12
12
  }
13
+ export interface DirectiveMatch {
14
+ directive: string;
15
+ lineNumber: number;
16
+ line: string;
17
+ }
18
+ export interface PairedDirectiveSpec {
19
+ open: RegExp;
20
+ close: RegExp;
21
+ }
13
22
  /**
14
23
  * Validates and adjusts lineNumber to prevent markdownlint exception.
15
24
  * When include files are used, lineNumber might exceed the original file's line count.
@@ -85,3 +94,66 @@ export declare function findImagesInInlineTokens(params: RuleParams, ruleName: s
85
94
  * @returns {void}
86
95
  */
87
96
  export declare function findYfmLintTokens(params: RuleParams, ruleName: string, onError: RuleOnError, handler?: (token: TokenWithAttrs) => void): void;
97
+ /**
98
+ * Returns a set of 1-based line numbers that should be skipped during directive scanning.
99
+ * Lines inside fenced code blocks (```` ``` ```) and indented code blocks are excluded
100
+ * to prevent false positives on code examples that contain YFM syntax.
101
+ *
102
+ * @param params - Rule parameters from markdownlint
103
+ * @returns Set of line numbers (1-based) that belong to code blocks
104
+ */
105
+ export declare function getIgnoredLineNumbers(params: RuleParams): Set<number>;
106
+ /**
107
+ * Replaces inline code spans (backtick-delimited) with spaces of the same length.
108
+ * Preserves character positions so that match offsets remain accurate.
109
+ * Handles single and multi-backtick spans (e.g., `` `code` `` and ` ``code`` `).
110
+ *
111
+ * @param line - A single line of markdown text
112
+ * @returns The line with all inline code spans replaced by spaces
113
+ */
114
+ export declare function stripInlineCode(line: string): string;
115
+ /**
116
+ * Finds all YFM/Liquid directive matches (`{% ... %}`) in the document lines,
117
+ * skipping lines inside code blocks and inline code spans.
118
+ *
119
+ * @param params - Rule parameters from markdownlint
120
+ * @returns Array of directive matches with their directive content, line number, and original line text
121
+ */
122
+ export declare function findDirectiveMatches(params: RuleParams): DirectiveMatch[];
123
+ /**
124
+ * Validates that opening and closing directives are properly paired using a stack.
125
+ * Reports two types of issues:
126
+ * - Unexpected closing directive (closing without a matching opening)
127
+ * - Unclosed opening directive (opening without a matching closing)
128
+ *
129
+ * @param params - Rule parameters from markdownlint
130
+ * @param spec - Pair specification with `open` and `close` regexes tested against the directive content
131
+ * @returns Array of issues, each with a line number, context (original line), and detail message
132
+ */
133
+ export declare function findPairedDirectiveIssues(params: RuleParams, spec: PairedDirectiveSpec): Array<{
134
+ lineNumber: number;
135
+ context: string;
136
+ detail: string;
137
+ }>;
138
+ /**
139
+ * Detects interleaved (improperly nested) directives using a unified stack across all specs.
140
+ *
141
+ * Example of interleaved directives:
142
+ * {% note info %}
143
+ * {% list tabs %}
144
+ * {% endnote %} ← closes note, but tabs is still open inside
145
+ * {% endlist %}
146
+ *
147
+ * Per-spec stacks cannot detect this because each spec closes cleanly in isolation.
148
+ * This function uses a single stack for all directive types and reports when a closing
149
+ * directive skips over unclosed directives of a different type.
150
+ *
151
+ * @param params - Rule parameters from markdownlint
152
+ * @param specs - Array of paired directive specifications
153
+ * @returns Array of issues with line number, context, and detail message
154
+ */
155
+ export declare function findInterleavedDirectiveIssues(params: RuleParams, specs: PairedDirectiveSpec[]): Array<{
156
+ lineNumber: number;
157
+ context: string;
158
+ detail: string;
159
+ }>;
@@ -10,3 +10,4 @@ export { yfm009 } from './yfm009';
10
10
  export { yfm010 } from './yfm010';
11
11
  export { yfm011 } from './yfm011';
12
12
  export { yfm018 } from './yfm018';
13
+ export { yfm020 } from './yfm020';
@@ -0,0 +1,2 @@
1
+ import type { Rule } from 'markdownlint';
2
+ export declare const yfm020: Rule;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@diplodoc/yfmlint",
3
- "version": "1.6.0",
3
+ "version": "1.7.0",
4
4
  "description": "YFM (Yandex Flavored Markdown) syntax linter with custom rules for Diplodoc platform",
5
5
  "keywords": [
6
6
  "docs",