Skip to content

confluence-mdx: reverse-sync 정확도 개선 및 테스트케이스 fixture 업데이트#895

Draft
jk-kim0 wants to merge 8 commits intomainfrom
feature/type-based-sidecar-mapping
Draft

confluence-mdx: reverse-sync 정확도 개선 및 테스트케이스 fixture 업데이트#895
jk-kim0 wants to merge 8 commits intomainfrom
feature/type-based-sidecar-mapping

Conversation

@jk-kim0
Copy link
Contributor

@jk-kim0 jk-kim0 commented Mar 9, 2026

배경

PR #901(타입 기반 sidecar 매핑)이 main에 머지된 이후, 이 PR은 해당 변경과 함께
이전에 개발된 아래의 추가 개선사항 및 fixture 업데이트를 포함합니다.

변경 내용

코드 수정

  • patch_builder.py: 헤딩 공백 차이만 있는 변경을 XHTML에 전파하지 않음
    • ## foo## foo 같은 공백 차이만 있는 헤딩 변경은 건너뜁니다.
    • Confluence XHTML의   등 고유 공백 문자 손실 방지.
  • roundtrip_verifier.py: _normalize_blank_line_after_blockquote() 추가
    • Forward converter가 blockquote 뒤에 빈 줄을 체계적으로 추가하는 차이를 정규화.
  • text_utils.py: HTML 태그 제거로 인한 trailing space 아티팩트 제거
    • 링크 텍스트의 genuine trailing space는 보존.
  • list_patcher.py, xhtml_patcher.py: <ol start="N"> 속성 변경 주석 추가

단위 테스트

  • test_reverse_sync_patch_builder.py: TestHeadingWhitespaceSkip 클래스 추가
  • test_reverse_sync_xhtml_patcher.py: TestOlStartPatch 기존 테스트 유지
  • test_reverse_sync_mdx_to_xhtml_inline.py: inline code escape 테스트 추가

테스트케이스 fixture 업데이트

  • 42개 reverse-sync 테스트케이스 original.mdx 재생성 (현재 converter 기준)
  • mapping.yaml 파일 추가 (21개 케이스)
  • page.v1.yaml 픽스처 추가 (3개 케이스)
  • improved.mdx 파일 업데이트 (다수 케이스)
  • _meta.ts 파일 추가 (8개 케이스)

검증

  • 780개 pytest 단위 테스트 통과
  • reverse-sync integration test (42개 케이스)

🤖 Generated with Claude Code

@jk-kim0 jk-kim0 self-assigned this Mar 9, 2026
@vercel
Copy link

vercel bot commented Mar 9, 2026

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

Project Deployment Actions Updated (UTC)
querypie-docs Ready Ready Preview, Comment Mar 12, 2026 4:29pm

Request Review

