#!/usr/bin/env perl use v5.34; use warnings; use feature 'signatures'; no warnings 'experimental'; use Getopt::Std (); use CommonMark (); BEGIN { *CM:: = *CommonMark:: } sub usage($fh) { print $fh <<~'EOF'; Usage: md md -h EOF } sub help($fh) { print $fh <<~'EOF'; Options: -h, --help show this message EOF } for (@ARGV) { last if $_ eq '--'; if ($_ eq '--help') { usage *STDOUT; help *STDOUT; exit; } } my %opts; if (!Getopt::Std::getopts('h', \%opts)) { usage *STDERR; exit 2; } if ($opts{h}) { usage *STDOUT; help *STDOUT; exit; } sub into_table($s) { my @lines = (); my $i = 1; for (split "\n", $s) { my $line = '
', 'antes';
print $fh1 $s;
close $fh1;
open my $fh2, '>', 'depois';
print $fh2 $s2;
close $fh2;
say '=========' if $s eq $s2;
break;
say "$s";
my $doc = CM->parse(file => *STDIN);
my $iter = $doc->iterator;
while (my ($event_type, $node) = $iter->next) {
# say $node->get_on_exit;
# say $node->get_type_string;
# next;
# next if $node->get_type == CM::NODE_DOCUMENT;
# next unless $event_type == CM::EVENT_ENTER;
if ($node->get_type == CM::NODE_CODE_BLOCK) {
# say $node->get_on_exit;
# say $node->get_on_enter;
# say 123;
# next;
# $node->set_literal(into_table($node->get_literal));
# say 123;
} else {
# say $node->render(format => 'html');
# use Data::Dumper;
# say Dumper($node->get_type_string);
}
}
say $doc->render(format => 'html', unsafe => 1);
}
default {
print STDERR "Bad ACTION \"$_\".\n\n";
usage *STDERR;
exit 2;
}
}
__END__
# use Data::Dumper;
# print Dumper(\%opts);
# exit: extra newline in output
# no warnings ('experimental::signatures', );
# no warnings ('experimental::when', );
# $Getopt::Std::STANDARD_HELP_VERSION = 1;
perlcritic
use builtin qw(true);
if (true) {
say 'true';
exit 3;
}