Switching way markup fields are formatted for cards
Former-commit-id: e97bb1211a24175976293161878ec771d94334dc
This commit is contained in:
parent
d2c9cb7b6b
commit
21b7c734a4
@ -444,26 +444,24 @@ class MainWindowReader(QtGui.QMainWindow, reader_ui.Ui_MainWindowReader):
|
||||
if factId is None:
|
||||
return False
|
||||
|
||||
expression, reading = markup['%e'], markup['%r']
|
||||
summary = expression
|
||||
if reading:
|
||||
summary = u'{0} [{1}]'.format(expression, reading)
|
||||
if markup['reading']:
|
||||
summary = u'{expression} [{reading}]'.format(**markup)
|
||||
else:
|
||||
summary = expression
|
||||
|
||||
self.addedFacts.append(factId)
|
||||
self.listDefinitions.addItem(summary)
|
||||
self.listDefinitions.setCurrentRow(self.listDefinitions.count() - 1)
|
||||
self.setStatus(u'Added expression {0}; {1} new fact(s) total'.format(expression, len(self.addedFacts)))
|
||||
self.setStatus(u'Added expression {0}; {1} new fact(s) total'.format(markup['expression'], len(self.addedFacts)))
|
||||
|
||||
self.updateDefinitions()
|
||||
return True
|
||||
|
||||
|
||||
def ankiIsFactValid(self, markup):
|
||||
if self.anki is None:
|
||||
return False
|
||||
|
||||
fields = reader_util.replaceMarkupInFields(self.preferences.ankiFields, markup)
|
||||
return self.anki.canAddNote(self.preferences.ankiDeck, self.preferences.ankiModel, fields)
|
||||
if self.anki is not None:
|
||||
fields = reader_util.replaceMarkupInFields(self.preferences.ankiFields, markup)
|
||||
return self.anki.canAddNote(self.preferences.ankiDeck, self.preferences.ankiModel, fields)
|
||||
|
||||
|
||||
def updateSampleMouseEvent(self, event):
|
||||
|
@ -80,36 +80,29 @@ def findSentence(content, position):
|
||||
return content[start:end].strip()
|
||||
|
||||
|
||||
def replaceMarkupInField(field, markup):
|
||||
for marker, value in markup.items():
|
||||
field = field.replace(marker, value or unicode())
|
||||
|
||||
return field
|
||||
|
||||
|
||||
def replaceMarkupInFields(fields, markup):
|
||||
result = dict()
|
||||
for field, value in fields.items():
|
||||
result[field] = replaceMarkupInField(value, markup)
|
||||
result[field] = value.format(**markup)
|
||||
|
||||
return result
|
||||
|
||||
|
||||
def buildFactMarkupExpression(expression, reading, glossary, sentence=None):
|
||||
return {
|
||||
'%e': expression,
|
||||
'%r': reading,
|
||||
'%g': glossary,
|
||||
'%s': sentence
|
||||
'expression': expression,
|
||||
'reading': reading,
|
||||
'glossary': glossary,
|
||||
'sentence': sentence
|
||||
}
|
||||
|
||||
|
||||
def buildFactMarkupReading(reading, glossary, sentence=None):
|
||||
return {
|
||||
'%e': reading,
|
||||
'%r': None,
|
||||
'%g': glossary,
|
||||
'%s': sentence
|
||||
'expression': reading,
|
||||
'reading': unicode(),
|
||||
'glossary': glossary,
|
||||
'sentence': sentence
|
||||
}
|
||||
|
||||
|
||||
@ -136,7 +129,7 @@ def buildDefinitionHtml(definition, factIndex, factQuery):
|
||||
|
||||
conjugations = unicode()
|
||||
if len(definition['rules']) > 0:
|
||||
conjugations = u' :: '.join(definition['rules'])
|
||||
conjugations = u' • '.join(definition['rules'])
|
||||
conjugations = '<span class = "conjugations"><{0}><br/></span>'.format(conjugations)
|
||||
|
||||
links = '<a href = "copyDefinition:{0}"><img src = "://img/img/icon_copy_definition.png" align = "right"/></a>'.format(factIndex)
|
||||
|
Loading…
Reference in New Issue
Block a user