authorgravatar for git@paperclover.netclover caruso <git@paperclover.net> 2026-09-11 04:01:57-07:00
committergravatar for git@paperclover.netclover caruso <git@paperclover.net> 2026-09-12 17:00:32-07:00
log7d2feb6f84ba766193b4041b9d6ee375a354e98e
treed9b41077c64078a45ec18bdd6122ccbda0d79276
parentd956049b4eeac2458cf646e61eb29a90390ff59f
signature Signed by SSH key SHA256:52mNGHRsVFBDED9IAX5pe+LRWUefqTbxEReunq21QvU

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

1 files changed, 39 insertions(+), 0 deletions(-)

tools/native/paragraph-formatting.ps1 created+39
...@@ -0,0 +1,39 @@
1param([Parameter(Mandatory=$true)][string]$Root, [Parameter(Mandatory=$true)][string]$CloneHost)
2Set-StrictMode -Version Latest
3$ErrorActionPreference = 'Stop'
4& "$PSScriptRoot\cold-current.ps1" -Root $Root -CloneHost $CloneHost
5$app = New-Object -ComObject OneNote.Application
6$notebook = ''
7try {
8 $app.OpenHierarchy((Join-Path $Root 'notebook'), '', [ref]$notebook, 0)
9 $section = ''
10 $app.OpenHierarchy('synthetic.one', $notebook, [ref]$section, 0)
11 $page = ''
12 $app.CreateNewPage($section, [ref]$page, 0)
13 $cases = @(
14 @{ name = 'Default'; attributes = '' },
15 @{ name = 'Explicit zero'; attributes = ' alignment="left" RTL="false" spaceBefore="0" spaceAfter="0" spaceBetween="0"' },
16 @{ name = 'Center spaced'; attributes = ' alignment="center" spaceBefore="12" spaceAfter="6" spaceBetween="20"' },
17 @{ name = 'Right RTL'; attributes = ' alignment="right" RTL="true" spaceBefore="3" spaceAfter="9" spaceBetween="18"' },
18 @{ name = 'Style inherited'; attributes = ' quickStyleIndex="1"' },
19 @{ name = 'Style overridden'; attributes = ' quickStyleIndex="1" alignment="center" spaceBefore="0" spaceAfter="2" spaceBetween="16"' }
20 )
21 $body = '<one:QuickStyleDef index="0" name="p" font="Calibri" fontSize="11" fontColor="automatic" highlightColor="automatic"/><one:QuickStyleDef index="1" name="h1" font="Georgia" fontSize="18" bold="true" fontColor="#123456" highlightColor="automatic" spaceBefore="8" spaceAfter="4"/>'
22 $body += '<one:Title><one:OE><one:T>Paragraph formatting</one:T></one:OE></one:Title><one:Outline><one:Position x="72" y="108"/><one:OEChildren>'
23 foreach ($case in $cases) {
24 $body += '<one:OE' + $case.attributes + '><one:T><![CDATA[' + $case.name + ': <b>bold</b> <i>italic</i> plain]]></one:T></one:OE>'
25 }
26 $body += '</one:OEChildren></one:Outline>'
27 $xml = '<one:Page xmlns:one="http://schemas.microsoft.com/office/onenote/2010/onenote" ID="' + $page + '">' + $body + '</one:Page>'
28 $inputs = Join-Path $Root 'inputs'
29 New-Item -ItemType Directory -Path $inputs | Out-Null
30 [IO.File]::WriteAllText((Join-Path $inputs 'paragraph-formatting.xml'), $xml, [Text.Encoding]::UTF8)
31 $app.UpdatePageContent($xml, [DateTime]::MinValue, 1, $true)
32 $app.SyncHierarchy($notebook)
33} finally {
34 if ($notebook) { $app.CloseNotebook($notebook, $false) }
35 [void][Runtime.InteropServices.Marshal]::FinalReleaseComObject($app)
36 $app = $null
37 [GC]::Collect()
38 [GC]::WaitForPendingFinalizers()
39}