from typing import List


def parse_comp_internal(
    comp_rules: str, top_delim: str, bottom_delim: str, rule_start: str
) -> List[str]:
    """
    Do the heavy handling to parse out specific sub-sections of rules.
    :param comp_rules: Rules to parse
    :param top_delim: Section to parse
    :param bottom_delim: Section to cut away
    :param rule_start: What rules to pull that rule from
    :return: List of asked for components
    """
    # Keyword actions are found in section XXX
    comp_rules = comp_rules.split(top_delim)[2].split(bottom_delim)[0]

    # Windows line endings... yuck
    valid_line_segments = comp_rules.split("\r\n")

    # XXX.1 is just a description of what rule XXX includes.
    # XXX.2 starts the action for _most_ sections
    keyword_index = 2
    return_list: List[str] = []

    for line in valid_line_segments:
        # Keywords are defined as "XXX.# Name"
        # We will want to ignore subset lines like "XXX.#a"
        if f"{rule_start}.{keyword_index}" in line:
            # Break the line into "Rule Number | Keyword"
            keyword = line.split(" ", 1)[1].lower()
            return_list.append(keyword)
            # Get next keyword, so we can pass over the non-relevant lines
            keyword_index += 1

    return sorted(return_list)