@jk-kim0 jk-kim0 force-pushed the feature/type-based-sidecar-mapping branch from 638bfd2 to b1e1514 Compare March 9, 2026 17:09
jk-kim0 added a commit that referenced this pull request Mar 10, 2026
PR #895 의 tests/reverse-sync/ 변경사항을 모두 취소합니다.
main 브랜치(PR #896, #897)의 테스트케이스가 올바른 기준입니다.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@jk-kim0 jk-kim0 force-pushed the feature/type-based-sidecar-mapping branch from c192fbc to 03dfd58 Compare March 10, 2026 02:59
@jk-kim0 jk-kim0 force-pushed the feature/type-based-sidecar-mapping branch from 03dfd58 to a656ad5 Compare March 10, 2026 04:30
@jk-kim0 jk-kim0 force-pushed the feature/type-based-sidecar-mapping branch from a656ad5 to b0fc47a Compare March 10, 2026 04:39
@jk-kim0 jk-kim0 force-pushed the feature/type-based-sidecar-mapping branch 2 times, most recently from 16ec541 to 76a3fba Compare March 10, 2026 06:30
@jk-kim0 jk-kim0 force-pushed the feature/type-based-sidecar-mapping branch from 7302033 to f7e30b2 Compare March 11, 2026 07:34
@jk-kim0 jk-kim0 marked this pull request as draft March 11, 2026 10:15
jk-kim0 and others added 8 commits March 13, 2026 01:16
…딩 공백 처리

- `bin/mdx_to_storage/inline.py`, `bin/reverse_sync/mdx_to_xhtml_inline.py`: inline code 변환 시 `html.escape()` 적용
  - `<`, `>`, `&` 등 HTML 특수문자가 포함된 코드 스니펫이 XHTML에서 깨지는 문제를 수정합니다.
- `bin/reverse_sync/list_patcher.py`, `bin/reverse_sync/xhtml_patcher.py`: `<ol start="N">` 속성 변경 감지 및 적용
  - `_get_ordered_list_start()` 헬퍼를 추가하여 MDX 순서 목록의 시작 번호를 추출합니다.
  - 시작 번호가 변경된 경우 패치에 `ol_start` 필드를 포함하고, xhtml_patcher에서 `<ol start>` 속성을 갱신하거나 제거합니다.
- `bin/reverse_sync/patch_builder.py`: 헤딩 공백 차이만 있는 변경을 XHTML에 전파하지 않음
  - 레벨과 텍스트가 동일한 헤딩 변경(공백 차이만 있는 경우)은 건너뜁니다.
  - Confluence XHTML의 `&nbsp;` 등 고유 공백 문자가 손실되는 것을 방지합니다.
- `bin/text_utils.py`: HTML 태그 제거로 인한 trailing space 아티팩트 제거
  - 링크 텍스트의 genuine trailing space는 보존하고, 태그 제거로 생긴 공백만 제거합니다.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- `tests/test_reverse_sync_mdx_to_xhtml_inline.py`: inline code 내 HTML 특수문자 escape 테스트 추가
  - `TestConvertInline`: `<`, `&` 포함 코드 스니펫의 escape 처리 검증
  - `TestBlockConversion`: reverse-sync 경로(`mdx_block_to_inner_xhtml`)에서의 escape 처리 검증
- `tests/test_reverse_sync_xhtml_patcher.py`: `<ol start="N">` 속성 변경 테스트 추가
  - `ol_start` 패치 필드로 `start` 속성을 설정하는 케이스
  - `ol_start=1` 패치로 `start` 속성을 제거하는 케이스
- `tests/test_reverse_sync_patch_builder.py`: `TestHeadingWhitespaceSkip` 클래스 추가
  - 공백 차이만 있는 헤딩 변경이 패치를 생성하지 않는 것 검증
  - 실제 텍스트가 변경된 헤딩은 패치를 생성하는 것 검증
- `bin/text_utils.py`: trailing space 아티팩트 제거 로직 revert
  - `s_before_html` 비교를 통한 trailing space 제거는 특정 케이스만을 위한 해킹으로 판단하여 취소합니다.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- `reverse_sync_cli.py`: 패치된 XHTML의 forward 변환 전, `page.v1.yaml`을
  `var/<page_id>/`로 복사합니다. Forward converter가 크로스 페이지 링크 해석 시
  `page.v1.yaml`을 XHTML과 같은 디렉터리에서 읽으므로, 이를 보장합니다.
- `roundtrip_verifier.py`: `_normalize_blank_line_after_blockquote()` 추가 —
  blockquote(`>`) 줄 바로 다음의 단일 빈 줄을 제거합니다. Forward converter가
  blockquote 뒤에 빈 줄을 체계적으로 추가하므로, 비교 시 이를 정규화합니다.

- 1454342158: `#unexpected-failure` 링크 → 정상 크로스 페이지 링크로 수정
- 1907294209: blockquote 뒤 빈 줄 차이 제거 → PASS

- feature/type-based-sidecar-mapping

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1. `bin/text_utils.py`: `normalize_mdx_to_plain`에서 HTML 태그 제거로
   생긴 trailing space 아티팩트를 제거합니다. (링크 텍스트의 genuine
   trailing space는 보존)

2. `bin/reverse_sync/patch_builder.py`: heading 블록에서 레벨과 텍스트가
   동일한 경우(공백 차이만 있는 경우) XHTML을 변경하지 않습니다.
   (`&nbsp;` 등 XHTML 고유 공백 문자가 손실되는 것을 방지)

3. `tests/reverse-sync/*/improved.mdx`: WS_ONLY 테스트케이스 11건
   trailing space, double space 등 whitespace 정규화

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
각 테스트케이스의 page.xhtml을 현재 버전의 forward converter로 변환하여
original.mdx와 mapping.yaml을 업데이트합니다.

이를 통해 테스트케이스가 현재 converter 버전의 출력을 정확하게 반영하게 됩니다.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- tests/reverse-sync/pages.yaml: 25개 미등록 테스트케이스 항목을 var/pages.yaml 에서 복사하여 추가합니다
- tests/reverse-sync/*/original.mdx: 전체 42개 케이스를 올바른 --attachment-dir 옵션으로 재생성합니다
  - attachment-dir 는 pages.yaml 의 mdx_path 에서 유도하여 이미지 경로가 실제 문서 경로와 일치하게 합니다
- tests/reverse-sync/*/mapping.yaml: original.mdx 재생성에 따른 sidecar 매핑 업데이트
- tests/reverse-sync/README.md: page.xhtml → original.mdx 변환 가이드 문서 추가

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- 543981760: improved.mdx의 HTML 테이블을 original.mdx 형식으로 복원합니다
- 544382364: <br/> 주변 blank line 누락 및 셀 내용 형식을 수정합니다
- 793608206: paragraph 텍스트 변경으로 round-trip 검증 가능하도록 수정합니다
- bin: list_patcher, xhtml_patcher, mdx_to_xhtml_inline, inline 개선사항 포함
- tests: page.v1.yaml 및 mapping.yaml 업데이트합니다

Co-Authored-By: Atlas <atlas@jk.agent>
- list_patcher.py: `_get_ordered_list_start` 중복 정의 제거
- roundtrip_verifier.py: 잉여 빈 줄 제거

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@jk-kim0 jk-kim0 force-pushed the feature/type-based-sidecar-mapping branch from f13ba08 to 45ac5e5 Compare March 12, 2026 16:26
@jk-kim0 jk-kim0 changed the title confluence-mdx: sidecar mapping을 텍스트 비교에서 타입 기반 순차 정렬로 교체합니다 confluence-mdx: reverse-sync 정확도 개선 및 테스트케이스 fixture 업데이트 Mar 12, 2026
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