From 1b7be87040552ed73017efcf3ee658c8192d38f0 Mon Sep 17 00:00:00 2001 From: Aire-One Date: Thu, 29 Sep 2022 20:05:11 +0200 Subject: [PATCH] build(types): web_sanitize minimal definition --- types/web_sanitize.d.tl | 16 ++++++++++++++++ types/web_sanitize/query/scan_html.d.tl | 23 +++++++++++++++++++++++ 2 files changed, 39 insertions(+) create mode 100644 types/web_sanitize.d.tl create mode 100644 types/web_sanitize/query/scan_html.d.tl diff --git a/types/web_sanitize.d.tl b/types/web_sanitize.d.tl new file mode 100644 index 0000000..f94455f --- /dev/null +++ b/types/web_sanitize.d.tl @@ -0,0 +1,16 @@ +local record Web_Sanitize + sanitize_html: function(unsafe_html: string): string + extract_text: function(unsafe_html: string): string + sanitize_style: function(unsafe_style_attributes: string): string + + record whitelist + clone: function(): whitelist + tags: table + add_attributes: table + self_closing: table + end + + Sanitizer: function(parameters: table): function(unsafe_html: string): string +end + +return Web_Sanitize diff --git a/types/web_sanitize/query/scan_html.d.tl b/types/web_sanitize/query/scan_html.d.tl new file mode 100644 index 0000000..a9f886b --- /dev/null +++ b/types/web_sanitize/query/scan_html.d.tl @@ -0,0 +1,23 @@ +local record Scanner + record HTMLNode + tag: string + type: string | nil + num: number + self_closing: boolean | nil + attr: table + outer_html: function(self: HTMLNode): string + inner_html: function(self: HTMLNode): string + inner_text: function(self: HTMLNode): string + -- TODO : add replacement methods + end + + record NodeStack + -- stack[n] - get the nth item in the stack (as an HTMLNode) + current: function(self: NodeStack): HTMLNode + is: function(query: string): boolean + end + + scan_html: function(html_text: string, callback: function(stack: NodeStack), opts: table) +end + +return Scanner