A Neovim plugin enabling you to solve LeetCode problems.
| 1 | local Normalizer = require("leetcode.parser.normalizer") |
| 2 | local u = require("leetcode.parser.utils") |
| 3 | |
| 4 | |
| 5 | self.text = self |
| 6 | .text -- |
| 7 | :gsub("", "") |
| 8 | :gsub("\r\n", "\n") |
| 9 | :gsub("<br%s*/>", "\n") |
| 10 | :gsub("<meta[^>]*/>", "") |
| 11 | :gsub(" ", " ") |
| 12 | :gsub("<(/?)b>", "<%1strong>") |
| 13 | :gsub(":", ":") |
| 14 | end |
| 15 | |
| 16 | -- :gsub("<strong>(提示:%s*)</strong>", "<followup>%1</followup>") -- Note |
| 17 | |
| 18 | -- |
| 19 | self.text = self |
| 20 | .text -- |
| 21 | :gsub("<strong>(输入:?%s*)</strong>", "<input>%1</input>") -- input |
| 22 | :gsub("<strong>(输出:?%s*)</strong>", "<output>%1</output>") -- output |
| 23 | :gsub("<strong>(解释:?%s*)</strong>", "<explanation>%1</explanation>") -- explanation |
| 24 | :gsub("<strong>(进阶:?%s*)</strong>", "<followup>%1</followup>") -- Note |
| 25 | :gsub("<strong>(注意:?%s*)</strong>", "<followup>%1</followup>") -- Followup |
| 26 | :gsub( |
| 27 | "\n*<p>%s*<strong[^>]*>(示例%s*%d*:?)%s*</strong>%s*</p>\n*", |
| 28 | "\n\n<example> %1</example>\n\n" |
| 29 | ) |
| 30 | :gsub( |
| 31 | "\n*<p>%s*<strong[^>]*>(提示:?%s*)</strong>%s*</p>\n*", |
| 32 | "\n\n<constraints> %1</constraints>\n\n" |
| 33 | ) |
| 34 | :gsub( |
| 35 | "\n*<p>%s*<strong[^>]*>(限制:?%s*)</strong>%s*</p>\n*", |
| 36 | "\n\n<constraints> %1</constraints>\n\n" |
| 37 | ) |
| 38 | :gsub( |
| 39 | "\n*<p>%s*<strong[^>]*>(提示:?%s*)</strong>%s*</p>\n*", |
| 40 | "\n\n<constraints> %1</constraints>\n\n" |
| 41 | ) |
| 42 | end |