On 27 May 2021, at 2:41, Arthur Goldberg wrote:
I'm looking for text filters to format JSON and XML. Google and https://www.barebones.com/search.html finds things that are not well documented or seem outdated.
BBEdit has built-in support for XML. There are lots of choices for JSON. I use a multi-language filter, so one key shortcut will format a few languages (that I care about). I'm using prettier
as the formatter.
#!/bin/sh
## https://github.com/prettier/prettier
## https://prettier.io
## ~/.prettierrc.js
# echo $BB_DOC_NAME
# echo $BB_DOC_LANGUAGE
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
--
Charlie Garrison <cha...@garrison.com.au>
Garrison Computer Services <http://www.garrison.com.au>