-
Notifications
You must be signed in to change notification settings - Fork 114
Expand file tree
/
Copy pathnormalizer.lua
More file actions
43 lines (40 loc) · 1.58 KB
/
Copy pathnormalizer.lua
File metadata and controls
43 lines (40 loc) · 1.58 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
local Normalizer = require("leetcode.parser.normalizer")
local u = require("leetcode.parser.utils")
function Normalizer:cleanup()
self.text = self
.text --
:gsub("", "")
:gsub("\r\n", "\n")
:gsub("<br%s*/>", "\n")
:gsub("<meta[^>]*/>", "")
:gsub(" ", " ")
:gsub("<([^/%a!])", "<%1")
:gsub("<(/?)b>", "<%1strong>")
:gsub(":", ":")
end
-- :gsub("<strong>(提示:%s*)</strong>", "<followup>%1</followup>") -- Note
function Normalizer:tags() --
self.text = self
.text --
:gsub("<strong>(输入:?%s*)</strong>", "<input>%1</input>") -- input
:gsub("<strong>(输出:?%s*)</strong>", "<output>%1</output>") -- output
:gsub("<strong>(解释:?%s*)</strong>", "<explanation>%1</explanation>") -- explanation
:gsub("<strong>(进阶:?%s*)</strong>", "<followup>%1</followup>") -- Note
:gsub("<strong>(注意:?%s*)</strong>", "<followup>%1</followup>") -- Followup
:gsub(
"\n*<p>%s*<strong[^>]*>(示例%s*%d*:?)%s*</strong>%s*</p>\n*",
"\n\n<example> %1</example>\n\n"
)
:gsub(
"\n*<p>%s*<strong[^>]*>(提示:?%s*)</strong>%s*</p>\n*",
"\n\n<constraints> %1</constraints>\n\n"
)
:gsub(
"\n*<p>%s*<strong[^>]*>(限制:?%s*)</strong>%s*</p>\n*",
"\n\n<constraints> %1</constraints>\n\n"
)
:gsub(
"\n*<p>%s*<strong[^>]*>(提示:?%s*)</strong>%s*</p>\n*",
"\n\n<constraints> %1</constraints>\n\n"
)
end