Altai-man / docs.raku.org

Source code of a beta version of the updated docs.raku.org website
Artistic License 2.0
11 stars 6 forks source link

Strip off Pod formatting codes from code on render #48

Closed Altai-man closed 2 years ago

Altai-man commented 2 years ago

As there is no neat way to preserve both Pod highlighting codes such as B<> and code coloring, for long time examples, where for some reason the codes were used, were not colored.

As it's easier to understand what's what with Raku syntax in examples such as:

my $excerpt = q:to/END/;
Here's some unimportant text.
=begin code
    This code block is what we're after.
    We'll use 'ff' to get it.
=end code
More unimportant text.
END

my @codelines = gather for $excerpt.lines {
    take $_ if "=begin code" ff "=end code"
}
say @codelines.join("\n");

we address the same issue by prefering coloring over codes like bold or italics. In code it means unwrapping the Pod::FormattingCode nodes into text we can then highlight.