INNER CODE UNIT · Python

write_markdown_header

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

def write_markdown_header(md_out, filename_no_ext: str, model: str, sanitized_model: str, api_base: str):
    """Write the initial headers and model information to the Markdown file."""
    md_out.write(f"# {filename_no_ext}\n\n")
    md_out.write(f"## {model}\n\n")  # Use the original model name for display

# -----------------------------
# Global or External Variables for ToC
# -----------------------------
toc_entries = []  # Will collect (level, heading_text) as we go

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

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…