mirror of
https://github.com/Nikolay-Shirokov/cc-1c-skills.git
synced 2026-07-17 16:25:16 +03:00
fix(skd-edit): drop unneeded " → " in query/expression
Зеркалим решение из skd-compile: убираем .Replace('"','"') из Esc-Xml
и удаляем post-process, который принудительно ставил " внутри
<query>/<expression>. Реальный Конфигуратор так не пишет — экранирование
было анти-1С-стилем и портило round-trip diff.
Снимок add-calculated-field-restrict обновлён под новый формат.
Кейс preserve-entities-modify-parameter-title удалён: его смысл
инвертировался (теперь проверял бы нормализацию, а не сохранение),
а часть про многострочный xmlns уже покрыта preserve-xmlns-multiline.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
# skd-edit v1.21 — Atomic 1C DCS editor
|
||||
# skd-edit v1.22 — Atomic 1C DCS editor
|
||||
# Source: https://github.com/Nikolay-Shirokov/cc-1c-skills
|
||||
param(
|
||||
[Parameter(Mandatory)]
|
||||
@@ -50,7 +50,7 @@ $resolvedPath = (Resolve-Path $TemplatePath).Path
|
||||
|
||||
function Esc-Xml {
|
||||
param([string]$s)
|
||||
return $s.Replace('&','&').Replace('<','<').Replace('>','>').Replace('"','"')
|
||||
return $s.Replace('&','&').Replace('<','<').Replace('>','>')
|
||||
}
|
||||
|
||||
function Resolve-QueryValue {
|
||||
@@ -3563,19 +3563,11 @@ if ($script:RawRootOpening) {
|
||||
$content = [regex]::Replace($content, '<DataCompositionSchema\b[^>]*>', { param($m) $script:RawRootOpening })
|
||||
}
|
||||
|
||||
# (2) re-escape `"` to " inside <query>/<expression> text content (1C-style).
|
||||
# Scope is anchored to those tag names so xsi:type="..." attribute quotes are untouched.
|
||||
$content = [regex]::Replace(
|
||||
$content,
|
||||
'(<(?:\w+:)?(?:query|expression)\b[^>]*>)([\s\S]*?)(</(?:\w+:)?(?:query|expression)>)',
|
||||
{ param($m) $m.Groups[1].Value + $m.Groups[2].Value.Replace('"', '"') + $m.Groups[3].Value }
|
||||
)
|
||||
|
||||
# (3) normalize self-closing tags: `.NET XmlDocument` adds a space before `/>`
|
||||
# (2) normalize self-closing tags: `.NET XmlDocument` adds a space before `/>`
|
||||
# (`<foo bar="x" />`) but 1C-Designer writes `<foo bar="x"/>`. Strip the space.
|
||||
$content = [regex]::Replace($content, '(?<=\S) />', '/>')
|
||||
|
||||
# (4) normalize line endings to match source — operations may mix LF (from new
|
||||
# (3) normalize line endings to match source — operations may mix LF (from new
|
||||
# fragments) with whatever the source used (CRLF on Windows, LF on Linux/git).
|
||||
if ($script:LineEnding -eq "`r`n") {
|
||||
$content = $content -replace '(?<!\r)\n', "`r`n"
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
# skd-edit v1.21 — Atomic 1C DCS editor (Python port)
|
||||
# skd-edit v1.22 — Atomic 1C DCS editor (Python port)
|
||||
# Source: https://github.com/Nikolay-Shirokov/cc-1c-skills
|
||||
import argparse
|
||||
import os
|
||||
@@ -80,7 +80,7 @@ def local_name(node):
|
||||
# ── helpers ──────────────────────────────────────────────────
|
||||
|
||||
def esc_xml(s):
|
||||
return s.replace('&', '&').replace('<', '<').replace('>', '>').replace('"', '"')
|
||||
return s.replace('&', '&').replace('<', '<').replace('>', '>')
|
||||
|
||||
|
||||
def resolve_query_value(val, base_dir):
|
||||
@@ -2946,16 +2946,9 @@ xml_bytes = xml_bytes.replace(b"<?xml version='1.0' encoding='UTF-8'?>", b'<?xml
|
||||
# Format-preserve post-processing (mirrors PS path):
|
||||
# (1) restore the original raw <DataCompositionSchema ...> opening tag — lxml collapses
|
||||
# multi-line xmlns into one line.
|
||||
# (2) re-escape `"` to " inside <query>/<expression> text content; scope anchored
|
||||
# to those tag names so xsi:type="..." attribute quotes are untouched.
|
||||
xml_text = xml_bytes.decode("utf-8")
|
||||
if raw_root_opening:
|
||||
xml_text = re.sub(r"<DataCompositionSchema\b[^>]*>", lambda m: raw_root_opening, xml_text, count=1, flags=re.DOTALL)
|
||||
xml_text = re.sub(
|
||||
r"(<(?:\w+:)?(?:query|expression)\b[^>]*>)([\s\S]*?)(</(?:\w+:)?(?:query|expression)>)",
|
||||
lambda m: m.group(1) + m.group(2).replace('"', '"') + m.group(3),
|
||||
xml_text,
|
||||
)
|
||||
# Normalize self-closing tags: lxml writes `<foo bar="x"/>` already (no space), but be
|
||||
# defensive — strip any space before `/>` so PS and PY ports stay byte-equivalent.
|
||||
xml_text = re.sub(r"(?<=\S) />", "/>", xml_text)
|
||||
|
||||
Reference in New Issue
Block a user