NAME
YAML::Tidy - Tidy YAML files
SYNOPSIS
% cat in.yaml
a: # a comment
b:
c: d
% yamltidy in.yaml
a: # a comment
b:
c: d
DESCRIPTION
yamltidy is a linter or rather a formatter for YAML files.
It can adjust formatting without removing comments or blank lines.
For examples see https://perlpunk.github.io/yamltidy
The code can be found at https://github.com/perlpunk/yamltidy.
FEATURES
- Trim trailing spaces
- Adjust indentation
- Remove unnecessary quotes (currently according to the YAML 1.2 Core Schema)
- Serialize reused aliases
Plans
- Add option for batch processing multiple files, e.g. by extension
- Use exit code to signal if yamltidy did any changes
- Quoting: Allow to add patterns for strings that should be quoted
- For more, see https://github.com/perlpunk/yamltidy/issues. Suggestions welcome!
METHODS
new
-
my $yt = YAML::Tidy->new;
tidy
-
my $outyaml = $yt->tidy($inyaml);
highlight
-
my $ansicolored = $yt->highlight($yaml, 'ansi'); my $html = $yt->highlight($yaml, 'html');
cfg
-
my $cfg = $yt->cfg;
Return YAML::Tidy::Config
AUTHOR
Tina Müller <tinita@cpan.org>
SEE ALSO
- yamllint https://yamllint.readthedocs.io/en/stable/
- perltidy Perl::Tidy
- YAML::LibYAML::API
- https://github.com/yaml/libyaml
- https://www.yaml.info/
COPYRIGHT AND LICENSE
Copyright 2024 by Tina Müller
This library is free software and may be distributed under the same terms as perl itself.