Skip to content

Add .mmd (Mermaid diagram) file support#1284

Merged
cyanzhong merged 7 commits intoMarkEdit-app:mainfrom
jordanhubbard:feature/mmd-file-support
Mar 19, 2026
Merged

Add .mmd (Mermaid diagram) file support#1284
cyanzhong merged 7 commits intoMarkEdit-app:mainfrom
jordanhubbard:feature/mmd-file-support

Conversation

@jordanhubbard
Copy link
Copy Markdown
Contributor

What this does

Adds first-class support for .mmd files — the conventional extension for standalone Mermaid diagram source files.

Changes:

  • Registers .mmd as an openable file type (Info.plist document type + exported UTType app.markedit.mmd, textFileExtensions allowlist)
  • Adds a "Preview Diagram" toolbar item (available in the toolbar customization palette) that renders the entire document as a Mermaid diagram using the existing Previewer popover infrastructure — no new dependencies

Why I find this useful: I maintain a small collection of .mmd diagram files alongside my Markdown notes. Right now MarkEdit can't open them at all; they fall through to another app. Since MarkEdit already supports Mermaid rendering inside Markdown fences and already has the Previewer popover, wiring up standalone .mmd files feels like a natural fit.

Is this in scope?

I fully understand if this doesn't align with the project's focus as a Markdown editor — the Philosophy page is pretty clear about keeping scope tight. If that's the case, I'm happy to maintain this on my own fork. I'm raising it here in case it's something other users want and the maintainers are open to it.

The implementation is intentionally minimal — it reuses the existing Previewer and adds no new dependencies.

Test plan

  • Open a .mmd file — MarkEdit accepts it and shows the raw diagram source as editable text
  • Right-click a .mmd file in Finder → Open With — MarkEdit appears as an option
  • Add "Preview Diagram" to the toolbar via customization; click it — the Mermaid diagram renders in the existing popover
  • Click again — popover dismisses (toggle behavior)
  • Empty document — button does nothing (guarded)

🤖 Generated with Claude Code

- Register .mmd as an openable file type (Info.plist document type +
  exported UTType app.markedit.mmd, textFileExtensions allowlist)
- Add a "Preview Diagram" toolbar item (available in toolbar
  customization palette) that renders the entire document as a Mermaid
  diagram using the existing Previewer popover infrastructure
- Exclude Modules/build from SwiftLint (auto-generated files)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Comment thread MarkEditMac/Info.plist
</array>
<key>UTExportedTypeDeclarations</key>
<array>
<dict>
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you don't need this. By adding mmd to the known file extension list would work.

In fact, if mmd conforms to plain text natively, this should happen without even changing the extension list.

What does mdls say about your mmd files?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jordanhubbard Based on your explanation, it looks like this change is needed, because .mmd won't be even recognized as a valid type if none of applications you installed can handle it.

Comment thread .swiftlint.yml Outdated
@@ -1,3 +1,6 @@
excluded:
- MarkEditMac/Modules/build
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this might be the right thing to do, but I personally never experienced once swiftlint is linting this directory, not sure why.


