line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
###################################################################################################
|
2
|
|
|
|
|
|
|
# Copyright 2013/2014 by Marcel Greter
|
3
|
|
|
|
|
|
|
# This file is part of OCBNET-CSS3 (GPL3)
|
4
|
|
|
|
|
|
|
####################################################################################################
|
5
|
|
|
|
|
|
|
package OCBNET::CSS3::Regex::Comments;
|
6
|
|
|
|
|
|
|
####################################################################################################
|
7
|
|
|
|
|
|
|
our $VERSION = '0.2.5';
|
8
|
|
|
|
|
|
|
####################################################################################################
|
9
|
|
|
|
|
|
|
|
10
|
12
|
|
|
12
|
|
23782
|
use strict;
|
|
12
|
|
|
|
|
23
|
|
|
12
|
|
|
|
|
402
|
|
11
|
12
|
|
|
12
|
|
143
|
use warnings;
|
|
12
|
|
|
|
|
23
|
|
|
12
|
|
|
|
|
371
|
|
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
####################################################################################################
|
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
# load exporter and inherit from it
|
16
|
12
|
|
|
12
|
|
57
|
BEGIN { use Exporter qw(); our @ISA = qw(Exporter); }
|
|
12
|
|
|
12
|
|
20
|
|
|
12
|
|
|
|
|
367
|
|
|
12
|
|
|
|
|
536
|
|
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
# define our functions that will be exported
|
19
|
12
|
|
|
12
|
|
357
|
BEGIN { our @EXPORT = qw($re_comment uncomment comments); }
|
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
# define our functions that can be exported
|
22
|
12
|
|
|
12
|
|
4290
|
BEGIN { our @EXPORT_OK = qw($re_sass_comment); }
|
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
####################################################################################################
|
25
|
|
|
|
|
|
|
# base regular expressions
|
26
|
|
|
|
|
|
|
####################################################################################################
|
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
# regex found on the w3.org's css grammar page
|
29
|
|
|
|
|
|
|
# ***************************************************************************************
|
30
|
|
|
|
|
|
|
our $re_comment = qr/\/\*[^*]*\*+([^\/*][^*]*\*+)*\//;
|
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
# regex for in-line comments (similar to js - sass specific)
|
33
|
|
|
|
|
|
|
# ***************************************************************************************
|
34
|
|
|
|
|
|
|
our $re_sass_comment = qr/(?:\/\/.*(?:\n|\r|\z)|$re_comment)/;
|
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
####################################################################################################
|
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
# uncomment a text
|
39
|
|
|
|
|
|
|
sub uncomment ($)
|
40
|
|
|
|
|
|
|
{
|
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
# get the text from args
|
43
|
366
|
|
|
366
|
0
|
714
|
my ($text) = join("", @_);
|
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
# remove all comments from text
|
46
|
366
|
|
|
|
|
1240
|
$text =~ s/$re_comment//gm;
|
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
# return result
|
49
|
366
|
|
|
|
|
966
|
return $text;
|
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
}
|
52
|
|
|
|
|
|
|
# EO sub uncomment
|
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
####################################################################################################
|
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
# get comments
|
57
|
|
|
|
|
|
|
sub comments ($)
|
58
|
|
|
|
|
|
|
{
|
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
# collect comments
|
61
|
2
|
|
|
2
|
0
|
13
|
my (@comments);
|
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
# get the text from args
|
64
|
2
|
|
|
|
|
10
|
my ($text) = join("", @_);
|
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
# collect all comments inside the given text node
|
67
|
2
|
|
|
|
|
121
|
push @comments, $1 while $text =~ m/($re_comment)/gs;
|
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
# remove comment opener and closer from strings
|
70
|
2
|
|
|
|
|
53
|
s/(?:\A\s*\/+\*+\s*|\s*\*+\/+\s*\z)//g foreach @comments;
|
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
# return result
|
73
|
2
|
|
|
|
|
11
|
return @comments;
|
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
}
|
76
|
|
|
|
|
|
|
# EO sub uncomment
|
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
####################################################################################################
|
79
|
|
|
|
|
|
|
####################################################################################################
|
80
|
|
|
|
|
|
|
1;
|