INNER CODE UNIT · Python

write_markdown_entry

cognitivetech/ollama-ebook-summary · sum.py:194

def write_markdown_entry(md_out, heading: str, content: str, verbose: bool = False):
    """Write a single entry to the Markdown file and optionally print to console."""
    # Sniff the heading level: count '#' characters from the left
    # e.g. "### Some Heading" => heading_level = 3
    heading_level = 0
    for ch in heading:
        if ch == '#':
            heading_level += 1
        else:
            break

    # Extract the actual heading text (after the '#' characters and space)
    heading_text = heading.lstrip('#').strip()

    # Store heading and level to build the ToC later
    toc_entries.append((heading_level, heading_text))

    # Write out the heading + content

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…