Skip to content

About

Markdown preview for MarkEdit.

Resources

Stars

0 stars

Watchers

0 watching

Forks

 
 

Repository files navigation

MarkEdit-preview-obsidian

A fork of MarkEdit-preview that adds Obsidian flavored markdown to the preview, and wikilink support in Quick Look. Everything else follows upstream releases.

Upstream intentionally doesn't support non-standard syntax (discussion), so this fork is maintained separately. Please report fork-specific issues here, not upstream.

Installing the fork

  1. Remove the original markedit-preview.js from MarkEdit's scripts folder (~/Library/Containers/app.cyan.markedit/Data/Documents/scripts/). The two can't run at the same time.
  2. Also remove markedit-preview.js from Quick Look's folder (~/Library/Group Containers/group.app.cyan.markedit/Shared/scripts/), if it's there.
  3. Run yarn install && yarn build from your own Terminal app, or copy dist/markedit-preview-obsidian.js into the scripts folder with Finder.
  4. Restart MarkEdit.

Settings still use the extension.markeditPreview key below, so existing settings keep working.

Syncing with upstream

The Sync with upstream workflow checks for a new MarkEdit-preview release every day. When there is one, it merges it, runs the checks, rebuilds dist/, and opens a pull request. If the merge conflicts with this fork's changes, it opens an issue instead. It can also be started from the Actions tab.

To sync by hand, run ./scripts/sync-upstream.sh [tag], then run the tests and rebuild dist/.


Original README:

Markdown view modes for MarkEdit that leverage markedit-api.

Installation

Install this extension from the MarkEdit Extension Registry.

Building

Run yarn install && yarn build to build and deploy the script.

To build the lite version, run yarn build:lite instead.

Development

  • yarn test — run tests
  • yarn lint — run linting (also runs automatically before build)
  • yarn typecheck — run TypeScript checks (also runs automatically before the full build)

How to Use

Choose a mode from Extensions > View Mode, or use the keyboard shortcut Shift–Command–V to cycle through modes.

Using MarkEdit-preview

To display local images, please ensure you're using MarkEdit 1.24.0 or later and follow the guide to grant file access.

This extension also exposes global functions, MarkEditGetHtml(styled: boolean) => Promise<string> and MarkEditRenderHtml(markdown: string, styled: boolean) => Promise<string>, allowing other extensions or scripts to easily generate the rendered HTML — either from the current document or from arbitrary markdown input.

Obsidian Syntax

The preview renders Obsidian flavored markdown in addition to GitHub flavored markdown:

