Commit d23f475e authored by Marco Cavalli's avatar Marco Cavalli
Browse files

feat: add exclusion for specific classes in custom tag creation for styling

parent 698cc6e6
Loading
Loading
Loading
Loading
+8 −0
Original line number Diff line number Diff line
@@ -602,10 +602,18 @@ def create_custom_tags_for_bold_italic_underline_styles(soup: BeautifulSoup):
    """Some spans apply complex styles part of which involves bolding, italicizing, or underlining. Create custom tags with the class name"""
    CSS_BIU = combine_biu_classes()
    
    # Classes that should be handled via custom-style in Lua filter, not via text replacement
    EXCLUDE_CLASSES = {"HTML-Keyboard", "HTML-Definition"}

    spans = soup.find_all("span", class_=lambda cls: cls in CSS_BIU if cls else False)

    for span in spans:
        cls = span.get("class")[0]
        
        # Skip classes that should maintain their span structure for Lua filter processing
        if cls in EXCLUDE_CLASSES:
            continue
            
        if cls in HANDLE_UNDERSCORE_CLASSES:
            # The styles for these classes do not have the underscores
            cls = cls.replace("_", " ")