idml 0.7.4 → 0.7.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/TODO.pdf/116-applied-style-resolution.md +62 -0
- data/TODO.pdf/99-table-column-widths.md +6 -6
- data/lib/idml/elements/column.rb +45 -0
- data/lib/idml/elements/table.rb +2 -0
- data/lib/idml/elements.rb +1 -0
- data/lib/idml/render/renderers/table_renderer.rb +43 -5
- data/lib/idml/version.rb +1 -1
- metadata +3 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: a713a0a63c6af7b6090c9a6260467db40ee9a7c497f37561dccf2526ceadaa71
|
|
4
|
+
data.tar.gz: a6695a7318b96ed6664e15b9e2a99e40d2da6ef05139154ba7ccfab73e3eeecf
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 92e8aff4adbb8935c2e3ec7b7ead236458ec2f7171a2923eee9de63b4b4f0ed96d95f7f39c9c184d97643b0aa9096e3aa1b40e890610e82d514bb36b17c6f14b
|
|
7
|
+
data.tar.gz: 88c470bb2d55962f57a950fe6c1ef526d34ce36d7fafe38ed045d4f7019821586a9045d1f027e28eb304a1d0a57da9f157256603a83e48e873decd3f2620554c
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
# TODO PDF 116: AppliedParagraphStyle / AppliedCharacterStyle resolution from Resources/Styles.xml
|
|
2
|
+
|
|
3
|
+
## Status: OPEN — critical gap identified in 2026-08-10 audit
|
|
4
|
+
|
|
5
|
+
## Problem
|
|
6
|
+
|
|
7
|
+
In real IDML documents, the `<ParagraphStyleRange>` element often
|
|
8
|
+
carries ONLY an `AppliedParagraphStyle` reference and NO inline
|
|
9
|
+
formatting attributes. The actual formatting (Justification,
|
|
10
|
+
SpaceBefore, PointSize, etc.) lives in the referenced
|
|
11
|
+
`<ParagraphStyle>` definition in `Resources/Styles.xml`.
|
|
12
|
+
|
|
13
|
+
Example from the sample-with-table-more fixture:
|
|
14
|
+
```xml
|
|
15
|
+
<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/$ID/NormalParagraphStyle">
|
|
16
|
+
<CharacterStyleRange AppliedCharacterStyle="CharacterStyle/$ID/[No character style]">
|
|
17
|
+
...
|
|
18
|
+
</CharacterStyleRange>
|
|
19
|
+
</ParagraphStyleRange>
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
The PSR has NO inline Justification, SpaceBefore, etc. Those values
|
|
23
|
+
are on `ParagraphStyle Self="ParagraphStyle/$ID/NormalParagraphStyle"`
|
|
24
|
+
in Styles.xml.
|
|
25
|
+
|
|
26
|
+
Today StyleResolver reads attributes directly from the PSR element.
|
|
27
|
+
When the PSR has only a style reference (common in real documents),
|
|
28
|
+
the renderer uses default values for everything.
|
|
29
|
+
|
|
30
|
+
## Impact
|
|
31
|
+
|
|
32
|
+
For the `sample-with-table-more` fixture, every PSR uses
|
|
33
|
+
`NormalParagraphStyle` — which in InDesign maps to 12pt Regular with
|
|
34
|
+
left alignment. The renderer happens to produce approximately right
|
|
35
|
+
output because the defaults match. But for documents that use custom
|
|
36
|
+
paragraph styles (Heading 1 = 24pt Bold Centered, Body Text = 11pt
|
|
37
|
+
Justified with 6pt SpaceAfter), the output would be wrong.
|
|
38
|
+
|
|
39
|
+
## What needs to happen
|
|
40
|
+
|
|
41
|
+
1. `Render::StyleResolver` resolves `AppliedParagraphStyle` to a
|
|
42
|
+
`ParagraphStyle` from `Parts::Style` (Resources/Styles.xml).
|
|
43
|
+
2. PSR inline attributes override the style's attributes (when both
|
|
44
|
+
are present — this is the IDML "local override" mechanism).
|
|
45
|
+
3. Same for `AppliedCharacterStyle` → `CharacterStyle` resolution.
|
|
46
|
+
4. The merged attributes become the Paragraph/StyledRun's values.
|
|
47
|
+
|
|
48
|
+
Architecture: `Parts::Style` already parses `<ParagraphStyle>` and
|
|
49
|
+
`<CharacterStyle>` entries. StyleResolver needs access to the style
|
|
50
|
+
part (via `context.package.styles` or similar).
|
|
51
|
+
|
|
52
|
+
## Acceptance criteria
|
|
53
|
+
|
|
54
|
+
- [ ] PSR with only AppliedParagraphStyle resolves formatting from
|
|
55
|
+
the referenced ParagraphStyle.
|
|
56
|
+
- [ ] PSR inline attributes override style attributes.
|
|
57
|
+
- [ ] CharacterStyle resolution for CSR's AppliedCharacterStyle.
|
|
58
|
+
- [ ] Spec: fixture with custom paragraph style renders correctly.
|
|
59
|
+
|
|
60
|
+
## Dependencies
|
|
61
|
+
|
|
62
|
+
- None — pure feature work on existing models.
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
# TODO PDF 99: Table column widths from
|
|
1
|
+
# TODO PDF 99: Table column widths from Column elements
|
|
2
2
|
|
|
3
|
-
## Status: DONE — Table now models `
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
3
|
+
## Status: DONE — Table now models both `single_column_width`
|
|
4
|
+
(uniform) and per-column `<Column>` elements with individual
|
|
5
|
+
`SingleColumnWidth` values. SchemaLayout uses per-column widths
|
|
6
|
+
when `<Column>` children are present; falls back to uniform when
|
|
7
|
+
not.
|
|
8
8
|
|
|
9
9
|
## Problem
|
|
10
10
|
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
# frozen_string: true
|
|
2
|
+
|
|
3
|
+
module Idml
|
|
4
|
+
module Elements
|
|
5
|
+
# `<Column>` — a column definition within an IDML Table. Carries
|
|
6
|
+
# the column's width (SingleColumnWidth), type (HeaderColumn /
|
|
7
|
+
# BodyColumn), insets, and visual properties (fill, diagonal lines).
|
|
8
|
+
#
|
|
9
|
+
# Schema: `Column_Object` in
|
|
10
|
+
# `reference-docs/schemas/package/Stories/Story.rnc`. Real IDML
|
|
11
|
+
# tables have `<Column>` children alongside `<Row>` and `<Cell>`
|
|
12
|
+
# siblings. The `Name` attribute is the column index as a string
|
|
13
|
+
# (e.g., "0", "1", "2").
|
|
14
|
+
#
|
|
15
|
+
# The renderer's SchemaLayout reads `SingleColumnWidth` per column
|
|
16
|
+
# to compute per-column x positions and widths (replaces the
|
|
17
|
+
# even-division / uniform-width fallback).
|
|
18
|
+
class Column < Lutaml::Model::Serializable
|
|
19
|
+
attribute :self_attr, :string
|
|
20
|
+
attribute :name, :string
|
|
21
|
+
attribute :single_column_width, :float
|
|
22
|
+
attribute :column_type, :string
|
|
23
|
+
attribute :fill_color, :string
|
|
24
|
+
attribute :fill_tint, :float
|
|
25
|
+
|
|
26
|
+
xml do
|
|
27
|
+
root "Column"
|
|
28
|
+
map_attribute "Self", to: :self_attr
|
|
29
|
+
map_attribute "Name", to: :name
|
|
30
|
+
map_attribute "SingleColumnWidth", to: :single_column_width
|
|
31
|
+
map_attribute "ColumnType", to: :column_type
|
|
32
|
+
map_attribute "FillColor", to: :fill_color
|
|
33
|
+
map_attribute "FillTint", to: :fill_tint
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
# Column Name is a string integer (e.g., "0", "1").
|
|
37
|
+
# Returns the integer index or nil if Name is missing/invalid.
|
|
38
|
+
def index
|
|
39
|
+
return nil unless name
|
|
40
|
+
|
|
41
|
+
Integer(name, 10, exception: false) # rubocop:disable Style/RescueModifier
|
|
42
|
+
end
|
|
43
|
+
end
|
|
44
|
+
end
|
|
45
|
+
end
|
data/lib/idml/elements/table.rb
CHANGED
|
@@ -46,6 +46,7 @@ module Idml
|
|
|
46
46
|
attribute :table_row, Idml::Elements::TableRow, collection: true
|
|
47
47
|
attribute :cell, Idml::Elements::Cell, collection: true
|
|
48
48
|
attribute :row, Idml::Elements::Row, collection: true
|
|
49
|
+
attribute :column, Idml::Elements::Column, collection: true
|
|
49
50
|
attribute :properties, Idml::Elements::Properties, collection: true
|
|
50
51
|
|
|
51
52
|
xml do
|
|
@@ -77,6 +78,7 @@ module Idml
|
|
|
77
78
|
map_element "TableRow", to: :table_row
|
|
78
79
|
map_element "Cell", to: :cell
|
|
79
80
|
map_element "Row", to: :row
|
|
81
|
+
map_element "Column", to: :column
|
|
80
82
|
map_element "Properties", to: :properties
|
|
81
83
|
end
|
|
82
84
|
|
data/lib/idml/elements.rb
CHANGED
|
@@ -17,6 +17,7 @@ module Idml
|
|
|
17
17
|
autoload :ButtonPreference, "idml/elements/pref_button_preference"
|
|
18
18
|
autoload :Bookmark, "idml/elements/bookmark"
|
|
19
19
|
autoload :Cell, "idml/elements/cell"
|
|
20
|
+
autoload :Column, "idml/elements/column"
|
|
20
21
|
autoload :Condition, "idml/elements/condition"
|
|
21
22
|
autoload :CellStyle, "idml/elements/cell_style"
|
|
22
23
|
autoload :CellStyleGroup, "idml/elements/cell_style_group"
|
|
@@ -243,7 +243,8 @@ module Idml
|
|
|
243
243
|
mark_covered(covered, col_idx, row_idx, col_span, row_span)
|
|
244
244
|
|
|
245
245
|
yield cell_x(col_idx), cell_y(row_idx, col_span, row_span),
|
|
246
|
-
cell_w(col_span), cell_h(row_idx, row_span),
|
|
246
|
+
cell_w(col_idx, col_span), cell_h(row_idx, row_span),
|
|
247
|
+
cell
|
|
247
248
|
end
|
|
248
249
|
end
|
|
249
250
|
end
|
|
@@ -286,7 +287,7 @@ module Idml
|
|
|
286
287
|
private :mark_covered
|
|
287
288
|
|
|
288
289
|
def cell_x(col)
|
|
289
|
-
box[:x] + (col
|
|
290
|
+
box[:x] + cumulative_col_width(col)
|
|
290
291
|
end
|
|
291
292
|
|
|
292
293
|
# PDF-coordinate bottom y of the cell's rectangle. For a
|
|
@@ -297,9 +298,11 @@ module Idml
|
|
|
297
298
|
box[:y] + total_height - cumulative_height(last_row + 1)
|
|
298
299
|
end
|
|
299
300
|
|
|
300
|
-
# Width covered by `span` columns starting at
|
|
301
|
-
|
|
302
|
-
|
|
301
|
+
# Width covered by `span` columns starting at `col`. Uses
|
|
302
|
+
# per-column widths from Column elements when available;
|
|
303
|
+
# falls back to uniform width when not.
|
|
304
|
+
def cell_w(col, span)
|
|
305
|
+
span.to_i.times.sum { |i| column_width_at(col + i) }
|
|
303
306
|
end
|
|
304
307
|
|
|
305
308
|
# Total height covered by `span` rows starting at `row_idx`.
|
|
@@ -318,6 +321,41 @@ module Idml
|
|
|
318
321
|
end
|
|
319
322
|
end
|
|
320
323
|
|
|
324
|
+
# Returns per-column widths from Column elements when
|
|
325
|
+
# present; empty array otherwise. When non-empty, the
|
|
326
|
+
# renderer uses per-column widths for x positions and
|
|
327
|
+
# span widths instead of uniform per_col_width.
|
|
328
|
+
def per_column_widths
|
|
329
|
+
return @per_column_widths if defined?(@per_column_widths)
|
|
330
|
+
|
|
331
|
+
cols = table.column
|
|
332
|
+
@per_column_widths = if cols.empty?
|
|
333
|
+
[]
|
|
334
|
+
else
|
|
335
|
+
cols.filter_map do |col|
|
|
336
|
+
w = col.single_column_width
|
|
337
|
+
w&.positive? ? w : nil
|
|
338
|
+
end
|
|
339
|
+
end
|
|
340
|
+
end
|
|
341
|
+
|
|
342
|
+
# Width of a single column at index `idx`. Uses per-column
|
|
343
|
+
# widths when available; falls back to uniform.
|
|
344
|
+
def column_width_at(idx)
|
|
345
|
+
return per_col_width if per_column_widths.empty?
|
|
346
|
+
return per_col_width unless idx.between?(0, per_column_widths.length - 1)
|
|
347
|
+
|
|
348
|
+
per_column_widths[idx]
|
|
349
|
+
end
|
|
350
|
+
|
|
351
|
+
# Cumulative width from column 0 up to (but not including)
|
|
352
|
+
# column `col`. Used for x positioning.
|
|
353
|
+
def cumulative_col_width(col)
|
|
354
|
+
return col * per_col_width if per_column_widths.empty?
|
|
355
|
+
|
|
356
|
+
col.times.sum { |i| column_width_at(i) }
|
|
357
|
+
end
|
|
358
|
+
|
|
321
359
|
def row_height(idx)
|
|
322
360
|
return 0.0 unless idx.between?(0, row_count - 1)
|
|
323
361
|
|
data/lib/idml/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: idml
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.7.
|
|
4
|
+
version: 0.7.5
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Ribose
|
|
@@ -172,6 +172,7 @@ files:
|
|
|
172
172
|
- TODO.pdf/113-multi-column-text-frames.md
|
|
173
173
|
- TODO.pdf/114-text-wrap-around-shapes.md
|
|
174
174
|
- TODO.pdf/115-bullet-numbered-lists.md
|
|
175
|
+
- TODO.pdf/116-applied-style-resolution.md
|
|
175
176
|
- TODO.pdf/12-idml-to-pdf-pipeline.md
|
|
176
177
|
- TODO.pdf/13-cjk-text-layout.md
|
|
177
178
|
- TODO.pdf/14-page-item-element-models.md
|
|
@@ -280,6 +281,7 @@ files:
|
|
|
280
281
|
- lib/idml/elements/character_style_group.rb
|
|
281
282
|
- lib/idml/elements/character_style_range.rb
|
|
282
283
|
- lib/idml/elements/color.rb
|
|
284
|
+
- lib/idml/elements/column.rb
|
|
283
285
|
- lib/idml/elements/condition.rb
|
|
284
286
|
- lib/idml/elements/content.rb
|
|
285
287
|
- lib/idml/elements/content_transparency_setting.rb
|