geometor.altshiller_court.codex_items

Folio depagination and item-per-page decomposition for College Geometry.

Transforms atomic diplomatic folio files (<NNNN>.rst and <NNNN>.notes.rst) into structured chapter sections, leaf items, and sub-collections (such as the twelve fundamental loci of § 11) with co-located .euclid-graphic SVGs and paired commentary.rst companion tracks.

Attributes

HEADING_CHARS

ARTICLE_INLINE_RE

ENUN_ARTICLE_RE

PROBLEM_ENUN_RE

LOCUS_ENUN_RE

PICTURE_RE

GEOM_GID_RE

ENUM_ITEM_RE

CH01_SECTION_META

CH03_SECTION_META

CHAPTER_SECTION_META_BY_INDEX

ITEM_EXCERPTS

ITEM_CARD_IMAGES

FRONTMATTER_UNITS

Classes

FolioBlock

A single top-level RST block carrying its source folio provenance.

CodexItem

A single compiled leaf page (or § 11 locus sub-collection) with commentary.

CodexSection

A chapter section container holding intro blocks and ordered CodexItem children.

Functions

parse_folio_rst(rst_path) → tuple[dict[str, str], str]

Parse :key: value metadata header and RST body from a <NNNN>.rst file.

demote_headings(text, map_chars) → str

Rewrite RST underline characters according to map_chars.

strip_top_heading(body[, underline_char]) → str

Remove top RST heading underlined with underline_char if present.

heading_info(block_text) → tuple[str, str] | None

If block_text is a 2-line RST heading, return (title, underline_char).

extract_depaginated_blocks(folio_entries[, ...]) → list[FolioBlock]

Convert consecutive folios into FolioBlock items, reflowing mid-sentence splits.

render_blocks_with_folios(blocks) → str

Render FolioBlock list to seamless RST prose (source folios live in :folios: frontmatter).

decompose_chapter_folios(folio_entries, chap_prefix, ...) → list[CodexSection]

Decompose transcribed chapter folios into CodexSection containers and leaf CodexItem units.

decompose_chapter_one(folio_entries) → list[CodexSection]

Decompose Chapter I (0020–0052) into 5 CodexSection containers and leaf items.

decompose_frontmatter(folio_entries) → list[CodexItem]

Decompose Frontmatter (0001–0019) into 6 leaf CodexItem units.

copy_referenced_graphics(blocks, source_chap_dir, ...) → tuple[int, int]

Copy ONLY the .g*.svg and .g*.png files referenced by .. picture:: in blocks.

Module Contents

geometor.altshiller_court.codex_items.HEADING_CHARS
geometor.altshiller_court.codex_items.ARTICLE_INLINE_RE
geometor.altshiller_court.codex_items.ENUN_ARTICLE_RE
geometor.altshiller_court.codex_items.PROBLEM_ENUN_RE
geometor.altshiller_court.codex_items.LOCUS_ENUN_RE
geometor.altshiller_court.codex_items.PICTURE_RE
geometor.altshiller_court.codex_items.GEOM_GID_RE
geometor.altshiller_court.codex_items.ENUM_ITEM_RE
class geometor.altshiller_court.codex_items.FolioBlock

A single top-level RST block carrying its source folio provenance.

text: str
folios: list[tuple[str, str]] = []
property primary_folio: tuple[str, str]

Return (folio_id, page_str) where this block begins.

class geometor.altshiller_court.codex_items.CodexItem

A single compiled leaf page (or § 11 locus sub-collection) with commentary.

slug: str
title: str
anchor: str
item_type: str
order: int
canonical_id: str
blocks: list[FolioBlock] = []
children: list[CodexItem] = []
child_collection_type: str | None = None
excerpt: str | None = None
card_image: str | None = None
all_folios() → list[tuple[str, str]]

Ordered unique (folio_id, page_str) pairs spanned by this item and its children.

class geometor.altshiller_court.codex_items.CodexSection

A chapter section container holding intro blocks and ordered CodexItem children.

slug: str
code: str
title: str
anchor: str
canonical_id: str
order: int
overview: str
intro_blocks: list[FolioBlock] = []
items: list[CodexItem] = []
geometor.altshiller_court.codex_items.parse_folio_rst(rst_path: pathlib.Path) → tuple[dict[str, str], str]

Parse :key: value metadata header and RST body from a <NNNN>.rst file.

geometor.altshiller_court.codex_items.demote_headings(text: str, map_chars: dict[str, str]) → str

Rewrite RST underline characters according to map_chars.

geometor.altshiller_court.codex_items.strip_top_heading(body: str, underline_char: str = '=') → str

Remove top RST heading underlined with underline_char if present.

geometor.altshiller_court.codex_items.heading_info(block_text: str) → tuple[str, str] | None

If block_text is a 2-line RST heading, return (title, underline_char).

geometor.altshiller_court.codex_items.extract_depaginated_blocks(folio_entries: list[tuple[str, str, dict[str, str], str]], strip_chapter_heading: bool = False, demote_frontmatter: bool = False) → list[FolioBlock]

Convert consecutive folios into FolioBlock items, reflowing mid-sentence splits.

geometor.altshiller_court.codex_items.render_blocks_with_folios(blocks: list[FolioBlock]) → str

Render FolioBlock list to seamless RST prose (source folios live in :folios: frontmatter).

geometor.altshiller_court.codex_items.CH01_SECTION_META: dict[str, tuple[str, str, str, str]]
geometor.altshiller_court.codex_items.CH03_SECTION_META: dict[str, tuple[str, str, str, str]]
geometor.altshiller_court.codex_items.CHAPTER_SECTION_META_BY_INDEX: dict[int, tuple[str, str, dict[str, tuple[str, str, str, str]]]]
geometor.altshiller_court.codex_items.ITEM_EXCERPTS: dict[str, str]
geometor.altshiller_court.codex_items.ITEM_CARD_IMAGES: dict[str, str]
geometor.altshiller_court.codex_items.decompose_chapter_folios(folio_entries: list[tuple[str, str, dict[str, str], str]], chap_prefix: str, chap_roman: str, section_meta_map: dict[str, tuple[str, str, str, str]]) → list[CodexSection]

Decompose transcribed chapter folios into CodexSection containers and leaf CodexItem units.

geometor.altshiller_court.codex_items.decompose_chapter_one(folio_entries: list[tuple[str, str, dict[str, str], str]]) → list[CodexSection]

Decompose Chapter I (0020–0052) into 5 CodexSection containers and leaf items.

geometor.altshiller_court.codex_items.FRONTMATTER_UNITS: list[tuple[str, str, str, str, str, str]] = [('01-cover', 'Dover Front Cover', '0001', '0001', 'Frontmatter.Cover', "Unabridged 2007 Dover...
geometor.altshiller_court.codex_items.decompose_frontmatter(folio_entries: list[tuple[str, str, dict[str, str], str]]) → list[CodexItem]

Decompose Frontmatter (0001–0019) into 6 leaf CodexItem units.

geometor.altshiller_court.codex_items.copy_referenced_graphics(blocks: list[FolioBlock], source_chap_dir: pathlib.Path, dest_item_dir: pathlib.Path) → tuple[int, int]

Copy ONLY the .g*.svg and .g*.png files referenced by .. picture:: in blocks.