Code Fence Testing
In Markdown/MultiMarkdown, a single line of code is surrounded by single backticks, and the HTML produced uses the <code>
tag only.
In Markdown/MultiMarkdown, a code block is created by indenting each line at least four spaces. The block is surrounded by <pre><code>
tags.
Markdown-style, indenting each line of the block four spaces:
my @alerts = $forecast->alerts;
if ( @alerts ) {
foreach my $a ( @alerts ) {
# loop through the array of objects and
# use get methods to process data for
# each object $a in the array. Example:
print "alert description = " . $a->alert_description . "\n";
}
}
I added my own code fence command where the block of code does not need to be indented, but the block needs to be surrounded with my fence.
and fence..
commands.
The HTML output starts the block with my own div formatting tag. <div class="fenceClass"><pre><code>
.
Example:
my @alerts = $forecast->alerts;
if ( @alerts ) {
foreach my $a ( @alerts ) {
# loop through the array of objects and
# use get methods to process data for
# each object $a in the array. Example:
print "alert description = " . $a->alert_description . "\n";
}
}
Many flavored Markdown/MultiMarkdown implementations support a code block or code fence or whatever it's called by surrounding the block with three backticks:
In the example below, the three backticks version doesn't work. It's not supported by the Perl Markdown and MultiMarkdown modules. I'll need to add this myself or stick with my own fence commands. When using the three backticks, only the <code>
tag is used to surround the block.
updated 17mar2017 - added some code to my Format.pm to enable the three bacticks to work. i'll need to spend more time to ensure that this works properly all the time.
my @alerts = $forecast->alerts;
if ( @alerts ) {
foreach my $a ( @alerts ) {
# loop through the array of objects and
# use get methods to process data for
# each object $a in the array. Example:
print "alert description = " . $a->alert_description . "\n";
}
}