UI: Improve doc_md rendering in Dag Documentation#66809
Conversation
There was a problem hiding this comment.
Pull request overview
This PR enhances the new UI’s DAG Documentation markdown rendering so doc_md displays richer content (inline code, fenced code blocks with improved UX, KaTeX math, and Mermaid diagrams), and adds regression tests for the new behavior.
Changes:
- Refactors markdown rendering to separate inline code from fenced code blocks and introduce dedicated block renderers (code + Mermaid).
- Adds KaTeX + math plugin support and globally loads KaTeX styles.
- Switches syntax highlighting setup and adds targeted Vitest coverage for markdown rendering cases.
Reviewed changes
Copilot reviewed 7 out of 8 changed files in this pull request and generated 7 comments.
Show a summary per file
| File | Description |
|---|---|
| airflow-core/src/airflow/ui/src/utils/syntaxHighlighter.ts | Switches exported highlighter + theme source (now hljs-based) and updates types. |
| airflow-core/src/airflow/ui/src/utils/renderMermaid.ts | Adds Mermaid rendering helper with strict security configuration. |
| airflow-core/src/airflow/ui/src/main.tsx | Imports KaTeX stylesheet globally. |
| airflow-core/src/airflow/ui/src/components/ReactMarkdownBlocks.tsx | Adds block-level renderers for fenced code blocks and Mermaid diagrams (copy UX, loading state, SVG injection). |
| airflow-core/src/airflow/ui/src/components/ReactMarkdown.tsx | Integrates remark-math/rehype-katex, new pre/code handling, Mermaid routing, and KaTeX display styling. |
| airflow-core/src/airflow/ui/src/components/ReactMarkdown.test.tsx | Adds regression tests for inline code, fenced blocks, math, and Mermaid rendering. |
| airflow-core/src/airflow/ui/package.json | Adds dependencies for KaTeX, Mermaid, and markdown math plugins. |
| airflow-core/src/airflow/ui/pnpm-lock.yaml | Updates lockfile for new dependencies. |
Files not reviewed (1)
- airflow-core/src/airflow/ui/pnpm-lock.yaml: Language not supported
|
Static checks are failing. Please run prek locally in your branch to fix the errors and then commit to repo. Remember to rebase to ensure all latest commits from community are incorporated. |
|
@minyeamer A few things need addressing before review — see our Pull Request quality criteria.
No rush. Note: This comment was drafted by an AI-assisted triage tool and may contain mistakes. Once you have addressed the points above, an Apache Airflow maintainer — a real person — will take the next look at your PR. We use this two-stage triage process so that our maintainers' limited time is spent where it matters most: the conversation with you. |
…rams - Fix inline code rendering to properly handle single backtick snippets - Add syntax highlighting, line numbers, and copy buttons to code blocks - Core support for LaTeX math expressions using KaTeX (inline and display) - Integrate Mermaid.js to render diagrams directly from markdown blocks
Co-authored-by: Copilot Autofix powered by AI <[email protected]>
Copilot follow-ups - Lazy-load Mermaid so markdown rendering only pulls it in when Mermaid blocks are rendered - Reuse existing i18n clipboard labels in markdown block actions instead of hard-coded JSX strings - Replace the Mermaid loading text with a spinner-only state and remove the redundant jest-dom test import Compat 3.0.6 fix - Pin pyjwt>=2.11.0 in providers/fab so compat installs paired with Airflow 3.0.6 do not fall back to PyJWT 2.10.1 - Fix flask_jwt_extended imports that expect jwt.types.Options during FAB and Google provider test setup - Keep the FAB wheel metadata aligned with the dependency floor already required by current airflow-core Validation - Pass targeted eslint, vitest, and UI build checks for the markdown rendering changes - Reproduce the FAB compat install sequence locally and confirm the failing import path is restored
- add jest-dom type support for ReactMarkdown tests so UI static checks use the current matcher types - keep the markdown UI files in the formatter output expected by the UI lint/type hook - sync FAB provider docs with the existing pyjwt>=2.11.0 dependency used for compat coverage - use origin/main as the correct baseline for branch-only pre-commit checks
4b91adc to
1114cde
Compare
|
Thanks for pointing those out! I’ve resolved the failures locally and pushed the fixes: Static Checks: Fixed the pre-commit and CI image check failures. |
choo121600
left a comment
There was a problem hiding this comment.
nice feature :)
one question
parkhojeong
left a comment
There was a problem hiding this comment.
Thanks for working on this. This looks very useful, and I left a few comments.
- revert the markdown syntax highlighter back to PrismLight with selective language registration - simplify language resolution to only allow explicitly registered languages - apply the Prism pre styling to the outer code block container - remove inherited margin and border radius that caused background bleed in the documentation modal
- trim ReactMarkdown tests down to a minimal smoke-test set - keep basic math integration coverage - keep mermaid render failure fallback coverage - drop broader layout and highlighting assertions that were not essential to preserve
|
@minyeamer — This PR has new commits since the last review requesting changes from Note: This comment was drafted by an AI-assisted triage tool and may contain mistakes. Once you have addressed the points above, an Apache Airflow maintainer — a real person — will take the next look at your PR. We use this two-stage triage process so that our maintainers' limited time is spent where it matters most: the conversation with you. Drafted-by: Claude Code (Opus 4.7); reviewed by @potiuk before posting |
|
@bbovenzi I went through your requested changes and pushed follow-up commits to address them. The biggest change is that Mermaid now lives in a Along the way, I also incorporated related feedback from the other threads:
I'm sorry for the late mention. After updating this branch from Also, thanks to @potiuk for pointing out that I should mention the reviewer once the requested changes were addressed. I’ve resolved the threads I addressed. When you have a moment, could you please take another look and let me know if anything still needs adjustment? |
Co-authored-by: Brent Bovenzi <[email protected]>
…acking - Remove `useCallback`/`useMemo` — `babel-plugin-react-compiler` handles memoization automatically via `reactCompilerPreset()` - Remove `useState`/`useRef`/`useEffect` theme-tracking chain and the separate `initializeMermaid` function; `mermaid.initialize()` is called directly in `renderDiagram` on every invocation instead
|
@bbovenzi Thanks for the review. Addressed all three:
Drafted-by: Claude Code (claude-sonnet-4-6); reviewed by @minyeamer before posting |
pierrejeambrun
left a comment
There was a problem hiding this comment.
Really nice result — the before/after screenshots look great, and lazy-importing mermaid is exactly right given its size.
One thing on structure: I think the context/mermaid/ module and the app-wide in main.tsx are more than this needs. Details inline — collapsing it to a small util would cut a good chunk of code without changing behavior.
|
@pierrejeambrun Addressed in ea53d86. Mermaid initialization is now cached per theme in the provider, so The |
choo121600
left a comment
There was a problem hiding this comment.
From my side, most things look good now.
bbovenzi
left a comment
There was a problem hiding this comment.
This is looking much better! Thanks for dealing with all of our feedback!
I think we have just two changes left:
Echo-ing @pierrejeambrun, I will say its safe to not need the 3rd party licenses.
I also agree with Pierre about making this a util instead of a context provider. My apologies for giving bad direction previously.
|
That improved markdown also including mermaid is really cool! But after merge nobody will know (except when reading the code). So can you please (1) ass a small hint to docs what is supported (proposal: (a) airflow-core/docs/core-concepts/dags.rst and (b) airflow-core/docs/tutorial/fundamentals.rst) and add an extended example also to one of the example dags (e.g. airflow-core/src/airflow/example_dags/tutorial.py) |
|
@jscheffl Thanks, updated this in the docs and examples in 0f5935d. I added a short note to For I also added new screenshots as For the Dag-level |

This PR improves how
doc_mdcontent renders in the Dag Documentation dialog in the new UI.It adds proper rendering for inline code, fenced code blocks, KaTeX math, and Mermaid diagrams.
What changed
Test plan
cd airflow-core/src/airflow/ui && corepack pnpm install --frozen-lockfilecd airflow-core/src/airflow/ui && corepack pnpm vitest run src/components/ReactMarkdown.test.tsxcd airflow-core/src/airflow/ui && corepack pnpm exec eslint src/components/ReactMarkdown.tsx src/components/ReactMarkdownBlocks.tsx src/utils/renderMermaid.ts src/utils/syntaxHighlighter.ts src/components/ReactMarkdown.test.tsx src/main.tsxcd airflow-core/src/airflow/ui && corepack pnpm buildScreenshots
Was generative AI tooling used to co-author this PR?
Generated-by: GitHub Copilot (GPT-5.4) following the guidelines
{pr_number}.significant.rst, in airflow-core/newsfragments. You can add this file in a follow-up commit after the PR is created so you know the PR number.