Recent releases of Marked have fixed Bear compatibility on Sonoma. As part of this, I’ve updated the Bear style for Marked, and written a little custom preprocessor to handle Bear’s (CommonMark) syntax properly. If you want a Marked preview styled to look exactly like Bear (with all of Marked’s options for export, navigation, and other features), you can use the Bear style in combination with the preprocessor, but if you just want Bear’s syntax properly interpreted, you can use the preprocessor with the style of your choosing1.

To get the Bear style, go the the Style Gallery and open the Bear style. Click “Install” to add it to Marked in one click.

For the custom preprocessor to work, you’ll need Ruby available on your system. As far as I know, Ruby is still distributed with macOS (for now), and if you open Terminal and run which ruby, you should get a path back, e.g. /usr/bin/ruby. If this isn’t the case for you and you need further help, please post on the support forum and I’ll update the instructions as needed.

For handling Bear’s specific syntax, like [[links]], underlining, and strikethrough, you’ll need a custom preprocessor. Save the following to a file called bear-preprocessor.rb in a safe folder (one you won’t move in the future).

Updated: now handles making tags clickable as well, and no longer requires that the #Text is tag preference be set in Marked.

Updated: now handles links with titles ([[link|title]]) and links with headers ([[link/header]]).

bear_preprocessor.rbraw
"
#!/usr/bin/env ruby
# frozen_string_literal: true

require 'cgi'

input = $stdin.read.force_encoding('utf-8')

# Handle [[links]]
input.gsub!(/\[\[(?<content>.*?)\]\]/) do
  m = Regexp.last_match
  # Test for link|title matchup
  if m['content'] =~ /(?<link>.+)\|(?<title>.+)/
    l = Regexp.last_match
    title = l['title']
    link = l['link']
  else
    title = m['content']
    link = m['content']
  end

  # Test for note/header matchup
  if link =~ %r{(?<page>.+)/(?<header>.+)}
    l = Regexp.last_match
    link = l['page']
    header = l['header']
  else
    header = nil
  end

  header = header.nil? ? '' : "&header=#{CGI.escape(header).gsub(/\+/, '%20')}"

  url = CGI.escape(link).gsub(/\+/, '%20')
  callback = CGI.escape("bear://x-callback-url/create?title=#{url}").gsub(/\+/, '%20')
  "[#{title}](bear://x-callback-url/open-note?title=#{url}#{header}&x-error=#{callback})"
end

# Handle ==highlight==
input.gsub!(/==(.*?)==/, '<mark>\1</mark>')

# Handle ~~deletion~~
input.gsub!(/~~(.*?)~~/, '<del>\1</del>')

# Handle ~underline~
input.gsub!(/~(.*?)~/, '<span class="underline">\1</span>')

# Handle tags, linking to tag pages in Bear
input.gsub!(%r{(?!<#)#(?<tag>[^\s#,?.!]+)}i) do
  m = Regexp.last_match
  tag = CGI.escape(m['tag'])
  %(<span class="mkstyledtag"><a href="bear://x-callback-url/open-tag?name=#{tag}">##{m['tag']}</a></span>)
end

puts input

Open terminal and run chmod a+x /path/to/file/bear-preprocessor.rb. That will make it executable, then you can just add /path/to/file/bear-preprocessor.rb as your custom preprocessor path in Marked->Advanced preferences. (To get the absolute path for a file, right click it in Finder, hold down Option, and click ‘Copy “bear-preprocess.rb” as Pathname’. That will put the absolute path to the file in your clipboard, which you can paste for both the chmod command and the Custom Preprocessor field.)

This script will convert [[wiki links]] into Bear internal links, which will open linked notes in Bear when clicked, and handle special cases like ~~strikethrough~~, ~underline~, and ==highlighting==.

In addition, you’ll want to set your Processor to MultiMarkdown and enable “#Text is tag” and the sub-item “Style tags” in Preferences->Processor. Note that the #tag processing will only work if you’re not using a custom processor (custom preprocessor like above won’t override it). New script above handles #tags and makes them clickable.

If you need additional help setting this up, just ping me on http://support.markedapp.com.

If you’re using a non-Bear Style and want underlines formatted, you can modify a custom Style or add the following to Marked->Preferences->Style->Additional CSS and modify as desired:

.underline {
	border-bottom: 1px solid rgb(222, 84, 86);;
}

I might eventually add support for Bear (CommonMark) syntax directly to Marked, but the whole purpose of the preprocessor functionality was to handle cases like this, and linking to Bear documents internally should be a case-by-case decision. The same part of the custom preprocessor that handles [[links]] could be repurposed for any system that allows internal [[linking]] and has a url handler syntax (like nvUltra, which I’ll post a preprocessor for when it’s available2, or Obsidian). You can also always set up CommonMark as a custom processor to get full compatibility.

  1. It won’t include underline styling unless you add it to your Style, as detailed below 

  2. you don’t believe me at this point, which is fully understandable, but it really is coming.