XML linter?

70 views
Skip to first unread message

@lbutlr

unread,
Jul 22, 2021, 5:46:53 PM7/22/21
to BBEdit Talk
A brief mention of using linters with BBEdit got me wondering if there is a linter for XML that works on macOS? The only thing I find one looking around are web based ones and on linux tool that is not in homebrew.

And assuming there is one, how do I integrate it into BBEdit?

--
Margo: P.S. We still hate you. but it's the twenty-first century. It shouldn't
be this hard for a girl to get an evil demigod abortion.
Eliot: And we're emotionally advanced. We can hold resentment and sympathy for
a person at the same time.

Edzard de Ranitz

unread,
Jul 23, 2021, 8:47:05 AM7/23/21
to BBEdit Talk
The build in function Markup > Tidy > Reflow works fine for me for XML

@lbutlr

unread,
Jul 23, 2021, 2:26:44 PM7/23/21
to BBEdit Talk
On 2021 Jul 23, at 05:47, Edzard de Ranitz <ran...@gmail.com> wrote:
> The build in function Markup > Tidy > Reflow works fine for me for XML

It does not check syntax like a linter does.

(Fore example, XML wants &#x26; instead of &amp;

--
Noble dragons don't have friends. The nearest they can get to the
idea is an enemy who is still alive. --Guards! Guards!

jj

unread,
Jul 23, 2021, 3:10:47 PM7/23/21
to BBEdit Talk

Did you try xmllint ?

Check if it is installed on your setup by typing in the Terminal: 

    which xmllint
    
If it is not installed you can intall it from Homebrew.
It's part of the libxml2 package.
In Terminal type:

    brew install libxml2
    
HTH

Jean Jourdain

@lbutlr

unread,
Jul 23, 2021, 6:31:06 PM7/23/21
to BBEdit Talk
On 2021 Jul 23, at 13:10, jj <goo...@mixio.com> wrote:
> Did you try xmllint ?

Ah, yes I do. Now, how to use it within BBEdit. (The only 'lint' mention in the manual is about using bbresults from the command line).

--
"Are you pondering what I'm pondering?"
"I think so, Brain, but what would goats be doing in red leather
turbans?"

jj

unread,
Jul 24, 2021, 4:22:10 AM7/24/21
to BBEdit Talk
Create a text filter named xmllint.sh and save it in "menu BBEdit > Folders > Text Filters" with executable permissions.

```
#!/usr/bin/env sh

xmllint --format -
```

You can then apply the filter to your document's selection or to the whole document if nothing is selected with "menu Text > Apply Text Filter > xmllint.sh".

For more info on xmllint options, type in the terminal:

    man xmllint

HTH

Jean Jourdain
Reply all
Reply to author
Forward
0 new messages