powertom 0.9.1 → 0.9.2
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/CHANGELOG.md +34 -0
- data/README.md +2 -2
- data/lib/powertom/adapter/page_surgery.rb +24 -10
- data/lib/powertom/adapter/ruby_pptx_adapter.rb +5 -4
- data/lib/powertom/cli.rb +6 -0
- data/lib/powertom/render.rb +29 -1
- data/lib/powertom/table_loop.rb +21 -0
- data/lib/powertom/validator.rb +48 -10
- data/lib/powertom/version.rb +3 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 4a75707be0d6668f45059162b18cb9db061b25ec10b173be04e2cb417f40ab92
|
|
4
|
+
data.tar.gz: 4b4a30bc41a02615903f00f4cbb4511a03f9fb3a53548e999c5fc783b764f0f6
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: c489366b14a0f4498b1ee1efb80cbf5fcacd45c6d2eb908a145461209df00dee247deae6998907954d3fc41598c7bc2455897868f198a5677ffef77d48a8d572
|
|
7
|
+
data.tar.gz: e1a0da8427f7f8b55e1790bde26c889103624a9f312d4a79313c5d1e2d3e795c8539e9f993c8ccabca8578ed63e310c6ea2e33028211bd78fe31edb7dacef378
|
data/CHANGELOG.md
CHANGED
|
@@ -6,6 +6,40 @@ and the project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.
|
|
|
6
6
|
|
|
7
7
|
## [Unreleased]
|
|
8
8
|
|
|
9
|
+
## [0.9.2] - 2026-11-24
|
|
10
|
+
|
|
11
|
+
### Fixed
|
|
12
|
+
|
|
13
|
+
- `check` no longer lets templates through that fail at render time
|
|
14
|
+
(design §7.2 "check says OK ⇒ render succeeds"):
|
|
15
|
+
- A `#grid` table's static rows (e.g. a totals row outside the header and
|
|
16
|
+
content rows) may no longer use `{{row.*}}` / `{{col.*}}` / `{{cell}}` —
|
|
17
|
+
`TableLoop.plan` rejects them with a located error, so `check` and render
|
|
18
|
+
fail identically. Static rows take page fields only.
|
|
19
|
+
- In a block table with a `{{#cols}}` band, `{{col.*}}` tags in static rows
|
|
20
|
+
inside the band's column range are now reconciled per column item (they
|
|
21
|
+
were silently skipped by the main reconciliation loop).
|
|
22
|
+
- `PageSurgery` rejects out-of-range slide numbers in the page plan
|
|
23
|
+
(`source: 0`, negative or beyond the slide count) with a located error
|
|
24
|
+
instead of silently cloning the wrong slide via Ruby's negative-index
|
|
25
|
+
wraparound.
|
|
26
|
+
- `PageSurgery` validates zip entry names when writing the output package and
|
|
27
|
+
rejects `../` traversal, absolute paths, drive letters and `..` segments
|
|
28
|
+
(zip-slip hardening; rubyzip does not sanitize entry names itself).
|
|
29
|
+
- CLI `render` now catches unexpected non-`PowerTom::Error` exceptions and
|
|
30
|
+
exits `1` with a one-line message instead of printing a Ruby backtrace;
|
|
31
|
+
the exit-code contract (0/1/2) holds for internal failures too.
|
|
32
|
+
|
|
33
|
+
### Added
|
|
34
|
+
|
|
35
|
+
- Standard charts (bar/column, line, area, doughnut, radar) now emit a
|
|
36
|
+
**warning** in both `render` and `check` when the data's series count
|
|
37
|
+
differs from the template's: added series inherit the last template
|
|
38
|
+
series' formatting, and removed series take their formatting with them.
|
|
39
|
+
Rendering is not blocked. Combo, scatter and bubble charts still require
|
|
40
|
+
exactly the template's series count (error), and pie still rejects more
|
|
41
|
+
than one series.
|
|
42
|
+
|
|
9
43
|
## [0.9.1] - 2026-11-20
|
|
10
44
|
|
|
11
45
|
### Fixed
|
data/README.md
CHANGED
|
@@ -212,7 +212,7 @@ result = PowerTom.render("templates/report.pptx", data: {
|
|
|
212
212
|
- **Loop variables**: `{{@index}}` (0-based), `{{@index1}}` (1-based), `{{@first}}` and `{{@last}}` are available in `#each` pages, `{{array[].field}}` rows, `#rows` blocks and `#grid` data rows. They refer to the innermost loop; using them on a header/total row or outside a loop is a located error in `check` and at render time.
|
|
213
213
|
- **Aggregates**: `{{classes[].avg:sum}}` (also `avg`, `min`, `max`) and `{{classes[]:count}}` work in body text, table total rows and `#each` items. Single-level arrays with numeric fields only; nil values are skipped; no expressions, sorting or filtering.
|
|
214
214
|
- **Asset resolution**: picture fields are references. By default they are local paths; `PowerTom.configure { |c| c.asset_resolver = ... }` (or `render(..., asset_resolver:)`) lets an application return a path or `{data:, extension:}` from object storage. PowerTom never fetches URLs itself, so the resolver stays the security boundary.
|
|
215
|
-
- **Charts**: name the chart shape or its alt text `powertom:chart:sales` and pass `{ categories, series, number_format }` in the data; the whole data set is replaced and series formatting is inherited from the template. Supported: bar/column, line, area, pie (exactly one series), doughnut and **radar** (including the filled variant — `radarStyle` and radial-axis scaling such as a fixed maximum are preserved). Combo charts and scatter/bubble charts use a different contract — see Limitations.
|
|
215
|
+
- **Charts**: name the chart shape or its alt text `powertom:chart:sales` and pass `{ categories, series, number_format }` in the data; the whole data set is replaced and series formatting is inherited from the template. On standard charts (bar/column, line, area, doughnut, radar) a series count that differs from the template renders fine but emits a warning — added series inherit the last template series' formatting, removed series lose theirs. Supported: bar/column, line, area, pie (exactly one series), doughnut and **radar** (including the filled variant — `radarStyle` and radial-axis scaling such as a fixed maximum are preserved). Combo charts and scatter/bubble charts use a different contract — see Limitations.
|
|
216
216
|
- One directive per notes page, maximum.
|
|
217
217
|
- TOML dates are written unquoted (`report_date = 2026-01-20`), normalised to Ruby `Date`, and can be formatted with `{{report_date:date.cn}}`.
|
|
218
218
|
- Full guide for designers: [docs/template-guide.md](https://github.com/ixepet/powertom/blob/main/docs/template-guide.md).
|
|
@@ -337,7 +337,7 @@ one that lists eleven problems.
|
|
|
337
337
|
| Limitation | Notes |
|
|
338
338
|
| --- | --- |
|
|
339
339
|
| Tables support row loops, paired row blocks, nesting and dynamic columns | `{{classes[].name}}` clones one row; `{{#rows ...}} ... {{/rows}}` clones multi-row records (3 levels); `{{#grid ...}}` / `{{#cols ...}}` clone columns; merged cells inside loops are rejected |
|
|
340
|
-
| Charts: bar/column/line/area/pie/doughnut, radar, combo and scatter/bubble are data-bound | Name the chart shape `powertom:chart:<field>`; pie charts accept exactly one series (use doughnut for multiple rings); combo/scatter/bubble bind in document order and require exactly the template's series count (scatter/bubble carry `points: [{x, y(, size)}]` per series instead of shared categories); text tags inside charts are left as-is and reported as warnings |
|
|
340
|
+
| Charts: bar/column/line/area/pie/doughnut, radar, combo and scatter/bubble are data-bound | Name the chart shape `powertom:chart:<field>`; pie charts accept exactly one series (use doughnut for multiple rings); standard charts allow add/remove series but warn when the count differs from the template (added series inherit the last series' formatting); combo/scatter/bubble bind in document order and require exactly the template's series count (scatter/bubble carry `points: [{x, y(, size)}]` per series instead of shared categories); text tags inside charts are left as-is and reported as warnings |
|
|
341
341
|
| Notes are not rendered | Notes are only read for page directives; ordinary tags in notes produce a warning |
|
|
342
342
|
| Tags on masters/layouts are rejected | Only shapes on slides are processed; `PowerTom.check` reports these tags as errors because they never take effect |
|
|
343
343
|
| No PPT → PDF | Use LibreOffice headless |
|
|
@@ -37,8 +37,14 @@ module PowerTom
|
|
|
37
37
|
|
|
38
38
|
# 输出映射:每个输出页对应哪张原始页(含其 notes 部件)
|
|
39
39
|
outputs = @plan.map do |p|
|
|
40
|
-
|
|
41
|
-
|
|
40
|
+
# 注意不能用 order[p[:source] - 1] + nil 检查:Ruby 负下标会回绕,
|
|
41
|
+
# order[-1] 返回最后一页而不是 nil,source=0 会静默克隆错页
|
|
42
|
+
idx = p[:source].is_a?(Integer) ? p[:source] - 1 : -1
|
|
43
|
+
src = idx >= 0 && idx < order.size ? order[idx] : nil
|
|
44
|
+
unless src
|
|
45
|
+
raise Error,
|
|
46
|
+
"slide number out of range: #{p[:source].inspect} (there are #{order.size} slides)"
|
|
47
|
+
end
|
|
42
48
|
|
|
43
49
|
{ src_slide: src, src_notes: notes_part_for(parts, p[:source]) }
|
|
44
50
|
end
|
|
@@ -222,35 +228,43 @@ module PowerTom
|
|
|
222
228
|
%r{\Appt/_rels/presentation\.xml\.rels\z}
|
|
223
229
|
].freeze
|
|
224
230
|
|
|
231
|
+
# zip entry 名安全:模板来自用户上传,entry 名不可信。
|
|
232
|
+
# 拒绝 ../ 穿越、绝对路径、Windows 盘符与任意 .. 段,防 zip-slip
|
|
233
|
+
# (rubyzip 的 put_next_entry 不净化 entry 名,会原样写入)。
|
|
234
|
+
UNSAFE_ENTRY_RE = %r{\A(\.\./|/|[A-Za-z]:[\\/])|(^|/)\.\.(/|\z)}
|
|
235
|
+
|
|
225
236
|
def write_zip(parts, rewritten)
|
|
226
237
|
Zip::OutputStream.open(@out_path) do |zos|
|
|
227
|
-
zos.
|
|
228
|
-
zos.write(rewritten.fetch("[Content_Types].xml"))
|
|
238
|
+
put_entry(zos, "[Content_Types].xml", rewritten.fetch("[Content_Types].xml"))
|
|
229
239
|
|
|
230
240
|
parts.each do |name, data|
|
|
231
241
|
next if name == "[Content_Types].xml"
|
|
232
242
|
next if SKIP_PATTERNS.any? { |re| name.match?(re) }
|
|
233
243
|
|
|
234
|
-
zos
|
|
235
|
-
zos.write(data)
|
|
244
|
+
put_entry(zos, name, data)
|
|
236
245
|
end
|
|
237
246
|
|
|
238
247
|
{ "ppt/presentation.xml" => "ppt/presentation.xml",
|
|
239
248
|
"ppt/_rels/presentation.xml.rels" => "ppt/_rels/presentation.xml.rels" }.each do |key, name|
|
|
240
|
-
zos.
|
|
241
|
-
zos.write(rewritten.fetch(key))
|
|
249
|
+
put_entry(zos, name, rewritten.fetch(key))
|
|
242
250
|
end
|
|
243
251
|
|
|
244
252
|
%w[slide_parts notes_parts].each do |group|
|
|
245
253
|
rewritten.fetch(group).each do |entries|
|
|
246
254
|
entries.each do |name, data|
|
|
247
|
-
zos
|
|
248
|
-
zos.write(data)
|
|
255
|
+
put_entry(zos, name, data)
|
|
249
256
|
end
|
|
250
257
|
end
|
|
251
258
|
end
|
|
252
259
|
end
|
|
253
260
|
end
|
|
261
|
+
|
|
262
|
+
def put_entry(zos, name, data)
|
|
263
|
+
raise Error, "unsafe zip entry name in template package: #{name.inspect}" if name.match?(UNSAFE_ENTRY_RE)
|
|
264
|
+
|
|
265
|
+
zos.put_next_entry(name)
|
|
266
|
+
zos.write(data)
|
|
267
|
+
end
|
|
254
268
|
end
|
|
255
269
|
end
|
|
256
270
|
end
|
|
@@ -196,10 +196,11 @@ module PowerTom
|
|
|
196
196
|
entry = { slide_no: i + 1, shape: shape.name, field: field,
|
|
197
197
|
slide: slide, chart_shape: shape, kind: kind,
|
|
198
198
|
mode_error: error }
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
199
|
+
# 系列数/分布对所有支持的 kind 都采集:combo/XY/BUBBLE 数量不符是
|
|
200
|
+
# 硬错误,标准图表(BAR/LINE/AREA/DOUGHNUT/RADAR)数量不符只记 warning
|
|
201
|
+
# (新增系列继承最后一个模板系列的格式,被裁掉的系列格式消失)。
|
|
202
|
+
entry[:series_count] = chart_series_count(shape.chart)
|
|
203
|
+
entry[:distribution] = chart_distribution_label(shape.chart)
|
|
203
204
|
contexts << entry
|
|
204
205
|
end
|
|
205
206
|
end
|
data/lib/powertom/cli.rb
CHANGED
|
@@ -145,6 +145,12 @@ module PowerTom
|
|
|
145
145
|
rescue PowerTom::Error => e
|
|
146
146
|
@err.puts "powertom: #{e.message}"
|
|
147
147
|
1
|
|
148
|
+
rescue StandardError => e
|
|
149
|
+
# 兜底:上游(ruby_pptx 等)抛的异常不一定是 PowerTom::Error 子类,
|
|
150
|
+
# 退出码是稳定契约 —— 渲染失败必须返回 1,而不是把 Ruby backtrace
|
|
151
|
+
# 甩给 CI 用户(check 侧已有同样的兜底,返回 2)
|
|
152
|
+
@err.puts "powertom: render failed: #{e.class}: #{e.message}"
|
|
153
|
+
1
|
|
148
154
|
end
|
|
149
155
|
|
|
150
156
|
# TOML 交给库的默认 loader;JSON 在 CLI 层解析成 Hash 后传入,
|
data/lib/powertom/render.rb
CHANGED
|
@@ -85,6 +85,10 @@ module PowerTom
|
|
|
85
85
|
# → 绑定(#each 页取迭代作用域)→ 保存。
|
|
86
86
|
# 任何抛错都发生在写盘之前:产物要么完整要么不存在。
|
|
87
87
|
class Render
|
|
88
|
+
# 系列数可自由增减的标准图表:数量与模板不符时只记 warning
|
|
89
|
+
# (combo/XY/BUBBLE 数量不符是硬错误;pie 多系列是硬错误)。
|
|
90
|
+
STANDARD_CHART_KINDS = %i[BAR LINE AREA DOUGHNUT RADAR].freeze
|
|
91
|
+
|
|
88
92
|
def initialize(template_path, data:, strict:, asset_resolver: nil)
|
|
89
93
|
@template_path = template_path
|
|
90
94
|
@data = data
|
|
@@ -267,7 +271,7 @@ module PowerTom
|
|
|
267
271
|
# 克隆页共享 chart part,adapter 在绑定前为该形状深拷贝独立 part
|
|
268
272
|
# (docs/chart-binding-design.md)。与图片一样作用域感知:#each 克隆页
|
|
269
273
|
# 各自绑定本项的数据;缺字段(strict: false)时保留占位图表。
|
|
270
|
-
def bind_charts(adapter, prs, page_scopes, binder,
|
|
274
|
+
def bind_charts(adapter, prs, page_scopes, binder, warnings)
|
|
271
275
|
adapter.chart_contexts(prs).each do |cctx|
|
|
272
276
|
if cctx[:mode_error]
|
|
273
277
|
raise PowerTom::Error,
|
|
@@ -294,6 +298,7 @@ module PowerTom
|
|
|
294
298
|
validate_chart_data!(value, cctx)
|
|
295
299
|
validate_chart_series_count!(value, cctx) if cctx[:kind] == :combo
|
|
296
300
|
validate_pie_series_count!(value, cctx) if cctx[:kind] == :PIE
|
|
301
|
+
warn_chart_series_count!(value, cctx, warnings) if STANDARD_CHART_KINDS.include?(cctx[:kind])
|
|
297
302
|
end
|
|
298
303
|
adapter.replace_chart_data(prs, cctx[:chart_shape], cctx[:slide], value)
|
|
299
304
|
end
|
|
@@ -358,6 +363,29 @@ module PowerTom
|
|
|
358
363
|
"order, got #{count}"
|
|
359
364
|
end
|
|
360
365
|
|
|
366
|
+
# 标准图表系列数与模板不符时记 warning(不阻断):上游会把多出的系列
|
|
367
|
+
# 克隆自最后一个模板系列(继承其格式),裁掉多余的系列(其格式随之消失)。
|
|
368
|
+
# 设计取舍见 docs/feature-direction.md §1 decision 3。
|
|
369
|
+
def warn_chart_series_count!(value, cctx, warnings)
|
|
370
|
+
series = chart_field_value(value, "series")
|
|
371
|
+
return unless series.is_a?(Array)
|
|
372
|
+
|
|
373
|
+
data_count = series.size
|
|
374
|
+
template_count = cctx[:series_count]
|
|
375
|
+
return if data_count == template_count
|
|
376
|
+
|
|
377
|
+
where = "slide #{cctx[:slide_no]} chart '#{cctx[:shape]}' field '#{cctx[:field]}'"
|
|
378
|
+
base = "#{where}: data provides #{data_count} series but the template draws " \
|
|
379
|
+
"#{cctx[:distribution]} (#{template_count} series)"
|
|
380
|
+
warnings << if data_count > template_count
|
|
381
|
+
"#{base}; the #{data_count - template_count} added series " \
|
|
382
|
+
"inherit the last template series' formatting"
|
|
383
|
+
else
|
|
384
|
+
"#{base}; the last #{template_count - data_count} template series " \
|
|
385
|
+
"are removed along with their formatting"
|
|
386
|
+
end
|
|
387
|
+
end
|
|
388
|
+
|
|
361
389
|
# 饼图只绘制第一个系列:多余系列会被静默丢弃,必须在写入前拒绝。
|
|
362
390
|
# 圆环图支持多系列(同心环),不受此守卫影响。
|
|
363
391
|
def validate_pie_series_count!(value, cctx)
|
data/lib/powertom/table_loop.rb
CHANGED
|
@@ -362,6 +362,7 @@ module PowerTom
|
|
|
362
362
|
check_grid_no_loop_labels!(rows)
|
|
363
363
|
check_grid_header_labels!(rows[marker[:row]], marker[:row])
|
|
364
364
|
check_grid_content_labels!(rows[content], content)
|
|
365
|
+
check_grid_static_rows!(rows, marker[:row], content)
|
|
365
366
|
|
|
366
367
|
{
|
|
367
368
|
kind: :grid,
|
|
@@ -372,6 +373,26 @@ module PowerTom
|
|
|
372
373
|
}
|
|
373
374
|
end
|
|
374
375
|
|
|
376
|
+
# 静态行(header/content 之外,如合计行):不允许 grid 作用域变量。
|
|
377
|
+
# render 侧只有 header/content 行有 row/col/cell 作用域,静态行写了会在
|
|
378
|
+
# 渲染期才抛错 —— 这里提前拦截,保证 check 报错、render 同样报错(§7.2)。
|
|
379
|
+
def check_grid_static_rows!(rows, header_index, content_index)
|
|
380
|
+
rows.each_with_index do |cells, index|
|
|
381
|
+
next if index == header_index || index == content_index
|
|
382
|
+
|
|
383
|
+
cells.each_with_index do |text, col|
|
|
384
|
+
label_paths(text).each do |path|
|
|
385
|
+
next unless scope_variable?(path)
|
|
386
|
+
|
|
387
|
+
raise TemplateSyntaxError,
|
|
388
|
+
"table row #{index + 1}, column #{col + 1}: {{#{path}}} is a grid scope variable " \
|
|
389
|
+
"and can only be used in the grid header or content row " \
|
|
390
|
+
"(row #{header_index + 1} / row #{content_index + 1}); static rows take page fields only"
|
|
391
|
+
end
|
|
392
|
+
end
|
|
393
|
+
end
|
|
394
|
+
end
|
|
395
|
+
|
|
375
396
|
def check_grid_no_loop_labels!(rows)
|
|
376
397
|
rows.each_with_index do |cells, index|
|
|
377
398
|
next if cells.none? { |text| loop_roots(text).any? }
|
data/lib/powertom/validator.rb
CHANGED
|
@@ -760,12 +760,15 @@ module PowerTom
|
|
|
760
760
|
end
|
|
761
761
|
end
|
|
762
762
|
|
|
763
|
-
#
|
|
764
|
-
#
|
|
765
|
-
#
|
|
763
|
+
# 绑定系列数校验(check 侧,与 render 同一规则,设计文档 §9):
|
|
764
|
+
# - combo 与 XY 家族(scatter/bubble):数量必须等于模板系列总数,否则上游
|
|
765
|
+
# 会静默增删 plot / 错位重写系列 → error
|
|
766
|
+
# - 标准图表(BAR/LINE/AREA/DOUGHNUT/RADAR,即 Render::STANDARD_CHART_KINDS):
|
|
767
|
+
# 数量可增减,但不符时记 warning —— 新增系列继承最后一个模板系列的格式,
|
|
768
|
+
# 被裁掉的系列格式随之消失(feature-direction.md §1 decision 3)
|
|
769
|
+
# - PIE:多系列已有硬错误(check_pie_series_count),不在此处理
|
|
766
770
|
def check_chart_series_count(value, cctx, entries, item_index = nil)
|
|
767
771
|
return if value.nil?
|
|
768
|
-
return unless %i[combo XY BUBBLE].include?(cctx[:kind])
|
|
769
772
|
|
|
770
773
|
series = value.key?(:series) ? value[:series] : value["series"]
|
|
771
774
|
return unless series.is_a?(Array)
|
|
@@ -773,12 +776,25 @@ module PowerTom
|
|
|
773
776
|
return if series.size == cctx[:series_count]
|
|
774
777
|
|
|
775
778
|
where = item_index ? "item #{item_index + 1}: " : ""
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
779
|
+
base = "chart template draws #{cctx[:distribution]} (#{cctx[:series_count]} series in " \
|
|
780
|
+
"total); data provides #{series.size} series"
|
|
781
|
+
if %i[combo XY BUBBLE].include?(cctx[:kind])
|
|
782
|
+
entries << error_entry(
|
|
783
|
+
cctx[:slide_no], cctx[:shape], cctx[:field],
|
|
784
|
+
"#{where}#{base}; the data must provide exactly #{cctx[:series_count]} series in " \
|
|
785
|
+
"document order"
|
|
786
|
+
)
|
|
787
|
+
elsif %i[BAR LINE AREA DOUGHNUT RADAR].include?(cctx[:kind])
|
|
788
|
+
consequence = if series.size > cctx[:series_count]
|
|
789
|
+
"the #{series.size - cctx[:series_count]} added series inherit " \
|
|
790
|
+
"the last template series' formatting"
|
|
791
|
+
else
|
|
792
|
+
"the last #{cctx[:series_count] - series.size} template series are " \
|
|
793
|
+
"removed along with their formatting"
|
|
794
|
+
end
|
|
795
|
+
entries << CheckEntry.new(level: :warning, slide_no: cctx[:slide_no], shape: cctx[:shape],
|
|
796
|
+
label: cctx[:field], message: "#{where}#{base}; #{consequence}")
|
|
797
|
+
end
|
|
782
798
|
end
|
|
783
799
|
|
|
784
800
|
# 饼图只绘制第一个系列:多余系列会被静默丢弃,check 阶段直接报 error
|
|
@@ -1000,6 +1016,7 @@ module PowerTom
|
|
|
1000
1016
|
cols = plan[:cols] ? (resolve_grid_array(plan[:cols][:path], ctx, data, entries) || []) : []
|
|
1001
1017
|
reconcile_column_ifs(plan[:cols], cols, ctx, data, entries)
|
|
1002
1018
|
reconcile_static_band_header(plan, cols, labels_by_row, ctx, data, entries)
|
|
1019
|
+
reconcile_static_band_rows(plan, cols, labels_by_row, ctx, data, entries)
|
|
1003
1020
|
reconcile_blocks(plan[:blocks], {}, nil, cols, plan[:cols], labels_by_row, ctx, data, entries)
|
|
1004
1021
|
end
|
|
1005
1022
|
end
|
|
@@ -1017,6 +1034,27 @@ module PowerTom
|
|
|
1017
1034
|
end
|
|
1018
1035
|
end
|
|
1019
1036
|
|
|
1037
|
+
# 列带区间内的其他静态行(不在任何行区块内、也不是声明行本身):主对账循环被
|
|
1038
|
+
# block_band_cell? 跳过,render 侧却会为这些单元格提供 col 作用域 —— 这里补对账
|
|
1039
|
+
# (col.* 逐列项、普通字段按整页数据),避免 check 放行而 render 才抛缺字段(§7.2)
|
|
1040
|
+
def reconcile_static_band_rows(plan, cols, labels_by_row, ctx, data, entries)
|
|
1041
|
+
band = plan[:cols]
|
|
1042
|
+
return unless band
|
|
1043
|
+
|
|
1044
|
+
stacks = TableLoop.build_row_stacks(plan[:blocks])
|
|
1045
|
+
labels_by_row.each do |(slide_no, shape, row_index), labels|
|
|
1046
|
+
next unless slide_no == ctx[:slide_no] && shape == ctx[:shape]
|
|
1047
|
+
next if stacks[row_index] # 区块内的行由 reconcile_blocks 覆盖
|
|
1048
|
+
next if row_index == band[:row] # 声明行由 reconcile_static_band_header 覆盖
|
|
1049
|
+
|
|
1050
|
+
labels.each do |label|
|
|
1051
|
+
next unless label[:context][:col_index].to_i.between?(band[:first_col], band[:last_col])
|
|
1052
|
+
|
|
1053
|
+
reconcile_block_label(label, {}, nil, cols, band, "static row #{row_index + 1}", data, entries)
|
|
1054
|
+
end
|
|
1055
|
+
end
|
|
1056
|
+
end
|
|
1057
|
+
|
|
1020
1058
|
# 列条件:每个列项都要能取到条件字段
|
|
1021
1059
|
def reconcile_column_ifs(band, cols, ctx, data, entries)
|
|
1022
1060
|
return unless band && band[:ifs]&.any?
|
data/lib/powertom/version.rb
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
3
|
module PowerTom
|
|
4
|
+
# 0.9.2:check/render 对账缺口修复(#grid 静态行、列带静态行)、PageSurgery 越界
|
|
5
|
+
# 页号与 zip-slip 加固、CLI render 非 PowerTom::Error 异常的退出码兜底。
|
|
4
6
|
# 0.9.1:表格区块的两处结构校验修复——列带冲突精确到列(放行静态行固定列合并),
|
|
5
7
|
# 子块路径 relative 禁止再含 [](改写成多级嵌套区块)。
|
|
6
8
|
# 0.9.0:Windows 文件锁修复(rubyzip 句柄泄漏 + Tempfile finalizer 竞态)、
|
|
7
9
|
# check 契约修复(不抛异常,与 render 共享同一套规则集)、
|
|
8
10
|
# ruby_pptx 0.3.1 版本门控;并含 0.8.0 的受限聚合与 AssetResolver
|
|
9
|
-
VERSION = "0.9.
|
|
11
|
+
VERSION = "0.9.2"
|
|
10
12
|
end
|