mirror of
https://github.com/koreader/koreader.git
synced 2025-08-10 00:52:38 +00:00
@@ -59,9 +59,7 @@ end
|
||||
function ReaderDictionary:stardictLookup(word, box)
|
||||
DEBUG("lookup word:", word, box)
|
||||
if word then
|
||||
-- strip ASCII punctuation characters around selected word
|
||||
-- and strip any generic punctuation (U+2000 - U+206F) in the word
|
||||
word = word:gsub("\226[\128-\131][\128-\191]",''):gsub("^%p+",''):gsub("%p+$",'')
|
||||
word = require("util").stripePunctuations(word)
|
||||
DEBUG("stripped word:", word)
|
||||
-- escape quotes and other funny characters in word
|
||||
local std_out = io.popen("./sdcv --utf8-input --utf8-output -nj "..("%q"):format(word), "r")
|
||||
|
||||
@@ -29,6 +29,7 @@ function ReaderSearch:addToMainMenu(tab_item_table)
|
||||
end
|
||||
|
||||
function ReaderSearch:onShowSearchDialog(text)
|
||||
text = require("util").stripePunctuations(text)
|
||||
local do_search = function(search_func, text, param)
|
||||
return function()
|
||||
local res = search_func(self, text, param)
|
||||
|
||||
11
frontend/util.lua
Normal file
11
frontend/util.lua
Normal file
@@ -0,0 +1,11 @@
|
||||
|
||||
local util = {}
|
||||
|
||||
function util.stripePunctuations(word)
|
||||
if not word then return end
|
||||
-- strip ASCII punctuation characters around word
|
||||
-- and strip any generic punctuation (U+2000 - U+206F) in the word
|
||||
return word:gsub("\226[\128-\131][\128-\191]",''):gsub("^%p+",''):gsub("%p+$",'')
|
||||
end
|
||||
|
||||
return util
|
||||
Reference in New Issue
Block a user