If you’re not using UTF-8 encoding, remove “–encode UTF-8”. Put this in your Tidy.sh file in ~/Library/Application Support/TextWrangler/Text Filters Xmllint –c14n – | XMLLINT_INDENT=$’\t’ xmllint –encode UTF-8 –format –Ĭat $STDIN | xmllint –c14n – | XMLLINT_INDENT=$’\t’ xmllint –encode UTF-8 –format – (If you’re curious, the difference is that the long hypen before the options should be a double dash, the long hyphen after “c14n” should be single dash, and the single quotes need to be changed to simple straight quotes instead of curly quotes.) It took me a while to figure out what was happening, so I’ve reposted their commands below. UPDATED:: Updated for TextWrangler version 4.5.8.īoth epharion and Mitch’s commands will work for TextWrangler verson 4, however they are mangled by the automatic formatting. UPDATED:: Added a post to format PHP code in TextWrangler. UPDATED:: Added UTF8 encoding, thanks Rolan. This is an interesting facility to extend an already great text editor, and I will be looking into more cool scripts that can hopefully lessen my daily annoyances. Now anytime you want to format an XML file, just go to the Text menu and select the Tidy XML.sh script and BOOM, neat tidy XML.Save the file, something like Tidy XML.sh, in the ~/Library/Application Support/TextWrangler/Text Filters/ folder.XMLLINT_INDENT=$'\t' xmllint -format -encode utf-8. Copy and paste the code below into this file. Open TextWrangler and open a new text file.We want to add a UNIX script to TextWrangler so it can format an XML file… to do this, do this… However, I found a simple way to do this today… thanks to this and this and this. Basically, it looked a mess and there was no way to tidy the file up so that I could read it easily. One issue that bugged me lately was when I opened an unindented, unformatted XML file. In particular, I like that I can SFTP into my development server. It’s lightweight and it has pretty much all you need from a text editor. My text editor of choice on the Mac is TextWrangler.
0 Comments
Leave a Reply. |