Skip to content

Commit

Permalink
Add two BBEdit text filters that match the functionality of the "acce…
Browse files Browse the repository at this point in the history
…pt" and "reject" services.

The Critic Markup toolkit ships with a pair of services to accept/reject Critic Markup annotations. These text filters largely recreate those services. Adding these to provide an alternative to the services.
  • Loading branch information
Michael Hall committed Jun 3, 2014
1 parent 7fb8afc commit cce68e3
Show file tree
Hide file tree
Showing 3 changed files with 63 additions and 0 deletions.
27 changes: 27 additions & 0 deletions BBEdit Additions/Text Filters/00)Accept CMark
@@ -0,0 +1,27 @@
#!/usr/bin/env ruby
# CriticMarkup accept change script for BBEdit

myMark = STDIN.read

# CriticMarks
# -----------
# Addition {++ ++}
# Deletion {-- --}
# Substitution {~~ ~> ~~}
# Comment {>> <<}
# Highlight {== ==}{>> <<}

addition_mark = /^\{\+\+(.+?)\+\+\}$/
deletion_mark = /^\{\-\-(.+?)\-\-\}$/
sub_mark = /^\{\~\~(.+?)\~\>(.+?)\~\~\}$/
comment_mark = /^\{\>\>(.+?)\<\<\}/
highlight_mark = /^\{\=\=(.+?)\=\=\}\{\>\>(.+?)\<\<\}$/

if addition_mark =~ myMark
print myMark.gsub(addition_mark, "\\1").chomp
elsif deletion_mark =~ myMark
print ""
elsif sub_mark =~ myMark
print myMark.gsub(sub_mark, "\\2").chomp
else
end
28 changes: 28 additions & 0 deletions BBEdit Additions/Text Filters/00)Reject CMark
@@ -0,0 +1,28 @@
#!/usr/bin/env ruby
# CriticMarkup reject change script for BBEdit

myMark = STDIN.read

# CriticMarks
# -----------
# Addition {++ ++}
# Deletion {-- --}
# Substitution {~~ ~> ~~}
# Comment {>> <<}
# Highlight {== ==}{>> <<}

addition_mark = /^\{\+\+(.+?)\+\+\}$/
deletion_mark = /^\{\-\-(.+?)\-\-\}$/
sub_mark = /^\{\~\~(.+?)\~\>(.+?)\~\~\}$/
comment_mark = /^\{\>\>(.+?)\<\<\}/
highlight_mark = /^\{\=\=(.+?)\=\=\}\{\>\>(.+?)\<\<\}$/

if addition_mark =~ myMark
print ""
elsif deletion_mark =~ myMark
print myMark.gsub(deletion_mark, "\\1")
elsif sub_mark =~ myMark
print myMark.gsub(sub_mark, "\\1")
else

end
8 changes: 8 additions & 0 deletions BBEdit Additions/Text Filters/README.markdown
@@ -0,0 +1,8 @@
You can put BBEdit text filters in the `Text Filters` folder of your BBEdit configuration folder (`~/Library/Application Support/BBEdit/Text Filters`) unless you've moved your configuration directory to Dropbox).

1. Put them in the appropriate folder
2. (Re)start BBEdit

You can also assign keyboard shortcuts to each of the filters from BBEdit's preferences (**Menus & Shortcuts** &raquo; **Text** &raquo; **Apply Text Filter**). The "control" combinations are largely unused in BBEdit (with the exception of control-s, which is used for progressive search).

Finally, you can make the filters appear at the top of the Filters menu by prepending `00)` to the filename of each.

0 comments on commit cce68e3

Please sign in to comment.