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                   <[email protected]>
    Garrison Computer Services      <http://www.garrison.com.au>

--
This is the BBEdit Talk public discussion group. If you have a feature request or need 
technical support, please email "[email protected]" 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 [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/bbedit/429E9A2E-BFD6-4B01-BEB3-17B693E0E9D5%40garrison.com.au.

Reply via email to