add extra examples field to LDOCE6
This commit is contained in:
parent
f27e460efc
commit
a95dc6af2b
@ -628,16 +628,16 @@ class MdxService(LocalService):
|
|||||||
|
|
||||||
def _get_default_html(self):
|
def _get_default_html(self):
|
||||||
html = u''
|
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:
|
||||||
if result[0].upper().find(u"@@@LINK=") > -1:
|
if result.upper().find(u"@@@LINK=") > -1:
|
||||||
# redirect to a new word behind the equal symol.
|
# 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:
|
if not word.upper() in self.word_links:
|
||||||
self.word_links.append(word.upper())
|
self.word_links.append(word.upper())
|
||||||
self.word = word
|
self.word = word
|
||||||
return self._get_default_html()
|
return self._get_default_html()
|
||||||
html = self.adapt_to_anki(result[0])
|
html = self.adapt_to_anki(result)
|
||||||
self.cache[self.word] = html
|
self.cache[self.word] = html
|
||||||
return self.cache[self.word]
|
return self.cache[self.word]
|
||||||
|
|
||||||
|
|||||||
@ -171,6 +171,19 @@ class Ldoce6(MdxService):
|
|||||||
return self._css(my_str)
|
return self._css(my_str)
|
||||||
return ''
|
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')
|
@with_styles(cssfile='_ldoce6.css')
|
||||||
def _css(self, val):
|
def _css(self, val):
|
||||||
return val
|
return val
|
||||||
|
|||||||
@ -635,16 +635,16 @@ class MdxService(LocalService):
|
|||||||
|
|
||||||
def _get_default_html(self):
|
def _get_default_html(self):
|
||||||
html = u''
|
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:
|
||||||
if result[0].upper().find(u"@@@LINK=") > -1:
|
if result.upper().find(u"@@@LINK=") > -1:
|
||||||
# redirect to a new word behind the equal symol.
|
# 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:
|
if not word.upper() in self.word_links:
|
||||||
self.word_links.append(word.upper())
|
self.word_links.append(word.upper())
|
||||||
self.word = word
|
self.word = word
|
||||||
return self._get_default_html()
|
return self._get_default_html()
|
||||||
html = self.adapt_to_anki(result[0])
|
html = self.adapt_to_anki(result)
|
||||||
self.cache[self.word] = html
|
self.cache[self.word] = html
|
||||||
return self.cache[self.word]
|
return self.cache[self.word]
|
||||||
|
|
||||||
|
|||||||
@ -171,6 +171,19 @@ class Ldoce6(MdxService):
|
|||||||
return self._css(my_str)
|
return self._css(my_str)
|
||||||
return ''
|
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')
|
@with_styles(cssfile='_ldoce6.css')
|
||||||
def _css(self, val):
|
def _css(self, val):
|
||||||
return val
|
return val
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user