from panflute import Space,SoftBreak,Str from typing import Union # Import local files from context import Context Whitespace = Union[Space,SoftBreak] class NBSP(Space): pass def bavlna(e: Whitespace, c: Context) -> bool: """Determine if given piece of whitespace should be non-breakable.""" if c.get_metadata("language") == "cs": # TODO: Add more clever stuff if isinstance(e.prev, Str) and isinstance(e.next, Str) and e.prev.text.lower() in ['k', 's', 'v', 'z', 'o', 'u', 'a', 'i']: return True return False