This file contains 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
#!/usr/bin/env bash | |
# check color support | |
colors=$(tput colors) | |
if (($colors >= 8)); then | |
red='\033[0;31m' | |
nocolor='\033[00m' | |
else | |
red= | |
nocolor= |
This file contains 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
def wpautop(pee, br = true) | |
return '' if pee.strip == '' | |
pee = "#{pee}\n" # just to make things a little easier, pad the end | |
pee = pee.gsub(/<br \/>\s*<br \/>/s, "\n\n") | |
# pace things out a little | |
allblocks = '(?:table|thead|tfoot|caption|col|colgroup|tbody|tr|td|th|div|dl|dd|dt|ul|ol|li|pre|select|option|form|map|area|blockquote|address|math|style|input|p|h[1-6]|hr|fieldset|legend|section|article|aside|hgroup|header|footer|nav|figure|figcaption|details|menu|summary)'; | |
pee = pee.gsub(Regexp.new('(<'+allblocks+'[^>]*>)'), "\n"+'\1') | |
pee = pee.gsub(Regexp.new('(<\/'+allblocks+'[^>]*>)'), '\1' + "\n\n") | |
pee = pee.gsub(/\r\n|\r/, "\n") # cross-platform newlines | |
if pee.include?('<object') |