-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
support escape chars `\n`, `\t`, and `\\`
- Loading branch information
1 parent
0b458a7
commit 717c2a6
Showing
5 changed files
with
34 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
--[[ | ||
Unicode Translator | ||
Copyright (C) 2024 Xuesong Peng <[email protected]> | ||
This program is free software: you can redistribute it and/or modify | ||
it under the terms of the GNU Affero General Public License as published | ||
by the Free Software Foundation, either version 3 of the License, or | ||
(at your option) any later version. | ||
This program is distributed in the hope that it will be useful, | ||
but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
GNU Affero General Public License for more details. | ||
You should have received a copy of the GNU Affero General Public License | ||
along with this program. If not, see <https://www.gnu.org/licenses/>. | ||
--]] | ||
|
||
local function filter(input) | ||
for cand in input:iter() do | ||
local text = string.gsub(cand.text, "\\n", "\n") | ||
text = string.gsub(text, "\\t", "\t") | ||
text = string.gsub(text, "\\\\", "\\") | ||
local comment = cand:get_genuine().comment | ||
yield(Candidate(cand.type, cand._start, cand._end, text, comment)) | ||
end | ||
end | ||
|
||
return filter |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
--[[ | ||
Hint Filter | ||
Copyright (C) 2020 Rea <[email protected]> | ||
Copyright (C) 2021, 2023 Xuesong Peng <[email protected]> | ||
Copyright (C) 2021, 2023 - 2024 Xuesong Peng <[email protected]> | ||
This program is free software: you can redistribute it and/or modify | ||
it under the terms of the GNU Affero General Public License as published | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
--[[ | ||
Unicode Translator | ||
Copyright (C) 2023 Xuesong Peng <[email protected]> | ||
Copyright (C) 2023 - 2024 Xuesong Peng <[email protected]> | ||
This program is free software: you can redistribute it and/or modify | ||
it under the terms of the GNU Affero General Public License as published | ||
|
@@ -17,17 +17,12 @@ | |
--]] | ||
|
||
local function translator(input, seg) | ||
local is_win = package.config:sub(1,1) == "\\" | ||
local delimiter = string.find(input, "u`") | ||
if delimiter ~= nil then | ||
local input_code = string.sub(input, delimiter + 2) | ||
local codepoint = tonumber(input_code, 16) | ||
if codepoint ~= nil then | ||
local ch = utf8.char(codepoint) | ||
-- to prevent software crashing on Windows | ||
if is_win and codepoint == 10 then | ||
ch = "LF" | ||
end | ||
local cand = Candidate("unicode", seg.start, seg._end, ch, " Unicode") | ||
-- input_code = string.format("%04s", input_code) | ||
-- string.format not working in Hamster | ||
|