line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# vim:ts=4:shiftwidth=4:expandtab |
2
|
1
|
|
|
1
|
|
571
|
use 5.026; |
|
1
|
|
|
|
|
9
|
|
3
|
1
|
|
|
1
|
|
5
|
use strict; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
19
|
|
4
|
1
|
|
|
1
|
|
4
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
86
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
package Text::Mrkdwn::Escape; |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
our $VERSION = '0.01'; # VERSION |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
our (@ISA, @EXPORT_OK); |
11
|
1
|
|
|
1
|
|
528
|
use parent qw/ Exporter /; |
|
1
|
|
|
|
|
378
|
|
|
1
|
|
|
|
|
5
|
|
12
|
|
|
|
|
|
|
BEGIN { |
13
|
1
|
|
|
1
|
|
147
|
@EXPORT_OK = qw/ escape_to_mrkdwn /; |
14
|
|
|
|
|
|
|
} |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
=head1 NAME |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
Text::Mrkdwn::Escape - Escape text for inclusion in mrkdwn |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
=head1 SYNOPSIS |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
my $str = Text::Mrkdwn::Escape::escape_to_mrkdwn("*Hello*!"); |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
=head1 DESCRIPTION |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
I is a variant of the Markdown text formatting system. It is used by |
27
|
|
|
|
|
|
|
the Slack API. This module is for escaping text, which may contain special |
28
|
|
|
|
|
|
|
characters for inclusion in mrkdwn text. |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
=head1 FUNCTIONS |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
=head2 escape |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
my $escaped_string = escape_to_mrkdwn($string); |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
Escapes characters which may cause formatting with a backslash. |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
=cut |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
sub escape_to_mrkdwn { |
41
|
5
|
|
|
5
|
0
|
98
|
my ($str) = @_; |
42
|
|
|
|
|
|
|
|
43
|
5
|
|
|
|
|
42
|
$str =~ s/([\x21-\x45 \x2f \x3a-\x40 \x5b-\x60 \x7b-\x7e])/\\$1/gxx; |
44
|
|
|
|
|
|
|
|
45
|
5
|
|
|
|
|
27
|
return $str; |
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
1; |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
=head1 SEE ALSO |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
=over |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
=item * |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
L |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
=item * |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
L |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
=back |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
=head1 AUTHOR |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
Dave Lambley |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
=head1 LICENSE |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
This library is free software; you can redistribute it and/or modify |
71
|
|
|
|
|
|
|
it under the same terms as Perl itself. |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
=cut |