-
-
Notifications
You must be signed in to change notification settings - Fork 2
Description
Summary
The book doctype is recognized by the parser and converters, but the only book-specific behavior currently implemented is setting <body class="book"> in HTML output. All other book-specific features (parts, chapters, special sections) are missing.
Current State
Doctype::Bookenum exists inconverters/core/src/doctype.rs- HTML converter outputs
<body class="book">when doctype is book - No other book-specific behavior is implemented
What's Missing
| Feature | Description |
|---|---|
| Level 0 sections | Parser rejects = Part Title syntax (parts) |
| Chapter detection | Level 1 sections not treated as chapters |
:chapter-signifier: |
Attribute not recognized or used |
:partnums: / :part-signifier: |
Attributes ignored |
| Chapter numbering | :sectnums: doesn't number chapters with signifier |
| Special sections | Preface, dedication, colophon not recognized |
Implementation Plan
Phase 1: Level 0 Section Support (Parts)
Goal: Allow parsing and rendering level 0 sections (parts) when doctype=book
Parser changes (acdc-parser/src/grammar/document.rs):
- Currently level 0 sections are rejected after document title
- Need to allow
= Part Titlesyntax when doctype=book - Options: Pass doctype through parsing context, or accept level 0 and validate during conversion
Converter changes (converters/html/src/section.rs):
match (section.level, doctype) {
(0, Doctype::Book) => {
// Render as part: <div class="sect0"><h1>Part Title</h1>...</div>
}
// ... existing handling
}Success criteria:
- Level 0 sections parse without error when doctype=book
- Parts render with
<div class="sect0">and<h1> - Article doctype continues to reject level 0 sections
Phase 2: Chapter Detection & Rendering
Goal: Recognize level 1 sections as chapters in book doctype, support chapter signifier
Changes needed:
- Add
chapter-signifierto default attributes (converters/core/src/lib.rs) - Detect chapters: level 1 + doctype=book
- Render chapter titles with signifier when
:sectnums:enabled:<h2>Chapter 1. Introduction</h2>
- Add
chapterCSS class:<div class="sect1 chapter">
Success criteria:
- Level 1 sections in book mode render with chapter signifier
- Chapter numbering works with
:sectnums: - Custom
:chapter-signifier:values respected
Phase 3: Multi-Part Structure
Goal: Support books organized into parts with chapters
Changes needed:
- Part introduction handling - content between part title and first chapter
- Part-level numbering state tracking
- Support for
:partnums:and:part-signifier:attributes - Chapter numbering options:
- Continuous across parts (Ch 1, 2, 3 in Part I; Ch 4, 5, 6 in Part II)
- Or reset per part (match asciidoctor behavior)
Success criteria:
- Books with level 0 sections render as multi-part
- Part introductions appear before first chapter
- Chapter numbering works correctly across parts
Phase 4: Special Sections
Goal: Recognize and render special section types
Special section types to support:
[preface]- Preface section[dedication]- Dedication section[colophon]- Colophon section (book-specific)[appendix]- Appendix sections
Changes needed:
- Detect special sections by style attribute
- Apply appropriate CSS classes
- Handle level 0 special sections (auto-adjust to level 1 per AsciiDoctor spec)
Success criteria:
- Special sections identified and marked with appropriate CSS classes
- Level 0 special sections treated as level 1
- All special section types supported
Key Files to Modify
acdc-parser/src/grammar/document.rs- Level 0 section parsingacdc-parser/src/model/mod.rs- Potentially addSectionTypeenumconverters/html/src/section.rs- Chapter/part renderingconverters/html/src/html_visitor.rs- State tracking for numberingconverters/core/src/lib.rs- Default attributes (chapter-signifier)