@takazudo/mdx-formatter 0.1.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.
- package/LICENSE +21 -0
- package/README.md +72 -0
- package/dist/cli.d.ts +2 -0
- package/dist/cli.js +128 -0
- package/dist/html-block-formatter.d.ts +46 -0
- package/dist/html-block-formatter.js +370 -0
- package/dist/hybrid-formatter.d.ts +59 -0
- package/dist/hybrid-formatter.js +977 -0
- package/dist/indent-detector.d.ts +62 -0
- package/dist/indent-detector.js +358 -0
- package/dist/index.d.ts +28 -0
- package/dist/index.js +57 -0
- package/dist/load-config.d.ts +13 -0
- package/dist/load-config.js +71 -0
- package/dist/plugins/docusaurus-admonitions.d.ts +5 -0
- package/dist/plugins/docusaurus-admonitions.js +42 -0
- package/dist/plugins/fix-autolink-output.d.ts +4 -0
- package/dist/plugins/fix-autolink-output.js +24 -0
- package/dist/plugins/fix-formatting-issues.d.ts +4 -0
- package/dist/plugins/fix-formatting-issues.js +42 -0
- package/dist/plugins/fix-paragraph-spacing.d.ts +5 -0
- package/dist/plugins/fix-paragraph-spacing.js +96 -0
- package/dist/plugins/html-definition-list.d.ts +5 -0
- package/dist/plugins/html-definition-list.js +64 -0
- package/dist/plugins/japanese-text.d.ts +5 -0
- package/dist/plugins/japanese-text.js +79 -0
- package/dist/plugins/normalize-lists.d.ts +5 -0
- package/dist/plugins/normalize-lists.js +58 -0
- package/dist/plugins/preprocess-japanese.d.ts +7 -0
- package/dist/plugins/preprocess-japanese.js +15 -0
- package/dist/plugins/preserve-image-alt.d.ts +8 -0
- package/dist/plugins/preserve-image-alt.js +19 -0
- package/dist/plugins/preserve-jsx.d.ts +6 -0
- package/dist/plugins/preserve-jsx.js +48 -0
- package/dist/settings.d.ts +7 -0
- package/dist/settings.js +91 -0
- package/dist/specific-formatter.d.ts +30 -0
- package/dist/specific-formatter.js +469 -0
- package/dist/types.d.ts +226 -0
- package/dist/types.js +4 -0
- package/dist/utils.d.ts +12 -0
- package/dist/utils.js +47 -0
- package/format-stdin.js +36 -0
- package/package.json +107 -0
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* HybridFormatter - Uses AST analysis to apply targeted fixes
|
|
3
|
+
* This implements the proper hybrid approach from the plan
|
|
4
|
+
*/
|
|
5
|
+
import type { FormatterSettings, FormatterOperation, PositionMapEntry, MdxJsxElement, MdxJsxAttribute, MdxJsxAttributeValueExpression, Root } from './types.js';
|
|
6
|
+
export declare class HybridFormatter {
|
|
7
|
+
private readonly originalContent;
|
|
8
|
+
private content;
|
|
9
|
+
private lines;
|
|
10
|
+
settings: FormatterSettings;
|
|
11
|
+
private ast;
|
|
12
|
+
private positionMap;
|
|
13
|
+
private indentDetector;
|
|
14
|
+
constructor(content: string, settings?: FormatterSettings | null);
|
|
15
|
+
parseAST(content: string): Root;
|
|
16
|
+
fixStandaloneClosingTags(content: string): string;
|
|
17
|
+
buildPositionMap(): PositionMapEntry[];
|
|
18
|
+
/**
|
|
19
|
+
* Detect indentation from content and update formatter settings
|
|
20
|
+
*/
|
|
21
|
+
detectAndApplyIndentation(): void;
|
|
22
|
+
/**
|
|
23
|
+
* Apply indentation settings consistently across all formatters
|
|
24
|
+
*/
|
|
25
|
+
applyIndentationToSettings(size: number, type: string): void;
|
|
26
|
+
format(): Promise<string>;
|
|
27
|
+
collectSpacingOperations(operations: FormatterOperation[]): void;
|
|
28
|
+
collectListIndentationOperations(operations: FormatterOperation[]): void;
|
|
29
|
+
collectJsxFormatOperations(operations: FormatterOperation[]): void;
|
|
30
|
+
needsJsxFormatting(node: MdxJsxElement, originalText: string): boolean;
|
|
31
|
+
formatJsxElement(node: MdxJsxElement, originalText: string): string;
|
|
32
|
+
getAttributeString(attr: MdxJsxAttribute, originalText: string): string;
|
|
33
|
+
extractAttributeExpression(attrName: string, originalText: string): string | null;
|
|
34
|
+
extractExpressionValue(expr: MdxJsxAttributeValueExpression): string;
|
|
35
|
+
extractNodeText(position: {
|
|
36
|
+
start: {
|
|
37
|
+
line: number;
|
|
38
|
+
column: number;
|
|
39
|
+
};
|
|
40
|
+
end: {
|
|
41
|
+
line: number;
|
|
42
|
+
column: number;
|
|
43
|
+
};
|
|
44
|
+
}): string;
|
|
45
|
+
extractChildrenText(node: MdxJsxElement, originalText: string): string;
|
|
46
|
+
/**
|
|
47
|
+
* Collect HTML block formatting operations using HtmlBlockFormatter
|
|
48
|
+
*/
|
|
49
|
+
collectHtmlBlockOperations(operations: FormatterOperation[]): Promise<void>;
|
|
50
|
+
/**
|
|
51
|
+
* Extract HTML content from an AST node
|
|
52
|
+
*/
|
|
53
|
+
extractHtmlFromNode(node: MdxJsxElement): string | null;
|
|
54
|
+
collectJsxIndentOperations(operations: FormatterOperation[]): void;
|
|
55
|
+
collectBlockJsxEmptyLineOperations(operations: FormatterOperation[]): void;
|
|
56
|
+
collectYamlFormatOperations(operations: FormatterOperation[]): void;
|
|
57
|
+
getLineAtPosition(charPos: number): number;
|
|
58
|
+
applyOperation(lines: string[], op: FormatterOperation): void;
|
|
59
|
+
}
|