Skip to content

fix(reverse_sync): 인라인 요소 경계 공백 변경이 XHTML에 반영되지 않는 문제를 수정합니다#985

Merged
jk-kim0 merged 5 commits intomainfrom
jk/fix-reverse-sync-whitespace-patch
Apr 5, 2026
Merged

fix(reverse_sync): 인라인 요소 경계 공백 변경이 XHTML에 반영되지 않는 문제를 수정합니다#985
jk-kim0 merged 5 commits intomainfrom
jk/fix-reverse-sync-whitespace-patch

Conversation

@jk-kim0
Copy link
Copy Markdown
Contributor

@jk-kim0 jk-kim0 commented Apr 5, 2026

Summary

build_patcheshas_content_change 판정에서 collapse_ws를 분리하고, preserved anchor 리스트 경로에서도 가시 공백 변경이 XHTML에 전파되도록 합니다.

목표

reverse-sync patch는 MDX에서 교정한 다음과 같은 공백 변경을 XHTML에 정확히 전파해야 합니다:

  • 이중→단일 공백: 모두 "Read-Only"모두 "Read-Only"
  • 인라인 요소 경계 공백: [ **General** ][**General**]
  • 링크 텍스트 trailing space: [Okta 연동하기 ](url)[Okta 연동하기](url)
  • preserved anchor 리스트 공백: 텍스트 [링크](url) 뒤에텍스트 [링크](url) 뒤에

Root Cause

has_content_changecollapse_ws(normalize_mdx_to_plain(...))로 비교하면 위 네 가지가 모두 False로 평가되어 패치가 생성되지 않습니다.

수정

1. has_content_change 비교와 _apply_mdx_diff_to_xhtml 전달 분리

용도 적용 이유
has_content_change 비교 _normalize_list_for_content_compare 가시 공백 보존, continuation line reflow 무시
_apply_mdx_diff_to_xhtml 전달 collapse_ws(...) (기본) XHTML plain text에 줄바꿈이 없으므로 정렬 필요

2. preserved anchor 리스트 경로에서 raw 공백 전이

_contains_preserved_link_markup()으로 <ac:link> 존재 여부를 판별하여, preserved link가 있는 리스트에서는 collapse_ws 없이 raw plain text를 text transfer에 전달합니다. <ac:image> 등 비링크 매크로는 기존 collapse_ws 경로를 유지합니다.

3. continuation line reflow 무시

_normalize_list_for_content_compare()는 리스트 항목 내부의 continuation line 줄바꿈을 공백으로 합쳐서, * hello world* hello\n world 같은 format-only 변경이 no-op 패치를 생성하지 않도록 합니다.

설계 원칙

has_content_change 경로에서 collapse_ws, strip 등 정규화를 적용하면 교정자가 의도한 공백 변경이 무시됩니다. 변경 감지 비교에는 Markdown 마크업만 제거하고 공백은 원본 그대로 보존해야 합니다.

Added/updated tests?

  • TestWhitespaceOnlyChangeGeneratesPatch — 이중→단일, 단일→이중 공백 변경 패치 생성 검증
  • test_continuation_line_reflow_only_skips_patch — continuation line reflow는 skip
  • test_path1b_link_boundary_whitespace_generates_patch — 링크 경계 공백 변경 양성 테스트
  • TestPreservedAnchorListWhitespaceTransfer — preserved anchor 리스트 공백 전이 검증
  • test_image_anchor_list_keeps_collapsed_text_diff — ac:image 리스트는 collapse_ws 유지 검증
  • test_normalize_preserves_link_trailing_space — 링크 텍스트 trailing space 보존 검증

Verification

  • 955 unit tests passed
  • 43 integration tests passed

🤖 Generated with Claude Code

- build_patches의 has_content_change 비교에서 collapse_ws를 제거하여
  이중→단일 공백 등 공백 수 변경을 감지합니다
- _apply_mdx_diff_to_xhtml 전달 시에는 collapse_ws를 유지하여
  XHTML plain text와의 정렬을 보장합니다
- normalize_mdx_to_plain의 링크 텍스트에 strip()을 적용하여
  [ **T** ] ↔ [**T**] 형식 차이를 흡수합니다

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@vercel
Copy link
Copy Markdown

vercel bot commented Apr 5, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
querypie-docs Ready Ready Preview, Comment Apr 5, 2026 5:48pm

Request Review

…지를 복원합니다

.strip()은 [ **T** ] ↔ [**T**] 경계 공백 변경과
[Okta 연동하기 ] trailing space 변경을 모두 삼켜서
has_content_change가 False로 평가되어 패치가 누락되었습니다.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@jk-kim0
Copy link
Copy Markdown
Contributor Author

jk-kim0 commented Apr 5, 2026

[debate-review][sha:ed566c055932a127840cf5b724a7628d7b8e81cb] Review stopped due to an error.

Round: 1
Step: step0_sync
Error: Round 1 not found

Manual review required.

- isu_001 (confluence-mdx/bin/reverse_sync/patch_builder.py:1064): `normalize_mdx_to_plain()`의 raw 결과를 그대로 비교하면 가시 공백 수정뿐 아니라 리스트 continuation line reflow도 `has_content_change=True`로 분류됩니다. 예를 들어 `* hello world`를 `* hello\n  world`로만 바꿔도 이 조건이 참이 되어 `replace_fragment` 패치가 생성되지만, emitter가 만드는 XHTML은 기존과 동일한 `<ul><li><p>hello world</p></li></ul>`입니다. 이번 변경으로 format-only 줄바꿈 정리까지 reverse-sync 패치 대상으로 승격되어 불필요한 no-op 패치가 생깁니다.
- isu_001 (confluence-mdx/bin/reverse_sync/patch_builder.py:1100): 리스트의 공백 변경을 감지한 뒤에도 preserved anchor(<ac:link>/<ri:...>) 경로에서는 _old_plain/_new_plain에 다시 collapse_ws를 적용해서 실제 text transfer 입력이 동일해집니다. 그래서 * 텍스트 [링크](url) 뒤에 -> * 텍스트  [링크](url) 뒤에 같은 공백 확대는 new_plain_text가 그대로 남아 XHTML에 반영되지 않습니다.
- isu_002 (confluence-mdx/tests/test_reverse_sync_patch_builder.py:154): 이 테스트를 URL만 바뀌는 케이스로 바꾸면 이번 PR이 고치려는 핵심 회귀인 `[ **General** ] -> [**General**]` 같은 링크 경계 공백 변경을 더 이상 잠그지 못합니다. `normalize_mdx_to_plain()`은 링크 URL을 버리므로, 공백 비교 로직이 다시 깨져도 이 테스트는 계속 통과합니다. 기존 경계 공백 케이스를 별도 회귀 테스트로 남겨야 합니다.
@jk-kim0
Copy link
Copy Markdown
Contributor Author

jk-kim0 commented Apr 5, 2026

[debate-review][sha:38c835b0488d6e88e418395417ea77082282d083] Review stopped due to an error.

Debate Summary

  • isu_003 [withdrawn] _contains_preserved_anchor_markup()가 ac:image 등 비링크 매크로도 포함하여 raw whitespace transfer 경로로 진입. 다만 955 unit tests + 43 integration tests 전체 통과 확인됨.

Round: 6
Step: step4_settle
Error: Unknown error

Manual review required.

@jk-kim0 jk-kim0 merged commit 81b3892 into main Apr 5, 2026
7 checks passed
@jk-kim0 jk-kim0 deleted the jk/fix-reverse-sync-whitespace-patch branch April 5, 2026 18:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant