| line | stmt | bran | cond | sub | pod | time | code | 
| 1 |  |  |  |  |  |  | package Pod::Simple::Role::XHTML::WithHighlightConfig; | 
| 2 | 1 |  |  | 1 |  | 6453 | use Moo::Role; | 
|  | 1 |  |  |  |  | 2 |  | 
|  | 1 |  |  |  |  | 5 |  | 
| 3 |  |  |  |  |  |  |  | 
| 4 |  |  |  |  |  |  | our $VERSION = '0.000002'; | 
| 5 |  |  |  |  |  |  | $VERSION =~ tr/_//d; | 
| 6 |  |  |  |  |  |  |  | 
| 7 | 1 |  |  | 1 |  | 299 | use Pod::Simple::XHTML (); | 
|  | 1 |  |  |  |  | 3 |  | 
|  | 1 |  |  |  |  | 51 |  | 
| 8 |  |  |  |  |  |  | BEGIN { | 
| 9 | 1 | 50 |  | 1 |  | 238 | *_ENCODE_AS_METHOD = $Pod::Simple::VERSION >= 3.16 ? sub(){1} : sub(){0}; | 
| 10 |  |  |  |  |  |  | } | 
| 11 |  |  |  |  |  |  |  | 
| 12 |  |  |  |  |  |  | with 'Pod::Simple::Role::WithHighlightConfig'; | 
| 13 |  |  |  |  |  |  |  | 
| 14 |  |  |  |  |  |  | sub _encode_html_entities { | 
| 15 | 2 |  |  | 2 |  | 4 | my ($self, $text) = @_; | 
| 16 | 2 |  |  |  |  | 4 | if (_ENCODE_AS_METHOD) { | 
| 17 | 2 |  |  |  |  | 5 | $self->encode_entities($text); | 
| 18 |  |  |  |  |  |  | } | 
| 19 |  |  |  |  |  |  | else { | 
| 20 |  |  |  |  |  |  | Pod::Simple::XHTML::encode_entities($text); | 
| 21 |  |  |  |  |  |  | } | 
| 22 |  |  |  |  |  |  | } | 
| 23 |  |  |  |  |  |  |  | 
| 24 |  |  |  |  |  |  | around start_highlight => sub { | 
| 25 |  |  |  |  |  |  | my ($orig, $self, $item, $config) = @_; | 
| 26 |  |  |  |  |  |  | $self->$orig($item, $config); | 
| 27 |  |  |  |  |  |  | $config ||= {}; | 
| 28 |  |  |  |  |  |  | my $tag = ' 
 | 
| 29 |  |  |  |  |  |  | my @classes; | 
| 30 |  |  |  |  |  |  | if ($config->{line_numbers}) { | 
| 31 |  |  |  |  |  |  | push @classes, 'line-numbers'; | 
| 32 |  |  |  |  |  |  | if ($config->{start_line}) { | 
| 33 |  |  |  |  |  |  | $tag .= ' data-start="' . $self->_encode_html_entities($config->{start_line}) . '"'; | 
| 34 |  |  |  |  |  |  | } | 
| 35 |  |  |  |  |  |  | } | 
| 36 |  |  |  |  |  |  | if ($config->{highlight}) { | 
| 37 |  |  |  |  |  |  | $tag .= ' data-line="' . $self->_encode_html_entities($config->{highlight}) . '"'; | 
| 38 |  |  |  |  |  |  | } | 
| 39 |  |  |  |  |  |  | if (@classes) { | 
| 40 |  |  |  |  |  |  | $tag .= ' class="' . join (' ', @classes) . '"'; | 
| 41 |  |  |  |  |  |  | } | 
| 42 |  |  |  |  |  |  | $tag .= '> 
 | 
| 43 |  |  |  |  |  |  | if ($config->{language}) { | 
| 44 |  |  |  |  |  |  | my $lang = lc $config->{language}; | 
| 45 |  |  |  |  |  |  | $lang =~ s/\+/p/g; | 
| 46 |  |  |  |  |  |  | $lang =~ s/\W//g; | 
| 47 |  |  |  |  |  |  | $tag .= ' class="language-' . $lang . '"'; | 
| 48 |  |  |  |  |  |  | } | 
| 49 |  |  |  |  |  |  | $tag .= '>'; | 
| 50 |  |  |  |  |  |  | $self->{scratch} = $tag; | 
| 51 |  |  |  |  |  |  | }; | 
| 52 |  |  |  |  |  |  |  | 
| 53 |  |  |  |  |  |  | 1; | 
| 54 |  |  |  |  |  |  | __END__ |