Skip to content

Commit 92aeef5

Browse files
author
lyfhf
committed
fix: align PowerShell 7 document handling
1 parent 16602fd commit 92aeef5

2 files changed

Lines changed: 19 additions & 9 deletions

File tree

scripts/generate-docx-field-map.ps1

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -607,12 +607,25 @@ $sectionRules = @(
607607
}
608608
)
609609

610+
$sectionHeadingLookupKeys = @{}
611+
foreach ($rule in $sectionRules) {
612+
foreach ($alias in @($rule.aliases)) {
613+
$headingKey = Get-SectionHeadingLookupKey -Text ([string]$alias)
614+
if (-not [string]::IsNullOrWhiteSpace($headingKey)) {
615+
$sectionHeadingLookupKeys[$headingKey] = $true
616+
}
617+
}
618+
}
619+
610620
$extraSectionRules = @(
611621
foreach ($heading in $extraSectionHeadings) {
612622
$headingKey = Get-SectionHeadingLookupKey -Text ([string]$heading)
613623
if ([string]::IsNullOrWhiteSpace($headingKey)) {
614624
continue
615625
}
626+
if ($sectionHeadingLookupKeys.ContainsKey($headingKey)) {
627+
continue
628+
}
616629

617630
[pscustomobject]@{
618631
id = "__extra_section_$headingKey"

scripts/insert-docx-images.ps1

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1023,16 +1023,15 @@ function Get-SingleXmlNode {
10231023
)
10241024

10251025
if ($NodeLike -is [System.Xml.XmlNode]) {
1026-
Write-Output -NoEnumerate $NodeLike
1027-
return
1026+
return ,$NodeLike
10281027
}
10291028

10301029
$candidates = @($NodeLike | Where-Object { $_ -is [System.Xml.XmlNode] })
10311030
if ($candidates.Count -eq 0) {
10321031
throw "Expected an XmlNode-compatible value."
10331032
}
10341033

1035-
Write-Output -NoEnumerate $candidates[0]
1034+
return ,$candidates[0]
10361035
}
10371036

10381037
function New-ImageParagraph {
@@ -1424,8 +1423,7 @@ function Get-SectionEndInsertionNode {
14241423
)
14251424

14261425
if ($TargetNode.LocalName -ne "p" -or $TargetNode.ParentNode.LocalName -ne "body") {
1427-
Write-Output -NoEnumerate $TargetNode
1428-
return
1426+
return ,$TargetNode
14291427
}
14301428

14311429
$insertionNode = $TargetNode
@@ -1446,7 +1444,7 @@ function Get-SectionEndInsertionNode {
14461444
$cursor = $cursor.NextSibling
14471445
}
14481446

1449-
Write-Output -NoEnumerate $insertionNode
1447+
return ,$insertionNode
14501448
}
14511449

14521450
function Get-EffectiveInsertionNode {
@@ -1461,11 +1459,10 @@ function Get-EffectiveInsertionNode {
14611459
$targetNode = Get-SingleXmlNode -NodeLike $ResolvedTarget.Node
14621460
if ([string]$ResolvedTarget.ResolutionKey -like "section:*") {
14631461
$sectionEndNode = Get-SectionEndInsertionNode -TargetNode $targetNode -NamespaceManager $NamespaceManager
1464-
Write-Output -NoEnumerate $sectionEndNode
1465-
return
1462+
return ,$sectionEndNode
14661463
}
14671464

1468-
Write-Output -NoEnumerate $targetNode
1465+
return ,$targetNode
14691466
}
14701467

14711468
function Get-EffectiveRowLayoutTarget {

0 commit comments

Comments
 (0)