Syntax Rendering
> [!faq] Title Callouts, with all Obsidian types and aliases, and markdown in titles; GitHub alerts keep working
> [!tip]- / > [!tip]+ Foldable callouts, collapsed or expanded by default
==text== Highlights
%%comment%% Comments, inline or spanning multiple lines
#tag, #nested/tag Tags
text ^block-id Block IDs, the identifier is hidden and becomes the block's id
[[#Heading]], [[#^block-id]] Links within the same note
![[image.png]], ![[image.png|300]], ![[image.png|300x200]] Image embeds, found anywhere in the vault
![[Note]] Note embeds, rendered as links

Other [[wikilinks]] are left as text, so extensions like MarkEdit-wikilinks can resolve them. Note embeds use the same me-wikilink class, so these extensions can open them too.

Image embeds and wikilinks are resolved across the vault the same way MarkEdit-wikilinks does: the current note's folder first, then a vault-relative path, then any file with that name. The vault is the closest folder containing .obsidian, .git or .markedit-vault, and MarkEdit needs access to it. Links to notes that don't exist are shown faded with a dashed underline, and hovering a link shows where it leads.

In Quick Look, where other extensions don't run, wikilinks are rendered as links in the preview and highlighted in the source view (macOS 14.2 or later).

In Mixed mode, wikilinks hide their brackets like regular links: [[Note|alias]] shows only "alias", and the full syntax comes back when the cursor enters it. The link button opens the note, found the same way as in the preview. Image embeds like ![[image.png|300]] show the image inline when inlineRendering includes "image". Plain wikilinks need MarkEdit-wikilinks, whose parser recognizes them; embeds work without it.

Styling

This extension applies the github-markdown styling. You can customize the appearance by following the customization guidelines.

The preview pane can be styled using the markdown-body CSS class.

Settings

In settings.json, you can define a settings node named extension.markeditPreview to configure this extension, default settings are:

{
  "extension.markeditPreview": {
    "syncScroll": true,
    "hidePreviewButtons": true,
    "syntaxAutoDetect": false,
    "imageHoverPreview": false,
    "inlineRendering": ["math", "mermaid"],
    "themeName": "github",
    "styledHtmlColorScheme": "auto",
    "mathDelimiters": [],
    "changeMode": {
      "modes": ["edit", "side-by-side", "preview", "syntax-hidden"],
      "hotKey": {
        "key": "V",
        "modifiers": ["Command"]
      }
    },
    "markdownIt": {
      "preset": "default",
      "options": {
        "html": true,
        "breaks": true,
        "linkify": true
      }
    },
    "mermaid": {
      "lightTheme": "default",
      "darkTheme": "dark"
    }
  }
}
  • syncScroll: Whether to enable scroll synchronization.
  • hidePreviewButtons: Whether to hide the built-in preview buttons in side-by-side mode (not applicable for lite build).
  • syntaxAutoDetect: Whether to enable automatic language detection for syntax highlighting in code blocks (not applicable for lite build).
  • imageHoverPreview: Whether to enable image preview on hover.
  • inlineImages (deprecated): Whether Mixed mode renders images inline, defaults to false. Use inlineRendering instead; an explicit inlineRendering array takes precedence.
  • inlineRendering: Types rendered inline in Mixed mode: "table", "math", "mermaid", "image", and "html". Defaults to ["math", "mermaid"]; use [] to disable all rendering. Math and Mermaid rendering require the full build.
  • themeName: Set the preview color theme, available themes can be found in the styles/themes folder. Use "none" to disable preview styling and render the raw HTML.
  • styledHtmlColorScheme: Determine the color scheme of saving styled html files, valid values are light, dark, and auto.
  • mathDelimiters: Customize math delimiters for KaTeX rendering (not applicable for lite build), each delimiter object has left, right, and display properties, defaults to $...$, $$...$$, \(...\), and \[...\].
  • changeMode.modes: Order modes by ID: edit (Markdown Source), side-by-side (Side-by-Side), preview (Overlay), and syntax-hidden (Mixed). If neither editor mode is included, edit is added automatically.
  • changeMode.hotKey: Assign keyboard shortcuts for mode switching. See the specification here.
  • markdownIt.preset: Override the default markdown-it preset.
  • markdownIt.options: Customize markdown-it options.
  • mermaid.lightTheme / mermaid.darkTheme: Set Mermaid themes for previews and exports (full build only). Keeps the legacy colors by default: "default" in light mode and "dark" in dark mode. To opt into Mermaid 12's colorful palettes, use "redux-color" and "redux-dark-color" respectively.

Tip

In MarkEdit 1.33.0 or later, this extension also provides preview support in Quick Look.

To add menu items to the toolbar, see MarkEdit Customization wiki.

Community Extensions

  • Bidirectional Preview Sync (by @Nigelw): Keeps MarkEdit’s editor and preview modes synchronized as you switch between them and scroll, replacing MarkEdit-preview's one-way editor→preview sync.
  • Direct Preview (by @Squarelight-ai): A setup helper that provides a one-click setup for a two-mode Edit/Preview toggle by configuring the toolbar item and changeMode.modes for you.

Contribution

Pull requests are welcome, but please discuss the proposal before making changes. This helps avoid misunderstandings and saves effort on both sides.

About

Markdown preview for MarkEdit.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages