src/syncabook/split_text.py
def _split_text_by_opening(pattern, text):
    """
    Splits text into parts identified by opening that matches `pattern`.
    For example, --pattern='\n\nCHAPTER \\d+\n\n' may be used
    to split text into chapters.
    """
    openings = re.findall(pattern, text)

    if len(openings) == 0:
        print(f'\n❗ No text matching pattern "{pattern}". Splitting is not performed.\n')
        return []

    texts = re.split(pattern, text)
    texts = [d + t for d, t in zip(openings, texts[1:])]
    return texts

    Splits text into parts identified by opening that matches `pattern`.
    For example, --pattern='\n\nCHAPTER \\d+\n\n' may be used
    to split text into chapters.
    
Splits text into parts identified by opening that matches `pattern`.
Splits text into parts identified by opening that matches ` pattern ` .
def _split_text_by_opening(pattern, text):
    openings = re.findall(pattern, text)
    if len(openings) == 0:
        print(f'\n❗ No text matching pattern "{pattern}". Splitting is not performed.\n')
        return []
    texts = re.split(pattern, text)
    texts = [d + t for d, t in zip(openings, texts[1:])]
    return texts
def _split_text_by_opening ( pattern , text ) : openings = re . findall ( pattern , text ) if len ( openings ) == 0 : print ( f'\n❗ No text matching pattern "{pattern}". Splitting is not performed.\n') return [ ] texts = re . split ( pattern , text ) texts = [ d + t for d , t in zip ( openings , texts [ 1 : ] ) ] return texts
Splits text into parts identified by opening that matches `pattern`.
Splits text into parts identified by opening that matches ` pattern ` .
"""
    Splits text into parts identified by opening that matches `pattern`.
    For example, --pattern='\n\nCHAPTER \\d+\n\n' may be used
    to split text into chapters.
    """
pattern
text