YAML-Tidy
view release on metacpan or search on metacpan
lib/YAML/Tidy.pm view on Meta::CPAN
sub _debug_lines($self) {
say "====================================";
say for @{ $self->{lines} };
say "====================================";
}
sub highlight($self, $yaml, $type = 'ansi') {
my ($error, $tokens) = YAML::PP::Parser->yaml_to_tokens(string => $yaml);
if ($error) {
$tokens = [];
my @lines = split m/(?<=\n)/, $yaml;
for my $line (@lines) {
if ($line =~ s/( +\n)//) {
push @$tokens, { value => $line, name => 'PLAIN' };
push @$tokens, { value => $1, name => 'TRAILING_SPACE' };
next;
}
push @$tokens, { value => $line, name => 'PLAIN' };
}
}
if ($type eq 'html') {
( run in 0.421 second using v1.01-cache-2.11-cpan-71847e10f99 )