Last active
January 30, 2026 18:45
-
-
Save cuellarfr/15ae4d74c02514472f25bcd1fb74bec9 to your computer and use it in GitHub Desktop.
A script for CotEditor that launches a Markdown preview in your default browser
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| #%%%{CotEditorXInput=AllText}%%% | |
| #%%%{CotEditorXOutput=None}%%% | |
| INPUT=$(/opt/homebrew/bin/cmark) | |
| TMPFILE="/tmp/md-preview-$$.html" | |
| cat > "$TMPFILE" << 'EOF' | |
| <html><head> | |
| <style> | |
| body { | |
| font-family: Helvetica, Arial, sans-serif; | |
| max-width: 720px; | |
| margin: 2rem auto; | |
| padding: 0 1rem; | |
| line-height: 1.6; | |
| } | |
| @media (prefers-color-scheme: dark) { | |
| body { | |
| background-color: #1e1e1e; | |
| color: #e0e0e0; | |
| } | |
| a { color: #6cb6ff; } | |
| code, pre { | |
| background-color: #2d2d2d; | |
| } | |
| } | |
| code, pre { | |
| background-color: #f4f4f4; | |
| padding: 0.2em 0.4em; | |
| border-radius: 4px; | |
| } | |
| pre { padding: 1em; overflow-x: auto; } | |
| </style></head><body> | |
| EOF | |
| echo "$INPUT" >> "$TMPFILE" | |
| echo "</body></html>" >> "$TMPFILE" | |
| open "$TMPFILE" |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
INSTALLATION
brew install cmarkchmod u+x ~/Library/Application Scripts/com.coteditor.CotEditor/Markdown Preview.@M.sh