Reference library

Automation & scripting

CLI tools, scheduled jobs, filesystem tasks, and glue scripts that save time.

2 matches
Automation & scripting easy

Convert Markdown to HTML in Python (Batch)

Convert every Markdown file in a directory to HTML with the Python markdown library, saving each result with an .html extension.

markdown html batch
Python
import markdown
from pathlib import Path


def convert_md_to_html(source_dir: str, dest_dir: str) -> list[str]:
    src = Path(source_dir)
    dst = Path(dest_dir)
    dst.mkdir(parents=True, exist_ok=True)

    converted_files = []
    for md_file in src.glob("*.md"):
        html_content = markdown.markdown(md_file.…
14 0 Open
Automation & scripting easy

How to Cross Post Markdown to dev.to API in Python

A Python function that POSTs markdown content to the dev.to API and handles HTTP or URLError exceptions with mock API testing.

api dev.to markdown
Python
import json
from urllib import request, error


def cross_post_to_devto(markdown_content, api_key, devto_api_url="https://dev.to/api/articles"):
    """
    Mock cross-posting of markdown content to the dev.to API.
    Returns the API response or an error message.
    """
    payload = json.dumps({
        "article": …
10 0 Open

Browse by section

Each section groups closely related Python snippets.

Automation & scripting — Python code examples

What you will find here

This page collects automation & scripting snippets — short, copy-ready Python you can paste into our free online IDE and run without installing anything. Each sample includes a plain-English explanation and the full source code.

Samples vs tutorials and challenges

Samples are quick reference — one concept per page. For step-by-step teaching, use our Python tutorials. To test yourself, try quizzes or coding challenges. Clean up style with the Python formatter.