Extract template parameters without -WithText flag

Parameters from [ParamName] placeholders in template text are now always
extracted and shown with [tpl] suffix. Numeric-only placeholders like [5]
(footnote references in legal forms) are filtered out.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Nick Shirokov
2026-02-08 16:17:50 +03:00
parent 1a79e84598
commit 455c12e6b6
2 changed files with 37 additions and 7 deletions
+16
View File
@@ -118,6 +118,22 @@ In BSL:
Область.Параметры.РасшифровкаТовар = СтрокаТЧ.Номенклатура; // detailParameter
```
### Template parameters (`[tpl]` suffix)
Some parameters are embedded in template text: `"Инв № [ИнвентарныйНомер]"`. These are filled via fillType=Template, not fillType=Parameter. The script always extracts them and marks with `[tpl]`:
```
НумерацияЛистов: Номер [tpl], Дата [tpl], НомерЛиста [tpl]
```
In BSL, template parameters are filled the same way as regular ones:
```bsl
Область.Параметры.Номер = НомерДокумента;
Область.Параметры.Дата = ДатаДокумента;
```
Numeric-only placeholders like `[5]`, `[6]` (footnote references in legal forms) are ignored.
### Text content (`-WithText`)
Shows static text (labels, headers) and template strings with `[Param]` placeholders:
+21 -7
View File
@@ -132,14 +132,26 @@ function Get-CellData {
$results += $entry
}
if ($includeText -and $tl) {
if ($tl) {
$content = $tl.SelectSingleNode("v8:item/v8:content", $ns)
if ($content -and $content.InnerText) {
$text = $content.InnerText
# Detect if this is a Template (has [...] placeholders)
if ($text -match '\[.+\]') {
$results += @{ Kind = "Template"; Value = $text }
} else {
$isTemplate = $text -match '\[.+\]'
if ($isTemplate) {
# Always extract parameter names from [Param] placeholders
# Skip numeric-only like [5] — these are footnote refs in legal forms
foreach ($m in [regex]::Matches($text, '\[([^\]]+)\]')) {
$val = $m.Groups[1].Value
if ($val -notmatch '^\d+$') {
$results += @{ Kind = "TemplateParam"; Value = $val }
}
}
# Full template text only with -WithText
if ($includeText) {
$results += @{ Kind = "Template"; Value = $text }
}
} elseif ($includeText) {
$results += @{ Kind = "Text"; Value = $text }
}
}
@@ -175,8 +187,9 @@ function Get-AreaCellData {
$params += $c.Value
if ($c.Detail) { $details += "$($c.Value)->$($c.Detail)" }
}
"Text" { $texts += $c.Value }
"Template" { $templates += $c.Value }
"TemplateParam" { $params += "$($c.Value) [tpl]" }
"Text" { $texts += $c.Value }
"Template" { $templates += $c.Value }
}
}
}
@@ -229,6 +242,7 @@ foreach ($r in $rowMap.Keys | Sort-Object) {
$outsideParams += $c.Value
if ($c.Detail) { $outsideDetails += "$($c.Value)->$($c.Detail)" }
}
"TemplateParam" { $outsideParams += "$($c.Value) [tpl]" }
"Text" { $outsideTexts += $c.Value }
"Template" { $outsideTemplates += $c.Value }
}