v1 checkpoint
This commit is the initial checkpoint for a functioning converter with all tests passing.
This commit is contained in:
1 parent
158c71bce6
commit
965fc09d99
58 files changed
+2921
-3224
No files matched your search
Vendored
+41
@@ -0,0 +1,41 @@
|
||||
export type TokenRole = 'open' | 'close' | 'block';
|
||||
export interface Token {
|
||||
role: TokenRole;
|
||||
value: string;
|
||||
sequence?: string;
|
||||
tag?: TagType;
|
||||
groups?: {
|
||||
[key: string]: string;
|
||||
};
|
||||
/** For link tokens: the href and optional title. */
|
||||
href?: string;
|
||||
title?: string;
|
||||
meta?: Record<string, string>;
|
||||
}
|
||||
/**
|
||||
* A Tag is the core abstraction: it knows how to match markdown syntax,
|
||||
* convert it to HTML, and convert the HTML back to markdown. Tags are
|
||||
* registered by HTML selector (e.g. 'STRONG,B') so the converter can
|
||||
* look them up during HTML→markdown conversion.
|
||||
*/
|
||||
export interface TagType {
|
||||
element: string[];
|
||||
opener: string[];
|
||||
closer: string | null;
|
||||
precedence: number;
|
||||
isBlock: boolean;
|
||||
template?: string;
|
||||
pattern?: RegExp | null;
|
||||
showDelimitersInEditorNodes?: boolean;
|
||||
aliases?: string[];
|
||||
tokenize(role: TokenRole, sequence: string, value: string): Token | null;
|
||||
toHTML: (token: Token, callback: Function) => string;
|
||||
toMarkdown: (element: HTMLElement, callback: Function) => string;
|
||||
toEditorNode: (token: Token, callback: Function) => Node | null;
|
||||
}
|
||||
export interface TagCollectionType {
|
||||
tags: Record<string, TagType>;
|
||||
ordered: TagType[];
|
||||
map: Map<string, TagType[]>;
|
||||
getByElementName(element: string): TagType | undefined;
|
||||
}
|
||||
Reference in new issue
Block a user