A Neovim plugin enabling you to solve LeetCode problems.
| 1 | local Group = require("leetcode-ui.group") |
| 2 | local Tag = require("leetcode-ui.group.tag") |
| 3 | local Line = require("leetcode-ui.line") |
| 4 | local u = require("leetcode.parser.utils") |
| 5 | |
| 6 | ---@class lc.Parser.Plain : lc.ui.Group |
| 7 | ---@field text string |
| 8 | local Plain = Group:extend("LeetParserPlain") |
| 9 | |
| 10 | |
| 11 | return text:gsub("<[^>]+>", "") |
| 12 | end |
| 13 | |
| 14 | ---@param text string |
| 15 | |
| 16 | Plain.super.init(self) |
| 17 | |
| 18 | for s in vim.gsplit(Plain.normalize(text), "\n") do |
| 19 | s = s:gsub("&[%a%d#]+;", u.entity) |
| 20 | self:append(s) |
| 21 | self:endl() |
| 22 | end |
| 23 | end |
| 24 | |
| 25 | ---@type fun(text: string) |
| 26 | local LeetParserPlain = Plain |
| 27 | |
| 28 | ---@param text string |
| 29 | |
| 30 | return LeetParserPlain(text) |
| 31 | end |
| 32 | |
| 33 | return LeetParserPlain |