From 7d2feb6f84ba766193b4041b9d6ee375a354e98e Mon Sep 17 00:00:00 2001 From: clover caruso Date: Fri, 11 Sep 2026 04:01:57 -0700 Subject: [PATCH] test: capture native paragraph formatting and style inheritance Add a six-case native fixture covering defaults, explicit zero, alignment, spacing, RTL layout and named-style overrides with mixed text runs. Compare the captured notebook with native XML before expanding paragraph authoring. Assisted-by: gpt-6-astra --- tools/native/paragraph-formatting.ps1 | 39 +++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 tools/native/paragraph-formatting.ps1 diff --git a/tools/native/paragraph-formatting.ps1 b/tools/native/paragraph-formatting.ps1 new file mode 100644 index 0000000000000000000000000000000000000000..93ee9beea196c50f82271116a38124d9ac44350a --- /dev/null +++ b/tools/native/paragraph-formatting.ps1 @@ -0,0 +1,39 @@ +param([Parameter(Mandatory=$true)][string]$Root, [Parameter(Mandatory=$true)][string]$CloneHost) +Set-StrictMode -Version Latest +$ErrorActionPreference = 'Stop' +& "$PSScriptRoot\cold-current.ps1" -Root $Root -CloneHost $CloneHost +$app = New-Object -ComObject OneNote.Application +$notebook = '' +try { + $app.OpenHierarchy((Join-Path $Root 'notebook'), '', [ref]$notebook, 0) + $section = '' + $app.OpenHierarchy('synthetic.one', $notebook, [ref]$section, 0) + $page = '' + $app.CreateNewPage($section, [ref]$page, 0) + $cases = @( + @{ name = 'Default'; attributes = '' }, + @{ name = 'Explicit zero'; attributes = ' alignment="left" RTL="false" spaceBefore="0" spaceAfter="0" spaceBetween="0"' }, + @{ name = 'Center spaced'; attributes = ' alignment="center" spaceBefore="12" spaceAfter="6" spaceBetween="20"' }, + @{ name = 'Right RTL'; attributes = ' alignment="right" RTL="true" spaceBefore="3" spaceAfter="9" spaceBetween="18"' }, + @{ name = 'Style inherited'; attributes = ' quickStyleIndex="1"' }, + @{ name = 'Style overridden'; attributes = ' quickStyleIndex="1" alignment="center" spaceBefore="0" spaceAfter="2" spaceBetween="16"' } + ) + $body = '' + $body += 'Paragraph formatting' + foreach ($case in $cases) { + $body += 'bold italic plain]]>' + } + $body += '' + $xml = '' + $body + '' + $inputs = Join-Path $Root 'inputs' + New-Item -ItemType Directory -Path $inputs | Out-Null + [IO.File]::WriteAllText((Join-Path $inputs 'paragraph-formatting.xml'), $xml, [Text.Encoding]::UTF8) + $app.UpdatePageContent($xml, [DateTime]::MinValue, 1, $true) + $app.SyncHierarchy($notebook) +} finally { + if ($notebook) { $app.CloseNotebook($notebook, $false) } + [void][Runtime.InteropServices.Marshal]::FinalReleaseComObject($app) + $app = $null + [GC]::Collect() + [GC]::WaitForPendingFinalizers() +} -- 2.54.0