Skip to content

Possible omission from usfm_stylesheet.py dealing with the \OccursUnder marker in stylesheets. #262

@davidbaines

Description

@davidbaines

corpora/usfm_stylesheets.py parses stylesheets, but only returns the first item in the list of markers under which a marker can occur.
The problem occurs in the _split_stylesheet function:

Here is a suggestion for a fix:

def _split_stylesheet(stream: TextIO) -> List[Tuple[str, str]]:
    entries: List[Tuple[str, str]] = []
    for line in stream:
        if line.startswith("#!"):
            line = line[2:]
        line = line.split("#")[0].strip()
        if line == "":
            continue

        if not line.startswith("\\"):
            # ignore lines that do not start with a backslash
            continue

        parts = line.split(maxsplit=2)
        if not parts[0][1:].lower() == "occursunder":
            entries.append((parts[0][1:].lower(), parts[1].strip() if len(parts) > 1 else ""))
        else:
            parts = line.split()
            entries.append((parts[0][1:].lower(), " ".join(parts[1:]) if len(parts) > 1 else ""))
    return entries

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Status

    🔖 Ready

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions