Implement styles
All checks were successful
CI Pipeline / build (pull_request) Successful in 12s

This commit is contained in:
2025-12-02 12:02:51 +01:00
parent 1fffecf0eb
commit 58492e9ef6
16 changed files with 786 additions and 23 deletions

View File

@@ -25,18 +25,23 @@ Ezdoc is a Ruby gem for creating .docx files using a DSL. The gem generates vali
- **Document** (`lib/ezdoc/document.rb`): Entry point via `Document.create`. Includes the Builder module and maintains a collection of nodes.
- **Builder** (`lib/ezdoc/builder.rb`): DSL methods (`p`, `text`, `b`, `i`, `u`, `ul`, `ol`, `li`, `table`, `tr`, `td`). Uses a format stack for nested formatting and target tracking for content placement.
- **Builder** (`lib/ezdoc/builder.rb`): DSL methods (`p`, `text`, `h1`-`h6`, `b`, `i`, `u`, `ul`, `ol`, `li`, `table`, `tr`, `td`, `image`). Uses a format stack for nested formatting and target tracking for content placement.
- **Nodes** (`lib/ezdoc/nodes/`): Document element representations (Paragraph, Run, List, ListItem, Table, TableRow, TableCell). All inherit from `Nodes::Base`.
- **Nodes** (`lib/ezdoc/nodes/`): Document element representations (Paragraph, Run, Image, List, ListItem, Table, TableRow, TableCell). All inherit from `Nodes::Base`.
- **Style** (`lib/ezdoc/style.rb`): Style definitions with text properties (bold, italic, color, size, font) and paragraph properties (align, indent, spacing).
- **Package** (`lib/ezdoc/package.rb`): Assembles the docx ZIP structure using rubyzip. Coordinates XML generation.
- **XML generators** (`lib/ezdoc/xml/`): Generate OOXML-compliant XML:
- `DocumentXml`: Main content with paragraphs, lists, tables
- `DocumentXml`: Main content with paragraphs, lists, tables, images
- `StylesXml`: styles.xml with built-in and custom styles
- `ContentTypes`: [Content_Types].xml
- `Relationships`: .rels files
- `Numbering`: numbering.xml for lists
- **ImageDimensions** (`lib/ezdoc/image_dimensions.rb`): Uses fastimage gem to read image dimensions for EMU calculations.
### Data Flow
1. User calls DSL methods on Document