blib/lib/Markdown/Parser/FootnoteReference.pm untested

filter: Statementstmt 0.0% 0 / 39 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 14 Podpod 0.0% 0 / 8 totaltotal 0.0% 0 / 61 CC 1 SCAR 6.9
CC
1
Cov
0%
BEGIN
2.0
init
2.0
as_markdown
2.0
CRAP 2.0
1 ## -*- perl -*-
2 ##----------------------------------------------------------------------------
3 ## Markdown Parser Only - ~/lib/Markdown/Parser/FootnoteReference.pm
4 ## Version v0.3.0
5 ## Copyright(c) 2022 DEGUEST Pte. Ltd.
6 ## Author: Jacques Deguest <jack@deguest.jp>
7 ## Created 2021/08/23
8 ## Modified 2024/08/30
9 ## All rights reserved
10 ##
11 ## This program is free software; you can redistribute it and/or modify it
12 ## under the same terms as Perl itself.
13 ##----------------------------------------------------------------------------
14 package Markdown::Parser::FootnoteReference;
15 BEGIN
16 {
17 use strict;
18 use warnings;
19 use parent qw( Markdown::Parser::Element );
20 use vars qw( $VERSION );
21 our $VERSION = 'v0.3.0';
22 };
23  
24 use strict;
25 use warnings;
26  
27 sub init
28 {
29 my $self = shift( @_ );
30 $self->{footnote} = '';
31 $self->{id} = '';
32 $self->{sequence} = '';
33 $self->{tag_name} = 'footnote_ref';
34 return( $self->SUPER::init( @_ ) );
35 }
36  
37 sub as_markdown
38 {
39 my $self = shift( @_ );
40 return( sprintf( '*[%s]: %s', $self->name, $self->value ) );
41 }
42  
43 sub as_pod
44 {
45 my $self = shift( @_ );
46 return( sprintf( '[C<%s>]: %s', $self->name, $self->value ) );
47 }
48  
49 # <li id="fn:1" role="doc-endnote">
50 # <p>This is the first footnote.&nbsp;<a href="#fnref:1" class="reversefootnote" role="doc-backlink">↩</a></p>
51 # </li>
52 sub as_string
53 {
54 my $self = shift( @_ );
55 my $val = $self->sequence->scalar;
56 $self->encode_html( [qw( < > & " ' )], \$val );
57 # e.g. <abbr title="Hyper Text Markup Language">HTML</abbr>
58 return( sprintf( '<sup id="fnref:%s"><a href="#fn:%s">%s</a></sup>', $self->id, $self->footnote->id, $val ) );
59 }
60  
61 ## The footnote object
62 sub footnote { return( shift->_set_get_object( 'footnote', 'Markdown::Parser::Footnote', @_ ) ); }
63  
64 ## The footnote reference own id for backlink, ie link from the footnote back to the point of reference
65 sub id { return( shift->_set_get_scalar_as_object( 'name', @_ ) ); }
66  
67 sub sequence { return( shift->_set_get_scalar_as_object( 'sequence', @_ ) ); }
68  
69 1;
70 # NOTE: POD
71 __END__