View Single Post
Old 10-31-2022, 08:23 AM   #1051
chaley
Grand Sorcerer
chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.
 
Posts: 12,510
Karma: 8065348
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
Quote:
Originally Posted by kiwidude View Post
I don't think there is a way in the current API of removing just one specific named marker once you have applied it - I am sure chaley can correct me on that if I am wrong. That would have been the quick change to the plugin I might have been willing to make.
There isn't a specific API but it is easy to do yourself. Here is an example that runs in the Template debugger so it is easy to see what it does. The work is in the function remove_val_from_marks().

Code:
python:
def evaluate(book, context):
	db = context.db
	new_marks = remove_val_from_marks(db, 'bbb')
	db.data.set_marked_ids(new_marks)
	return 'a string'

def remove_val_from_marks(db, val):
	return {k:v for k,v in db.data.marked_ids.items() if v != val}

Last edited by chaley; 10-31-2022 at 08:26 AM.
chaley is offline   Reply With Quote