diff --git a/addons/fastwq/service/base.py b/addons/fastwq/service/base.py index 56f538d..8390324 100644 --- a/addons/fastwq/service/base.py +++ b/addons/fastwq/service/base.py @@ -628,16 +628,16 @@ class MdxService(LocalService): def _get_default_html(self): html = u'' - result = self.builder.mdx_lookup(self.word, ignorecase=config.ignore_mdx_wordcase) # self.word: unicode + result = self.get_html() if result: - if result[0].upper().find(u"@@@LINK=") > -1: + if result.upper().find(u"@@@LINK=") > -1: # redirect to a new word behind the equal symol. - word = result[0][len(u"@@@LINK="):].strip() + word = result[len(u"@@@LINK="):].strip() if not word.upper() in self.word_links: self.word_links.append(word.upper()) self.word = word return self._get_default_html() - html = self.adapt_to_anki(result[0]) + html = self.adapt_to_anki(result) self.cache[self.word] = html return self.cache[self.word] diff --git a/addons/fastwq/service/dict/LDOCE6.py b/addons/fastwq/service/dict/LDOCE6.py index ebe92ce..9f4bf1b 100644 --- a/addons/fastwq/service/dict/LDOCE6.py +++ b/addons/fastwq/service/dict/LDOCE6.py @@ -171,6 +171,19 @@ class Ldoce6(MdxService): return self._css(my_str) return '' + @export([u'额外例句', u'Extra Examples']) + def fld_extra_examples(self): + lst = re.findall(r'href="/(@examples_.*?)\">.*?<', self.get_html()) + if lst: + str_content = u'' + for m in lst: + content = self.builder.mdx_lookup(m) + if len(content) > 0: + for c in content: + str_content += c.replace("\r\n","").replace("entry:/","") + return self._css(str_content) + return '' + @with_styles(cssfile='_ldoce6.css') def _css(self, val): return val diff --git a/addons21/fastwq/service/base.py b/addons21/fastwq/service/base.py index 2361352..e593308 100644 --- a/addons21/fastwq/service/base.py +++ b/addons21/fastwq/service/base.py @@ -635,16 +635,16 @@ class MdxService(LocalService): def _get_default_html(self): html = u'' - result = self.builder.mdx_lookup(self.word, ignorecase=config.ignore_mdx_wordcase) # self.word: unicode + result = self.get_html() if result: - if result[0].upper().find(u"@@@LINK=") > -1: + if result.upper().find(u"@@@LINK=") > -1: # redirect to a new word behind the equal symol. - word = result[0][len(u"@@@LINK="):].strip() + word = result[len(u"@@@LINK="):].strip() if not word.upper() in self.word_links: self.word_links.append(word.upper()) self.word = word return self._get_default_html() - html = self.adapt_to_anki(result[0]) + html = self.adapt_to_anki(result) self.cache[self.word] = html return self.cache[self.word] diff --git a/addons21/fastwq/service/dict/LDOCE6.py b/addons21/fastwq/service/dict/LDOCE6.py index c55bd18..a59578a 100644 --- a/addons21/fastwq/service/dict/LDOCE6.py +++ b/addons21/fastwq/service/dict/LDOCE6.py @@ -171,6 +171,19 @@ class Ldoce6(MdxService): return self._css(my_str) return '' + @export([u'额外例句', u'Extra Examples']) + def fld_extra_examples(self): + lst = re.findall(r'href="/(@examples_.*?)\">.*?<', self.get_html()) + if lst: + str_content = u'' + for m in lst: + content = self.builder.mdx_lookup(m) + if len(content) > 0: + for c in content: + str_content += c.replace("\r\n","").replace("entry:/","") + return self._css(str_content) + return '' + @with_styles(cssfile='_ldoce6.css') def _css(self, val): return val