feat: support opt-in GitHub Alerts (#3764) by Jocs · Pull Request #5765 · marktext/marktext · GitHub
Skip to content

feat: support opt-in GitHub Alerts (#3764) - #5765

Closed
Jocs wants to merge 10 commits into
developfrom
feat/github-alerts
Closed

Jocs wants to merge 10 commits into
developfrom
feat/github-alerts

Conversation

@Jocs

@Jocs Jocs commented Oct 16, 2026 •

Copy link
Copy Markdown
Member

Superseded by two smaller reviewable PRs: #5770 (settings, core editing, parsing/rendering/export) and #5771 (Paragraph, front-menu and Quick Insert integration). Review #5770 first; #5771 targets its branch. This PR is closed without merging; its original discussion and screenshots remain available below.

Closes #3764
Related to #1240 (the GitHub Alerts portion).

Summary

MarkText currently treats GitHub Alerts as ordinary blockquotes. Add a default-off GitHub Alerts preference under Markdown extensions, enabling the five official types: NOTE, TIP, IMPORTANT, WARNING and CAUTION.

  • Model alerts as dedicated github-alert container blocks with body-only children and type metadata. Share quote-container editing behavior with blockquotes; generated titles and icons stay outside the document state.
  • Normalize eligible top-level Marked blockquote tokens into alert tokens in a shared parsing stage used by editor state, HTML export and clipboard rendering.
  • Create alerts through the Paragraph submenu, Quick Insert or [!TYPE] followed by Enter in a top-level quote. Add localized entries without new shortcuts.
  • Convert paragraphs, quotes and alert types through the paragraph front menu, preserving complete container contents, selections and a single undo step. Local conversions retain unrelated editor nodes instead of rebuilding the document.
  • Keep portable Markdown declarations through saving, source-mode handoff, copying, cutting and rich HTML paste. Support ordinary editing undo and live rendering preference changes. Reject nested alerts, unknown types and custom-title syntax; distinguish empty editor drafts from renderable alerts.
  • Render GitHub-style titles, icons and borders in light/dark themes and built-in HTML/PDF/print output. Export the latest source-mode contents and allow long alerts to flow across pages.
  • Enable or disable Pandoc's native alerts extension only when the selected reader reports support. No filters or writer-specific styling are added.

Type of change

  • Bug fix (non-breaking, fixes an issue)
  • New feature (non-breaking, adds functionality)
  • Breaking change (causes existing functionality to change)
  • Documentation update

Test plan

  • New tests added for syntax, editing, menus, preferences, clipboard round trips, exports and preservation of unrelated nodes during conversion/undo/redo.
  • Manually tested on macOS: creation/conversion menus, light/dark rendering, clipboard/source round trips and exported PDF pagination.
  • Desktop unit suite: 1,110 tests passed.
  • Muya unit suite: 2,685 tests passed.
  • CommonMark/GFM suites: 1,347 tests passed.
  • Full Muya Chromium E2E passed locally with bundled Chromium before the history simplification; all 14 alert E2E tests passed again afterward.
  • Native Electron alert, PDF export, paragraph-menu, paragraph-block and Quick Insert E2E: 17 tests passed; 2 platform-specific tests skipped.
  • Desktop/Muya type checks, ESLint, circular dependency check and pnpm run build:unpack passed.
  • Changed CSS files pass Stylelint.

Notes for reviewers

  • Preference changes update document state and selection without migrating or clearing undo/redo history, following the existing extension-setting behavior.
  • The setting is off by default, including migrated preferences. Turning it off reveals the original quote declaration without changing document content or clearing history.
  • Only top-level GitHub alerts are recognized. Marker-only content remains an ordinary quote on reparse/export. Generated English titles and icons are presentation, not saved Markdown.
  • A quote downgrade is unavailable when removing its declaration would reinterpret the first body line as another alert; the front menu explains how to preserve that text as inline code first.
  • The full CSS lint still reports seven pre-existing specificity errors in unchanged blockSyntax.css and inlineSyntax.css; this change's styles pass.
  • Requirements and manual test documents remain outside the repository, as requested. Screenshot evidence is uploaded to this PR rather than committed.

Screenshots

Light theme

All five GitHub Alert types in the light theme

Dark theme

All five GitHub Alert types in the dark theme

By submitting this pull request, I confirm that my contribution is made under the terms of the MIT license.

@github-actions

github-actions Bot commented Oct 16, 2026 •

Copy link
Copy Markdown
Contributor

Comment thread packages/muya/src/block/base/content.ts Outdated
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.

Support for GitHub Alerts

1 participant