Skip to main content

AI Native Document Format — self-contained HTML documents with embedded JSON, opening like a PDF in any browser

Project description

ANDF — AI Native Document Format

ANDF (.andf) is a document format built for AI-native workflows. Every .andf file is a self-contained HTML file that:

  • Opens in any browser instantly — looks and feels like a PDF (toolbar, dark background, white pages, page numbers)
  • Is trivially parseable by AI — structured JSON is embedded in a <script type="application/andf+json"> tag
  • Requires no install, no server, no extension

Quick Start

from andf import ANDFDocument

doc = ANDFDocument()
doc.set_metadata(title="My Report", authors=["Alice"])

sec = doc.add_section("intro", "Introduction")
sec.heading("Welcome", level=2)
sec.paragraph("Hello from **ANDF**! This is *important*.")
sec.callout("Remember to save your work!", variant="tip", title="Tip")
sec.table(
    headers=["Name", "Score"],
    rows=[["Alice", "95"], ["Bob", "87"]],
    caption="Table 1: Results",
)
sec.code("print('hello world')", language="python")

doc.save("report.andf")
doc.open_in_browser("report.andf")  # opens in browser

Installation

pip install andf

For development (after cloning the repo):

pip install -e .

CLI

# Create a blank document
andf new output.andf

# Open in browser
andf open output.andf

# Extract embedded JSON
andf parse output.andf --pretty

# Validate format
andf validate output.andf

# Show metadata
andf info output.andf

# AI layer summary
andf ai output.andf

File Format

An .andf file is an HTML file. The complete document data is embedded as JSON:

<script type="application/andf+json">
{
  "andf_version": "1.0",
  "document_id": "...",
  "metadata": { "title": "...", "authors": [...] },
  "sections": [...],
  "blocks": { "blk_xxx": { "type": "paragraph", "text": "..." } },
  ...
}
</script>

AI tools extract it with a single regex:

import re, json

pattern = re.compile(
    r'<script[^>]+type=["\']application/andf\+json["\'][^>]*>(.*?)</script>',
    re.DOTALL
)
data = json.loads(pattern.search(open("file.andf").read()).group(1))

Block Types

Type Description
heading Section heading (levels 1–6)
paragraph Body text with **bold**, *italic*, `code`, [ref] markup
image Embedded image from assets
table Data table with headers and rows
list Ordered or unordered list with nesting
code Syntax-highlighted code block
quote Block quote with optional attribution
callout Highlighted box: info / warning / error / success / tip
separator Horizontal rule
pagebreak Explicit page break

Themes

doc.set_theme("default")    # Inter sans-serif, clean
doc.set_theme("academic")   # Georgia serif, formal
doc.set_theme("corporate")  # Arial, business blue headings
doc.set_theme("minimal")    # System UI, minimal color

AI Layer

from andf import ANDFDocument, ANDFAILayer

doc = ANDFDocument.from_file("report.andf")
layer = ANDFAILayer(doc)

# Plain text
text = layer.full_text()

# Markdown (best for LLM input)
md = layer.to_markdown()

# RAG chunks
chunks = layer.context_chunks(max_chars=4000)

# Document summary
summary = layer.document_summary()
print(summary["key_points"])

# High-importance blocks
important = layer.blocks_by_importance(min_importance=4)

Project Structure

andf/
├── __init__.py     # Public API
├── document.py     # ANDFDocument model + fluent builder
├── renderer.py     # HTML renderer
├── parser.py       # Parser + validator
├── ai_layer.py     # AI extraction layer
└── cli.py          # Command-line interface

spec/
└── ANDF-1.0.md     # Format specification

examples/
├── create_examples.py
├── research_paper.andf
├── business_report.andf
├── legal_contract.andf
└── technical_manual.andf

tests/
└── test_andf.py

Generate Examples

python examples/create_examples.py

Opens each .andf file in your browser to see the viewer.


Run Tests

python -m pytest tests/ -v

Specification

See spec/ANDF-1.0.md for the complete format specification.


License

Apache 2.0

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

andf-1.0.2.tar.gz (29.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

andf-1.0.2-py3-none-any.whl (26.1 kB view details)

Uploaded Python 3

File details

Details for the file andf-1.0.2.tar.gz.

File metadata

  • Download URL: andf-1.0.2.tar.gz
  • Upload date:
  • Size: 29.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.5

File hashes

Hashes for andf-1.0.2.tar.gz
Algorithm Hash digest
SHA256 48f80a2692f0eecdeaf5a06cc168d7b31d824b503528613055bca60a6971abe8
MD5 2531f884c1d4f5aad171a3eac31bdc7b
BLAKE2b-256 e7f1ab941b785eec40a63086034ef73192d8e9e88a9294729e2dac777da48b91

See more details on using hashes here.

File details

Details for the file andf-1.0.2-py3-none-any.whl.

File metadata

  • Download URL: andf-1.0.2-py3-none-any.whl
  • Upload date:
  • Size: 26.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.5

File hashes

Hashes for andf-1.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 e7120ddbb5c7a16d493c25b6788802d72cd572ce7a35b66aa3bc3525081cf1a4
MD5 d168e3a0dc00320e9009a4da7fe137eb
BLAKE2b-256 62c4200c32d075b26e80b913a6b61eee2b1f44e776ea8270e7a9e995edf102dc

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page