Last active
October 8, 2019 00:38
-
-
Save scottslowe/5686217 to your computer and use it in GitHub Desktop.
This AppleScript takes Markdown text from BBEdit, runs it through MultiMarkdown, then through TextSoap, and finally posts it to a new entry in MarsEdit.
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
-- Set some global values to be used later in the script | |
property markdownloc : "/usr/local/bin/multimarkdown" | |
on translate_line_breaks(str) | |
set AppleScript's text item delimiters to {ASCII character 13} | |
set _lines to every text item of str | |
set AppleScript's text item delimiters to {ASCII character 10} | |
set str to _lines as text | |
set AppleScript's text item delimiters to {} | |
return str | |
end translate_line_breaks | |
-- Handler for when the script is called from the BBEdit scripts menu | |
on run | |
tell application "BBEdit" | |
set mdSource to contents of text window 1 as Unicode text | |
end tell | |
set mdSource to translate_line_breaks(mdSource) | |
set rawHTML to do shell script "echo " & the quoted form of mdSource & " | " & markdownloc | |
tell application "textsoap7agent" | |
set cleanedHTML to cleanText rawHTML with "Remove HTML Entities" | |
end tell | |
tell application "MarsEdit" | |
make new document | |
tell document 1 | |
set body to cleanedHTML | |
end tell | |
activate | |
end tell | |
end run |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment