Skip to content

fix: 코드블록 HTML 마크다운 판별 복구#657

Merged
Hyeonjun0527 merged 1 commit into
developfrom
fix/markdown-html-code-fence-classification
May 20, 2026
Merged

fix: 코드블록 HTML 마크다운 판별 복구#657
Hyeonjun0527 merged 1 commit into
developfrom
fix/markdown-html-code-fence-classification

Conversation

@Hyeonjun0527
Copy link
Copy Markdown
Member

@Hyeonjun0527 Hyeonjun0527 commented May 20, 2026

Summary

  • Fix markdown/HTML classification so HTML examples inside fenced code blocks do not make the whole Notion ZIP lesson body render as raw HTML.
  • Keep normal editor HTML fragments (<p>...) on the HTML path.
  • Add regression coverage for the failing Cursor/HTML lesson shape with markdown heading, fenced HTML examples, and signed image markdown.

Verification

  • yarn lint:fix (0 errors, existing warnings only)
  • yarn prettier:fix (exit 0; existing .codex/skills/clarify.md symlink warning)
  • yarn typecheck
  • yarn test:unit src/features/admin/course-management/model/admin-course-markdown.test.ts src/utils/markdown-rendering-utils.test.ts
  • git diff --check

Summary by CodeRabbit

릴리스 노트

  • Bug Fixes

    • 코드 블록 내 HTML 예제가 올바르게 마크다운으로 렌더링되도록 개선
    • 콘텐츠 렌더링 경로 판별 로직 최적화로 정확도 향상
  • Refactor

    • 마크다운 및 HTML 콘텐츠 렌더링 로직 개선
  • Tests

    • 마크다운 콘텐츠 정규화 및 렌더링 검증 테스트 추가

Review Change Stack

@vercel
Copy link
Copy Markdown

vercel Bot commented May 20, 2026

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

Project Deployment Actions Updated (UTC)
study-platform-client-dev Ready Ready Preview, Comment May 20, 2026 4:11pm

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 20, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 2c013c42-710e-44f4-83e4-6db44754cb58

📥 Commits

Reviewing files that changed from the base of the PR and between fa1e9a8 and e249ee8.

📒 Files selected for processing (6)
  • src/components/common/ui/editor/markdown-content.tsx
  • src/components/common/ui/rich-text/markdown-content-core.tsx
  • src/features/admin/course-management/model/admin-course-markdown.test.ts
  • src/features/admin/course-management/model/admin-course-markdown.ts
  • src/utils/markdown-rendering-utils.test.ts
  • src/utils/markdown-rendering-utils.ts
💤 Files with no reviewable changes (1)
  • src/components/common/ui/rich-text/markdown-content-core.tsx

📝 Walkthrough

개요

마크다운과 HTML 콘텐츠를 구분하는 새로운 shouldRenderMarkdownAsMarkdown 함수를 도입하여, 코드 펜스 내부의 HTML은 마크다운 코드 블록으로 렌더링하고 일반 HTML은 HTML로 유지하도록 렌더링 결정 로직을 일관되게 통합합니다. 에디터, 리치텍스트 렌더러, 관리자 코스 정규화 모듈이 이 함수를 활용하도록 업데이트됩니다.

변경 사항

마크다운 렌더링 경로 결정 통합

레이어 / 파일 요약
렌더링 판정 함수 정의 및 테스트
src/utils/markdown-rendering-utils.ts, src/utils/markdown-rendering-utils.test.ts
HTML 선행 태그를 감지하는 정규식과 shouldRenderMarkdownAsMarkdown(content) 함수를 추가합니다. 이 함수는 정규화된 콘텐츠가 렌더링 가능한 마크다운 문법을 포함하고, HTML이 아니거나 코드 펜스 제외 후 HTML이 아니며, 선행 HTML 태그로 시작하지 않을 때 참을 반환합니다. 테스트는 코드 펜스 내부 HTML이 마크다운으로 렌더링되고 일반 HTML은 마크다운으로 분류되지 않음을 검증합니다.
마크다운 에디터 렌더링 경로
src/components/common/ui/editor/markdown-content.tsx
shouldRenderMarkdownAsMarkdown을 임포트하고 isOriginalHtml 조건을 isHtmlContent(renderableContent) && !shouldRenderMarkdownAsMarkdown(renderableContent)로 변경하여, HTML로 인식되는 경우에도 새 함수가 참이면 마크다운 파싱 경로를 선택하도록 합니다.
리치텍스트 코어 렌더러 단순화
src/components/common/ui/rich-text/markdown-content-core.tsx
isHtmlContent 임포트와 isOriginalHtml 변수를 제거하여, 정규화된 콘텐츠를 YouTube 링크 임베드 → marked.parse → DOMPurify 정제 → 후처리 속성 적용의 일관된 경로로 처리합니다.
관리자 코스 마크다운 정규화 업데이트
src/features/admin/course-management/model/admin-course-markdown.ts, src/features/admin/course-management/model/admin-course-markdown.test.ts
hasRenderableMarkdownSyntaxshouldRenderMarkdownAsMarkdown으로 대체하고, 조건부 렌더링 흐름을 재구성합니다. 정규화된 콘텐츠가 마크다운으로 렌더링되어야 하면 HTML로 변환하고, 그렇지 않고 HTML이 아니면 원본을 반환합니다. 새 테스트는 코드 펜스 내부 HTML 예제 처리를 검증합니다.

관련 가능성 있는 PR

  • code-zero-to-one/study-platform-client#654: 두 PR 모두 markdown-content-core.tsx에서 입력이 HTML인지에 따른 렌더링 경로 분기를 제거/변경하여 일관된 처리로 통합합니다.
  • code-zero-to-one/study-platform-client#463: 이 PR이 마크다운 에디터 개발 중 도입한 markdown-content.tsx 렌더링 파이프라인을 개선하여 shouldRenderMarkdownAsMarkdown 기반 경로 결정으로 정제합니다.
  • code-zero-to-one/study-platform-client#578: 수업 페이지에서 lesson.contentMarkdownMarkdownContentCore로 렌더링하므로, 이 PR의 마크다운 vs HTML 렌더링 로직 변경이 수업 마크다운 출력 동작에 직접 영향을 미칩니다.

제안 라벨

🐛 bug

🐰 코드 펜스 안의 HTML도

마크다운 언어로 예쁘게 빛나고,

일관된 로직으로

렌더링 경로가 명확해지는

아름다운 변화입니다! ✨


🎯 3 (Moderate) | ⏱️ ~25분

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed PR 제목이 변경사항의 핵심을 명확하게 반영하고 있습니다. 코드 펜스 내부의 HTML이 전체 콘텐츠를 HTML로 렌더링하게 하는 문제를 수정하는 것이 주요 목표이며, 제목은 이를 간결하게 표현합니다.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/markdown-html-code-fence-classification

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@Hyeonjun0527 Hyeonjun0527 merged commit d5c01d6 into develop May 20, 2026
13 checks passed
@Hyeonjun0527 Hyeonjun0527 deleted the fix/markdown-html-code-fence-classification branch May 20, 2026 16:19
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