Hey guys -
I was thinking about a plugin that might be useful. It essentially offers a way to execute saved regular expressions on demand. For example, I’m often working with other people’s code or HTML, and I find myself making the same set of changes over and over. One thing that I’m constantly doing is removing type=“text/javascript” and type=“text/css” from script and link tags, respectively (they’re not necessary). If there was a plugin with a settings file…
{
replacements: {
'Remove Link and Script Types': /\stype="text\/(?:css|javascript)/ig
}
}
I could then pull up the command palette, choose “Remove Link and Script Types,” and the associated regular expression will instantly be run on the contents of the focused page.
…Or maybe to remove all HTML comments from the page:
replacements: {
'Remove HTML Comments': /<!--\s\S]+?-->/g
}
It would be even neater if there was a way to stack these. So, in addition to single commands, I could also execute a series of them with a single command: first use this regular expression to remove comments, then make the first letter of all words in h1 tags capital, etc.
sequence: {
"Optimize HTML": [replacement1, replacement1, replacement1]
}
The regex references in the array would then be executed sequentially on the document.
Personally, I’d have a lot of uses for something like this, but I’m not sure if anyone else would. Let me know, and, if so, we may hire @weslly to make it.