feat: mermaid 다이어그램 렌더링 기능 추가#672
Open
vanillacake369 wants to merge 4 commits into
Open
Conversation
Author
CI 실패 관련 참고4개의 Netlify CI(Header rules, Pages changed, Redirect rules, deploy-preview)가 실패하고 있으나, 이는 본 PR의 변경사항과 무관합니다.
|
Convert mermaid code blocks into renderable placeholder HTML (<div class="mermaid-block"><pre class="mermaid">) so that mermaid.js can pick them up on the client side.
Prevent Prism.js from syntax-highlighting mermaid code blocks, which would turn diagram definitions into colored code text instead of renderable diagrams.
- Add mermaidPlugin to remark pipeline (SSR + client) - Dynamically load mermaid.js from CDN when mermaid blocks detected - Auto-switch mermaid theme based on code theme setting - Add .mermaid-block styles for centered, responsive diagrams
- mermaidPlugin: 5 unit tests (transform, skip non-mermaid, diagram types) - prismPlugin: 3 unit tests (mermaid skip, JS highlight, plain code) - test-mermaid.html: standalone visual test (10 cases, no backend needed)
c81af31 to
1398ff8
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
개요
아래와 같은
mermaid코드 블록을 다이어그램(SVG)으로 렌더링하는 기능을 추가합니다.flowchart TD A[Christmas] -->|Get money| B(Go shopping) B --> C{Let me think} C -->|One| D[Laptop] C -->|Two| E[iPhone] C -->|Three| F[fa:fa-car Car]변경사항
<pre class="mermaid">placeholder로 변환하는 remark 플러그인 추가테스트
논의사항
이슈 : mermaid npm 패키지와 현재 빌드 환경의 호환성
mermaid npm 패키지는 optional chaining 등 최신 JS 문법을 사용하고 있어, 현재 프로젝트의 babel/webpack 설정에서 `ERR: optionalChaining isn't currently enabled` 에러가 발생합니다. 이로 인해 npm 패키지를 직접 번들링할 수 없습니다.
대안
이에 대해 다음과 같은 대안들이 있으며, 현재는 CDN 동적 로딩을 선택하여 mermaid.js를 런타임에 불러오고 있습니다. 기존 프로젝트에서 Twitter widgets, KaTeX CSS를 CDN으로 로딩하는 패턴과 일관되고, 빌드 설정 변경 없이 적용 가능하기 때문입니다.