Refactor Htmlparser2 plugin (#869)

* refactor (not work)

* fix: Hako parseNovel

* update Hako version

* Handler interface

* refactor: repo name
This commit is contained in:
nyagami
2024-04-04 22:29:44 +07:00
committed by GitHub
parent 3ce32096f2
commit 71bdd196dc
6 changed files with 320 additions and 155 deletions
+20
View File
@@ -108,3 +108,23 @@ export namespace Plugin {
parsePage(novelPath: string, page: string): Promise<SourcePage>;
}
}
export namespace HTMLParser2Util {
interface HandlerBase {
onopentag?(name: string, attribs: { [s: string]: string }): void;
ontext?(data: string): void;
onclosetag?(name: string, isImplied: boolean): void;
}
export interface Handler extends HandlerBase {
isStarted?: boolean;
isDone?: boolean;
}
// route htmlparser2 event to handlers
export interface HandlerRouter<ActionType extends string>
extends HandlerBase {
handlers: Record<ActionType, Handler | undefined>;
action: ActionType;
}
}