Skip to content

Instantly share code, notes, and snippets.

@mixio
mixio / copy_markdown_as_html.applescript
Last active November 8, 2022 16:58
This BBEdit script copies a markdown document's selection as HTML to the pasteboard.
(*
README
This BBEdit script copies a markdown document's selection as HTML to the pasteboard.
In case nothing is selected it copies the whole contents of the document.
DOCUMENTATION
https://pandoc.org
@mixio
mixio / sort_and_merge_indented_list.applescript
Last active October 16, 2022 18:30
BBEdit script to sort indented hierarchical lists
(*
README
Considering that list indentation is a form of compression, this BBEdit script
decompresses the list, sorts it with the shell `sort` command, and compresses it back again.
In doing so, the indented list will be sorted, sub lists will be merged and
duplicates will be eliminated.
For sorting options (case insensitive, etc.) see the `sort` man page in terminal and
@mixio
mixio / find_longest_repeated_substring.go
Created April 30, 2022 18:28
A BBEdit Text Filter that will help find a document's longest repetition
#!/usr/bin/env gorun
// Original code: https://rosettacode.org/wiki/Ukkonen’s_suffix_tree_construction
/*
Here is a BBEdit Text Filter that will scan the frontmost document's selected text (or the whole document in no selection) for the longest repeated substring and log a regular expression in the 'Unix Script Output.log' that allows you to find the repetition.
It works by replacing all non alphanumeric or underscore characters with a regular expression, thus comparing only the 'text' and ignoring anything else: whitespace, punctuation, math operators, etc.
As a consequence, it's more useful on textual content than on code.
@mixio
mixio / select_contents_of_nth_tag.scpt
Last active March 15, 2022 09:11
BBEdit script to select inner contents of Nth tag of front document
(*
FILENAME:
select_contents_of_nth_tag.scpt
README:
This script:
• asks for a "tag#index" pair separated by a '#' hash mark:
- "tag" is the name of the seeked tag,
- "index" is the number of the seeked tag;
@mixio
mixio / Text Substitutions.plist
Created January 18, 2022 22:22
Countries Text Substitutions.plist
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN"
"http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<array>
<dict><key>shortcut</key><string>AD</string><key>phrase</key><string>Andorra</string></dict>
<dict><key>shortcut</key><string>AE</string><key>phrase</key><string>United Arab Emirates</string></dict>
<dict><key>shortcut</key><string>AF</string><key>phrase</key><string>Afghanistan</string></dict>
<dict><key>shortcut</key><string>AG</string><key>phrase</key><string>Antigua and Barbuda</string></dict>
@mixio
mixio / 0-[⌘…]-[underline_selection].applescript
Last active January 9, 2022 16:32
Adds a p͇s͇e͇u͇d͇o͇ ͇u͇n͇d͇e͇r͇l͇i͇n͇e͇ ͇s͇t͇y͇l͇e͇ to BBEdit
(*
README:
This scrit is a bit of a hack that takes advantage of Unicode combining
codepoints to create a p͇s͇e͇u͇d͇o͇ ͇u͇n͇d͇e͇r͇l͇i͇n͇e͇ ͇s͇t͇y͇l͇e͇.
It works by inserting the combining underline codepoint (U+0347 COMBINING EQUALS
SIGN BELOW) after each character of the selection, skipping linefeeds.
@mixio
mixio / 0-[⌘…]-[compare_extracts]-[1]-[open_differences_window].applescript
Created December 12, 2021 11:33
BBEdit scripts to diff two front windows' selections
(*
FILENAME:
0-[⌘…]-[compare_extracts]-[1]-[open_differences_window].applescript
README:
This script:
• extracts the selection of the two frontmost windows to two new temporary documents;
• names the temporary documents with the name of the original documents with identification metadata appended;
@mixio
mixio / emmet_expand_css_abbreviation.applescript
Last active November 12, 2021 17:10
This BBEdit applescript will try to expand css abbreviations using Emmet.
##
# README
#
# This script will try to expand Emmet css abbreviations.
# If nothing is selected in the frontmost document,
# it will use the expression at the left of the insertion point
# otherwise it will use the selected expression.
#
# See: https://github.com/emmetio/emmet
#
@mixio
mixio / test_process_pdfs.applescript
Last active July 4, 2021 20:08
This is a sample script showing how to process a directory of PDF files: 1) Extract PDF's text. 2) Create a BBEdit document with it.
--
use AppleScript version "2.7"
use scripting additions
use framework "Foundation"
--
property NSString : class "NSString"
property NSURL : class "NSURL"
property PDFDocument : class "PDFDocument"
property NSCharacterSet : class "NSCharacterSet"
--
@mixio
mixio / open_link_copied_to_clipboard_in_BBEdit.applescript
Created June 29, 2021 12:06
Run this script to have the contents of a link copied to the clipboard, downloaded into a new BBEdit document.