On 19 Sep 2020, at 3:48, James Reynolds wrote:
I know BBEdit has an HTML formatter. Can it also format code? Like
what https://beautifier.io/ does for JavaScript?
BBEdit has fantastic support for Text Filters. So if your formatter of
choice works via CLI, writing a formatter (prettifier) is fairly
trivial.
I have attached the filter script I use, which auto-detects language and
applies appropriate command. It should be easy to swap out `prettier`
for `beautifier`.
I set a keyboard shortcut for the filter, so it's as simple to use as
the built-in formatting - select the text to format, type shortcut. (No
selection will format the whole document.)
-cng
--
Charlie Garrison <char...@garrison.com.au>
Garrison Computer Services <http://www.garrison.com.au>
PO Box 380
Tumbarumba NSW 2653 Australia
--
This is the BBEdit Talk public discussion group. If you have a feature request or need
technical support, please email "supp...@barebones.com" rather than posting here.
Follow @bbedit on Twitter: <https://twitter.com/bbedit>
---
You received this message because you are subscribed to the Google Groups "BBEdit Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to bbedit+unsubscr...@googlegroups.com.
To view this discussion on the web visit
https://groups.google.com/d/msgid/bbedit/852FB848-89F7-4E5C-9872-1C361ECAEEAA%40garrison.com.au.
#!/bin/sh
## https://github.com/prettier/prettier
## https://prettier.io
## ~/.prettierrc.js
# echo $BB_DOC_NAME
# echo $BB_DOC_LANGUAGE
# SCSS
if [ "$BB_DOC_LANGUAGE" == "SCSS" ]; then
prettier --parser scss
elif [ "$BB_DOC_LANGUAGE" == "JavaScript" ] || [ "$BB_DOC_LANGUAGE" == "HTML"
]; then
prettier --parser flow
# prettier --parser babel
elif [ "$BB_DOC_LANGUAGE" == "JSON" ]; then
prettier --parser json
elif [ "$BB_DOC_LANGUAGE" == "SQL (Generic)" ] || [ "$BB_DOC_LANGUAGE" == "SQL
(MySQL)" ]; then
cli-sql-formatter --dialect sql
else
echo "unknown language: $BB_DOC_LANGUAGE"
fi
# prettier --use-tabs
# --parser
<flow|babylon|typescript|css|less|scss|json|json5|json-stringify|graphql|markdown|mdx|vue|yaml|html|angular>