From c8df7a460da1c483a9d8c0b6dfe3d8d2e6023e69 Mon Sep 17 00:00:00 2001 From: chrox Date: Sat, 15 Jun 2013 23:09:22 +0800 Subject: [PATCH] strip punctuation characters around selected word --- frontend/ui/reader/readerdictionary.lua | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/frontend/ui/reader/readerdictionary.lua b/frontend/ui/reader/readerdictionary.lua index e6f719f21..2c0dd74ce 100644 --- a/frontend/ui/reader/readerdictionary.lua +++ b/frontend/ui/reader/readerdictionary.lua @@ -39,6 +39,10 @@ end function ReaderDictionary:stardictLookup(word) DEBUG("lookup word:", word) if word then + -- strip punctuation characters around selected word + word = string.gsub(word, "^%p+", '') + word = string.gsub(word, "%p+$", '') + DEBUG("stripped word:", word) -- escape quotes and other funny characters in word local std_out = io.popen("./sdcv -nj "..("%q"):format(word), "r") local results_str = std_out:read("*all") @@ -67,6 +71,7 @@ function ReaderDictionary:showDict(result) -- }) if result then UIManager:show(DictQuickLookup:new{ + ui = self.ui, dict = result.dict, definition = result.definition, id = result.ID,