from typing import List


def gen_preview_from_chunks(chunks: List[str], preview_length: int):
    """Generates a preview string for a document

    Args:
        chunks: List of strings, the chunks of the document
        preview_length: Number of characters in the preview

    Returns:
        Preview/metatext string
    """
    preview = ""
    reached_length = False
    for chunk in chunks:
        words = chunk.split()
        for word in words:
            if len(preview) + len(word) <= preview_length:
                preview += f" {word}"
            else:
                reached_length = True
                break

        if reached_length:
            break

    return preview