diff --git a/.claude/skills/mxl-compile/scripts/mxl-compile.ps1 b/.claude/skills/mxl-compile/scripts/mxl-compile.ps1 index 5b4c5cf8..148107b0 100644 --- a/.claude/skills/mxl-compile/scripts/mxl-compile.ps1 +++ b/.claude/skills/mxl-compile/scripts/mxl-compile.ps1 @@ -285,6 +285,9 @@ function Register-CellFormat { # Pre-register all formats from areas foreach ($area in $def.areas) { foreach ($row in $area.rows) { + # Skip empty row placeholder + if ($row.empty) { continue } + # Row height format if ($row.height) { $hKey = Get-FormatKey -height ([int]$row.height) @@ -362,6 +365,21 @@ foreach ($area in $def.areas) { $localRow = 0 foreach ($row in $area.rows) { + # Empty row placeholder: emit N empty rows + if ($row.empty) { + $count = [int]$row.empty + for ($ei = 0; $ei -lt $count; $ei++) { + X "`t" + X "`t`t$globalRow" + X "`t`t" + X "`t`t`ttrue" + X "`t`t" + X "`t" + $globalRow++; $localRow++ + } + continue + } + # Build set of columns occupied by rowspans from previous rows $rowspanOccupied = @{} # 1-based col -> $true foreach ($rs in $activeRowspans) { diff --git a/.claude/skills/mxl-decompile/scripts/mxl-decompile.ps1 b/.claude/skills/mxl-decompile/scripts/mxl-decompile.ps1 index e822e9cb..70df68d2 100644 --- a/.claude/skills/mxl-decompile/scripts/mxl-decompile.ps1 +++ b/.claude/skills/mxl-decompile/scripts/mxl-decompile.ps1 @@ -520,9 +520,29 @@ foreach ($area in $namedAreas) { $areaRows += $dslRow } + # Compress consecutive empty rows ({}) into { empty = N } + $compressedRows = @() + $emptyRun = 0 + foreach ($r in $areaRows) { + if ($r.Count -eq 0) { + $emptyRun++ + } else { + if ($emptyRun -gt 0) { + if ($emptyRun -eq 1) { $compressedRows += [ordered]@{} } + else { $compressedRows += [ordered]@{ empty = $emptyRun } } + $emptyRun = 0 + } + $compressedRows += $r + } + } + if ($emptyRun -gt 0) { + if ($emptyRun -eq 1) { $compressedRows += [ordered]@{} } + else { $compressedRows += [ordered]@{ empty = $emptyRun } } + } + $dslAreas += [ordered]@{ name = $area.Name - rows = [array]$areaRows + rows = [array]$compressedRows } } @@ -579,6 +599,18 @@ if ($styleDefs.Contains("default") -and $styleDefs["default"].Count -eq 0) { $styleDefs.Remove("default") } +# Remove unused styles +$usedStyles = @{} +foreach ($a in $dslAreas) { + foreach ($r in $a.rows) { + if ($r.rowStyle) { $usedStyles[$r.rowStyle] = $true } + if ($r.cells) { foreach ($c in $r.cells) { if ($c.style) { $usedStyles[$c.style] = $true } } } + } +} +$toRemove = @($styleDefs.Keys | Where-Object { -not $usedStyles.ContainsKey($_) }) +foreach ($s in $toRemove) { $styleDefs.Remove($s) +} + $result["fonts"] = $fontsOut $result["styles"] = $styleDefs $result["areas"] = [array]$dslAreas diff --git a/docs/mxl-dsl-spec.md b/docs/mxl-dsl-spec.md index d7d952b5..be478fce 100644 --- a/docs/mxl-dsl-spec.md +++ b/docs/mxl-dsl-spec.md @@ -119,8 +119,9 @@ | `height` | — | Высота строки (если не задана, используется авто) | | `rowStyle` | — | Стиль для ВСЕХ колонок (заполняет пустоты рамками) | | `cells` | `[]` | Массив ячеек | +| `empty` | — | Количество подряд идущих пустых строк (заменяет N отдельных `{}`) | -Строка без `cells` и `rowStyle` → пустая строка. +Строка без `cells` и `rowStyle` → пустая строка. `{ "empty": 3 }` эквивалентно трём `{}`. ## Ячейки (`cells[]`)