build(types): web_sanitize minimal definition
ci/woodpecker/push/lint Pipeline was successful Details
ci/woodpecker/pr/lint Pipeline was successful Details
ci/woodpecker/push/build Pipeline failed Details
ci/woodpecker/pr/build Pipeline failed Details

This commit is contained in:
Aire-One 2022-09-29 20:05:11 +02:00
parent 90c2aa4bc2
commit 1b7be87040
2 changed files with 39 additions and 0 deletions

16
types/web_sanitize.d.tl Normal file
View File

@ -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

View File

@ -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