extension EditorViewController {
/// Preview the entire document as a Mermaid diagram; intended for .mmd files.
func previewDiagram(sender: NSToolbarItem) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is a bit weird for a Markdown editor, and the user experience here isn't optimal.

What dou you think leveraging https://github.com/MarkEdit-app/MarkEdit-preview instead?

In this PR we can focus allowing mmd file to open.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like you probably need a dedicated mermaid editor (I am not sure its existence).

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@cyanzhong I can get a mermaid editor online, but it is handy to be able to deal with .md files and .mmd files with a single application that can edit and preview them because, with agentic coding reaching a peak, I often have a mixture of both files in a single directory because the agents use .md files for their plans and .mmd files for their diagrams (architecture information, flow diagrams, and so on). There are commercial applications on the app store that do both, but jumping between apps is kind of a pain.

Would you suggest that each type of text file with a "live preview option" should live in a configurable plugin and simply have MarkEdit be able to browse and load plugins, perhaps? I'm just thinking out loud here.

Are you in a China timezone? I'm in the U.S. at the moment but am traveling to Shanghai in the morning and can continue this thread in "local time" if that's where you're located!

Copy link
Copy Markdown
Contributor

@cyanzhong cyanzhong Mar 17, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the explanation.

In my view, MarkEdit probably should not attempt to handle every type of text file, since it is fundamentally designed for Markdown.

One possible approach is to continue allowing .mmd files to open, as they are still plain text. This PR could focus specifically on that. In addition, the existing Mermaid support in MarkEdit Preview could be extended with a simple rule: if the entire file content is Mermaid, render it directly.

Yes I am based in China, but I tend to respond to messages at fairly random times.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you agree with this approach of leveraging the preview extension, then let's remove the changes related to adding a new toolbar item and instead focus this PR on enabling support for opening "mmd" files. Thanks!

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sounds good!

@cyanzhong
Copy link
Copy Markdown
Contributor

I plan to release a minor build to address several issues. We can first check in the changes to allow .mmd files, along with my updates to work around the Swift 6 concurrency issue.

Let's discuss this later.

@cyanzhong cyanzhong self-requested a review March 19, 2026 01:58
@cyanzhong cyanzhong requested a review from Copilot March 19, 2026 02:00
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds baseline support for opening Mermaid source files (.mmd) in MarkEdit by registering the extension/UTType and treating it as a text file in the app’s URL heuristics. Also updates SwiftLint configuration to exclude a build output path.

Changes:

  • Register .mmd in Info.plist (document type extension + exported UTType app.markedit.mmd).
  • Add mmd to the textFileExtensions allowlist to ensure .mmd is treated as non-binary text.
  • Add a SwiftLint excluded entry for a Modules build directory.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.

File Description
MarkEditMac/Info.plist Adds .mmd extension and exports app.markedit.mmd UTType.
MarkEditKit/Sources/Extensions/URL+Extension.swift Treats .mmd as a text file extension (non-binary).
.swiftlint.yml Introduces an excluded path for linting.
Comments suppressed due to low confidence (1)

MarkEditMac/Info.plist:36

  • LSItemContentTypes for the document type doesn’t include the newly exported app.markedit.mmd UTType (defined later in UTExportedTypeDeclarations). Without listing it here (or in a dedicated Mermaid document type), LaunchServices may not consistently associate .mmd files with the exported content type, which can affect “Open With” / type display. Add app.markedit.mmd to the appropriate LSItemContentTypes list (ideally for a Mermaid-specific document type).
			<key>LSItemContentTypes</key>
			<array>
				<string>net.daringfireball.markdown</string>
				<string>net.ia.markdown</string>
				<string>app.markedit.md</string>
				<string>app.markedit.markdown</string>
				<string>app.markedit.txt</string>
				<string>public.markdown</string>

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

You can also share your feedback on Copilot code review. Take the survey.

Comment thread MarkEditMac/Info.plist
Comment thread .swiftlint.yml Outdated
Comment thread MarkEditKit/Sources/Extensions/URL+Extension.swift
@cyanzhong cyanzhong requested a review from Copilot March 19, 2026 02:38
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds baseline support for opening Mermaid .mmd files in MarkEdit by registering the extension/UTType and treating .mmd as a text file (plus a SwiftLint config tweak).

Changes:

  • Register .mmd as an NSDocument type and export app.markedit.mmd UTType in Info.plist.
  • Add mmd to the textFileExtensions allowlist so .mmd is treated as non-binary.
  • Exclude MarkEditMac/Modules/.build from SwiftLint.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.

File Description
MarkEditMac/Info.plist Adds .mmd document type + exported UTType declaration.
MarkEditKit/Sources/Extensions/URL+Extension.swift Treats .mmd as a text file extension.
.swiftlint.yml Excludes SPM build output under MarkEditMac/Modules/.build.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

You can also share your feedback on Copilot code review. Take the survey.

Comment thread MarkEditMac/Info.plist Outdated
Comment thread MarkEditMac/Info.plist
Comment thread MarkEditKit/Sources/Extensions/URL+Extension.swift
@cyanzhong
Copy link
Copy Markdown
Contributor

cyanzhong commented Mar 20, 2026

I've decided to move mmd and mermaid to a "structured text" type: #1292.

@jordanhubbard jordanhubbard deleted the feature/mmd-file-support branch March 20, 2026 22:39
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.

3 participants