Skip to content

Text Processing

Ying Zhong edited this page Aug 29, 2026 · 30 revisions

Using System Services

As a native macOS app, MarkEdit works seamlessly with system services. Please refer to Apple's official user manual. If you're already familiar with similar workflows in TextEdit, they work the same way in MarkEdit.

This also means that the techniques described on this page work with any well-designed text editor for macOS.

Leveraging Shortcuts

This section explains how to add services easily with the Shortcuts app, using the conversion of text to uppercase as an example:

Shortcuts

By enabling Service Menu and Provide Output, the shortcut appears in the system Services menu and can replace the selected text. You can also assign a keyboard shortcut so that you don't need to use the contextual menu.

This example is extremely simple: the "processing" step merely converts the input to uppercase. However, Shortcuts is very powerful and offers many advanced actions, such as sending HTTP requests and parsing responses. You can even run scripts to unlock more possibilities.

Tip

You can run shortcuts from the contextual menu when text is selected or from the main menu without a selection.

MarkEdit Actions

Shortcuts has many built-in actions and allows third-party apps such as MarkEdit to provide their own.

MarkEdit Actions

In the example above, you can preview the active Markdown document as HTML. This shortcut must be run from the main menu because it does not take selected text as input.

Here is a more advanced example based on Markdeep for those who prefer a preview with style sheets:

Markdeep

MarkEdit includes a few built-in actions. You can easily implement Send to MarkEdit with the Create New Document action. Shortcuts also includes several Markdown conversion actions, allowing you to quickly build workflows such as Paste from HTML.

Note

This feature requires macOS 13 or later because it uses the App Intents framework.

Evaluating JavaScript

Just as you can customize the editor, you can use the advanced Evaluate JavaScript action to run JavaScript on the current document and retrieve the result.

For example, this shortcut toggles the zoom level of the editor, without changing the actual font size.

Evaluate JavaScript

In addition to standard Web APIs, you can interact with the window.editor object. You can also use the interfaces exposed through the MarkEdit object, as documented in MarkEdit-api.

Note

The techniques in this section require a basic understanding of frontend development. Please open an issue if you encounter errors or have suggestions.

Building Your AI Assistant

As mentioned above, Shortcuts can do many impressive things. Why not integrate it with the OpenAI APIs to build an AI assistant?

Fortunately, the community has built some excellent shortcuts, including Summarize, Improve readability, and Translate. Learn more in this post: How to use Apple Shortcuts to integrate GPT-4o in macOS and iOS.

Note

Review shortcuts before running them. They may send requests to a server and introduce privacy risks.

Leveraging AppleScript

MarkEdit v1.23.0 added AppleScript support. See the discussion in #854. Here is an example:

tell application "MarkEdit"
  -- Getting the full content
  set full_content to source of document 1
  display dialog full_content

  -- Getting the selected text
  set selected_text to selection of document 1
  display dialog selected_text

  -- Replacing the selection
  set selection of document 1 to "Bazinga!"

  -- Creating a new document
  set new_document to make new document with properties {name:"New File.md"}

  -- Modifying the document we just created
  delay 0.5
  set source of new_document to "Hello, World!"
end tell

Tip

For more examples, see the pull request and this gist.

Wrapping Up

In conclusion, we don't need to build text-processing features directly into MarkEdit. Instead, we will keep MarkEdit a good macOS citizen and make it programmable through system services.

Clone this wiki locally