Compiler/Target/Plogitty.pm untested

filter: Statementstmt 0.0% 0 / 21 Branchbran 0.0% 0 / 8 Conditioncond 0.0% 0 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 0.0% 0 / 8 Podpod 0.0% 0 / 7 totaltotal 0.0% 0 / 49 CC 5 SCAR 19.5
CC
5
Cov
0%
codeblock
12.0
paragraph_image
12.0
table
2.0
CRAP 7.0
1 package Markdown::Compiler::Target::Plogitty;
2 use Moo;
3 extends 'Markdown::Compiler::Target::HTML';
4  
5 sub codeblock {
6 my ( $self, $node, $content ) = @_;
7  
8 return "<div class=\"mermaid\">\n$content\n</div>\n\n"
9 if $node->{language} and $node->{language} eq 'mermaid';
10  
11 return $node->{language}
12 ? "<pre><code class=\"" . $node->{language} . "\">\n$content\n</code></pre>\n\n"
13 : "<pre><code class=\"plaintext\">\n$content\n</code></pre>\n\n";
14 }
15  
16 sub paragraph_image {
17 my ( $self, $node ) = @_;
18  
19 if ( $node->{title} ) {
20 return sprintf( '<img class="img-fluid" src="%s" title="%s" alt="%s">',
21 $node->{href},
22 $node->{title},
23 $node->{text}
24 );
25 } else {
26 return sprintf( '<img class="img-fluid" src="%s" alt="%s">',
27 $node->{href},
28 $node->{text} ? $node->{text} : $node->{href},
29 );
30 }
31 }
32  
33 ##
34 #sub table_cell {
35 # my ( $self, $node, $content ) = @_;
36 #
37 # return sprintf( "<td>%s%s</td>\n", $node->{content}, $content );
38 #
39 #}
40 #
41 #sub table_row {
42 # my ( $self, $node, $content ) = @_;
43 #
44 # return "<tr>\n$content</tr>\n";
45 #}
46  
47 sub table {
48 my ( $self, $node, $content ) = @_;
49  
50 return "<table class='table'>\n$content</table>\n\n";
51 }
52  
53 sub ordered_list {
54 my ( $self, $node, $content ) = @_;
55  
56 return qq|<ol>\n$content\n</ol>\n|;
57  
58 }
59  
60 sub unordered_list {
61 my ( $self, $node, $content ) = @_;
62  
63 return qq|<li>\n$content\n</li>\n|;
64  
65 }
66  
67 sub list_item {
68 my ( $self, $node, $content ) = @_;
69  
70 return qq|<li>$content</li>\n|;
71  
72 }
73  
74 sub list_item_string {
75 my ( $self, $node ) = @_;
76  
77 return $node->{content};
78 }
79  
80 1;