from typing import Optional


def normalize_dewey(class_mark: str) -> Optional[str]:
    """
    Normalizes Dewey classification to be used in call numbers

    Args:
        class_mark:                  Dewey classification

    Returns:
        normalized class_mark
    """
    if isinstance(class_mark, str):
        class_mark = (
            class_mark.replace("/", "")
            .replace("j", "")
            .replace("C", "")
            .replace("[B]", "")
            .replace("'", "")
            .strip()
        )
        try:
            # test if has correct format
            float(class_mark)
            while class_mark[-1] == "0":
                class_mark = class_mark[:-1]
            return class_mark
        except ValueError:
            return None
    else:
        return None