Add .mmd (Mermaid diagram) file support#1284
Conversation
- 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>
| </array> | ||
| <key>UTExportedTypeDeclarations</key> | ||
| <array> | ||
| <dict> |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
@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.
| @@ -1,3 +1,6 @@ | |||
| excluded: | |||
| - MarkEditMac/Modules/build | |||
There was a problem hiding this comment.
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) { |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
It looks like you probably need a dedicated mermaid editor (I am not sure its existence).
There was a problem hiding this comment.
@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!
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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!
|
I plan to release a minor build to address several issues. We can first check in the changes to allow Let's discuss this later. |
There was a problem hiding this comment.
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
.mmdinInfo.plist(document type extension + exported UTTypeapp.markedit.mmd). - Add
mmdto thetextFileExtensionsallowlist to ensure.mmdis treated as non-binary text. - Add a SwiftLint
excludedentry 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
LSItemContentTypesfor the document type doesn’t include the newly exportedapp.markedit.mmdUTType (defined later inUTExportedTypeDeclarations). Without listing it here (or in a dedicated Mermaid document type), LaunchServices may not consistently associate.mmdfiles with the exported content type, which can affect “Open With” / type display. Addapp.markedit.mmdto the appropriateLSItemContentTypeslist (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.
There was a problem hiding this comment.
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
.mmdas anNSDocumenttype and exportapp.markedit.mmdUTType inInfo.plist. - Add
mmdto thetextFileExtensionsallowlist so.mmdis treated as non-binary. - Exclude
MarkEditMac/Modules/.buildfrom 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.
|
I've decided to move mmd and mermaid to a "structured text" type: #1292. |
What this does
Adds first-class support for
.mmdfiles — the conventional extension for standalone Mermaid diagram source files.Changes:
.mmdas an openable file type (Info.plistdocument type + exported UTTypeapp.markedit.mmd,textFileExtensionsallowlist)Previewerpopover infrastructure — no new dependenciesWhy I find this useful: I maintain a small collection of
.mmddiagram 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 thePreviewerpopover, wiring up standalone.mmdfiles 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
Previewerand adds no new dependencies.Test plan
.mmdfile — MarkEdit accepts it and shows the raw diagram source as editable text.mmdfile in Finder → Open With — MarkEdit appears as an option🤖 Generated with Claude Code