View Single Post
Old 10-09-2021, 05:51 AM   #3
njpig
Zealot
njpig began at the beginning.
 
Posts: 108
Karma: 10
Join Date: Sep 2020
Device: kindle paperwhite3/Oasis2
Quote:
Originally Posted by kovidgoyal View Post
yes they do. combine them all into one if you dont care about order with this function

Code:
def prefixed_classes(classes):
    q = frozenset(classes.split(' '))

    def matcher(x):
        if x:
            for candidate in frozenset(x.split()):
                for x in q:
                    if candidate.startswith(x):
                        return True
        return False
    return {'attrs': {'class': matcher}}
keep_onlly_tags = [prefixed_classes('prefix1 prefix2 prefix3')]
Thanks a lot!
njpig is offline   Reply With Quote