Skip to content

Commit 60990a8

Browse files
Ron RadtkeRon Radtke
Ron Radtke
authored and
Ron Radtke
committed
adding sourceinfo and sourceMeta to ASTNode
1 parent 50856ad commit 60990a8

File tree

1 file changed

+55
-48
lines changed

1 file changed

+55
-48
lines changed

src/index.d.ts

Lines changed: 55 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -5,90 +5,97 @@ import {ComponentType, ReactNode} from 'react';
55
import {StyleSheet, View} from 'react-native';
66

77
export function getUniqueID(): string;
8+
89
export function openUrl(url: string): void;
910

1011
export function hasParents(parents: any[], type: string): boolean;
1112

1213
export type RenderFunction = (
13-
node: ASTNode,
14-
children: ReactNode[],
15-
parentNodes: ASTNode[],
16-
styles: any,
17-
styleObj?: any,
18-
// must have this so that we can have fixed overrides with more arguments
19-
...args: any
14+
node: ASTNode,
15+
children: ReactNode[],
16+
parentNodes: ASTNode[],
17+
styles: any,
18+
styleObj?: any,
19+
// must have this so that we can have fixed overrides with more arguments
20+
...args: any
2021
) => ReactNode;
2122

2223
export type RenderLinkFunction = (
23-
node: ASTNode,
24-
children: ReactNode[],
25-
parentNodes: ASTNode[],
26-
styles: any,
27-
onLinkPress?: (url: string) => boolean,
24+
node: ASTNode,
25+
children: ReactNode[],
26+
parentNodes: ASTNode[],
27+
styles: any,
28+
onLinkPress?: (url: string) => boolean,
2829
) => ReactNode;
2930

3031
export type RenderImageFunction = (
31-
node: ASTNode,
32-
children: ReactNode[],
33-
parentNodes: ASTNode[],
34-
styles: any,
35-
allowedImageHandlers: string[],
36-
defaultImageHandler: string,
32+
node: ASTNode,
33+
children: ReactNode[],
34+
parentNodes: ASTNode[],
35+
styles: any,
36+
allowedImageHandlers: string[],
37+
defaultImageHandler: string,
3738
) => ReactNode;
3839

3940
export interface RenderRules {
40-
[name: string]: RenderFunction | undefined;
41-
link?: RenderLinkFunction;
42-
blocklink?: RenderLinkFunction;
43-
image?: RenderImageFunction;
41+
[name: string]: RenderFunction | undefined;
42+
43+
link?: RenderLinkFunction;
44+
blocklink?: RenderLinkFunction;
45+
image?: RenderImageFunction;
4446
}
4547

4648
export const renderRules: RenderRules;
4749

4850
export interface MarkdownParser {
49-
parse: (value: string, options: any) => Token[];
51+
parse: (value: string, options: any) => Token[];
5052
}
5153

5254
export interface ASTNode {
53-
type: string;
54-
sourceType: string; // original source token name
55-
key: string;
56-
content: string;
57-
markup: string;
58-
tokenIndex: number;
59-
index: number;
60-
attributes: Record<string, any>;
61-
children: ASTNode[];
55+
type: string;
56+
sourceType: string; // original source token name
57+
sourceInfo: string;
58+
sourceMeta: any;
59+
key: string;
60+
content: string;
61+
markup: string;
62+
tokenIndex: number;
63+
index: number;
64+
attributes: Record<string, any>;
65+
children: ASTNode[];
6266
}
6367

6468
export class AstRenderer {
65-
constructor(renderRules: RenderRules, style?: any);
66-
getRenderFunction(type: string): RenderFunction;
67-
renderNode(node: any, parentNodes: ReadonlyArray<any>): ReactNode;
68-
render(nodes: ReadonlyArray<any>): View;
69+
constructor(renderRules: RenderRules, style?: any);
70+
71+
getRenderFunction(type: string): RenderFunction;
72+
73+
renderNode(node: any, parentNodes: ReadonlyArray<any>): ReactNode;
74+
75+
render(nodes: ReadonlyArray<any>): View;
6976
}
7077

7178
export function parser(
72-
source: string,
73-
renderer: (node: ASTNode) => View,
74-
parser: MarkdownParser,
79+
source: string,
80+
renderer: (node: ASTNode) => View,
81+
parser: MarkdownParser,
7582
): any;
7683

7784
export function stringToTokens(
78-
source: string,
79-
markdownIt: MarkdownParser,
85+
source: string,
86+
markdownIt: MarkdownParser,
8087
): Token[];
8188

8289
export function tokensToAST(tokens: ReadonlyArray<Token>): ASTNode[];
8390

8491
export interface MarkdownProps {
85-
rules?: RenderRules;
86-
style?: StyleSheet.NamedStyles<any>;
87-
renderer?: AstRenderer;
88-
markdownit?: MarkdownIt;
89-
mergeStyle?: boolean;
90-
debugPrintTree?: boolean;
91-
onLinkPress?: (url: string) => boolean;
92+
rules?: RenderRules;
93+
style?: StyleSheet.NamedStyles<any>;
94+
renderer?: AstRenderer;
95+
markdownit?: MarkdownIt;
96+
mergeStyle?: boolean;
97+
debugPrintTree?: boolean;
98+
onLinkPress?: (url: string) => boolean;
9299
}
93100

94101
type MarkdownStatic = ComponentType<MarkdownProps>;

0 commit comments

Comments
 (0)