Skip to content

Commit 0f41c45

Browse files
jk-kim0claude
andcommitted
confluence-mdx: gap whitespace 축소 시 leading 조정 버그의 pytest 단위 테스트를 추가합니다
<code>{{..}}</code><span> 안의</span> 구조에서 gap이 2→1로 축소될 때 leading이 전부 제거되는 버그를 재현하는 테스트케이스입니다. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent bee8454 commit 0f41c45

1 file changed

Lines changed: 36 additions & 0 deletions

File tree

confluence-mdx/tests/test_reverse_sync_xhtml_patcher.py

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -639,6 +639,42 @@ def test_gap_fully_deleted(self):
639639
result = patch_xhtml(xhtml, patches)
640640
assert 'IDENTIFIER</strong>조사' in result
641641

642+
def test_gap_is_node_leading_reduces_not_strips(self):
643+
"""gap 전체가 노드의 leading whitespace일 때, gap 축소 시 leading을 조정한다.
644+
645+
재현 시나리오 (PR #979, page 883654669):
646+
XHTML: <code>{{..}}</code><span> 안의 값은...</span>
647+
old_plain_text: "...진행합니다. {{..}} 안의 값은..."
648+
new_plain_text: "...이동합니다. {{..}} 안의 값은..."
649+
현상: gap " "→" " 축소 시 <span>의 leading " "가 전부 제거되어
650+
<span>안의 값은</span>이 됨 (올바른 결과: <span> 안의 값은</span>)
651+
원인: gap_old(2) == leading(2)인 경우에도 leading=''로 전부 제거
652+
"""
653+
xhtml = (
654+
'<p>'
655+
'미리 채워져 있는 내용들을 삭제하고 아래의 App Manifest를 진행합니다.'
656+
'<br/>'
657+
'<span style="background-color: rgb(254,222,200);"> </span>'
658+
'<code>{{..}}</code>'
659+
'<span style="background-color: rgb(254,222,200);"> 안의 값은 원하는 값으로 변경해 주세요.</span>'
660+
'</p>'
661+
)
662+
patches = [{
663+
'xhtml_xpath': 'p[1]',
664+
# collapse_ws로 " 안의" → " 안의"가 된 후 _apply_mdx_diff_to_xhtml 결과
665+
'old_plain_text': '미리 채워져 있는 내용들을 삭제하고 아래의 App Manifest를 진행합니다. {{..}} 안의 값은 원하는 값으로 변경해 주세요.',
666+
'new_plain_text': '미리 채워져 있는 내용을 삭제하고 아래 App Manifest를 이동합니다. {{..}} 안의 값은 원하는 값으로 변경해 주세요.',
667+
}]
668+
result = patch_xhtml(xhtml, patches)
669+
# gap " "→" " 축소 시, gap 전체가 노드 leading이므로 leading=" "으로 조정
670+
assert '> 안의 값은' in result, (
671+
f"leading should be reduced to 1 space, not stripped entirely: {result}"
672+
)
673+
# 버그 동작: leading이 전부 제거되어 ">안의"가 되면 안 됨
674+
assert '>안의 값은' not in result, (
675+
f"leading whitespace must not be stripped entirely: {result}"
676+
)
677+
642678
def test_gap_not_reduced_preserves_leading(self):
643679
"""gap이 축소되지 않으면 leading whitespace를 보존한다."""
644680
xhtml = (

0 commit comments

Comments
 (0)