Skip to content

Commit 1f6e855

Browse files
committed
Svelte: comments in strings defined by backticks, single quotes #892
1 parent 49a7816 commit 1f6e855

File tree

5 files changed

+38
-0
lines changed

5 files changed

+38
-0
lines changed

Unix/cloc

+2
Original file line numberDiff line numberDiff line change
@@ -11126,6 +11126,8 @@ sub set_constants { # {{{1
1112611126
[ 'call_regexp_common' , 'C++' ],
1112711127
],
1112811128
'Svelte' => [
11129+
[ 'rm_comments_in_strings', "`", '/*', '*/' ],
11130+
[ 'rm_comments_in_strings', "'", '/*', '*/' ],
1112911131
[ 'rm_comments_in_strings', '"', '/*', '*/' ],
1113011132
[ 'rm_comments_in_strings', '"', '//', '' ],
1113111133
[ 'remove_html_comments', ],

Unix/t/00_C.t

+5
Original file line numberDiff line numberDiff line change
@@ -1218,6 +1218,11 @@ my @Tests = (
12181218
'ref' => '../tests/outputs/test_w_cpp_comments.svelte.yaml',
12191219
'args' => '../tests/inputs/test_w_cpp_comments.svelte',
12201220
},
1221+
{
1222+
'name' => 'Svelte (comments in strings)',
1223+
'ref' => '../tests/outputs/comments_in_str.svelte.yaml',
1224+
'args' => '--strip-str-comments ../tests/inputs/comments_in_str.svelte',
1225+
},
12211226
{
12221227
'name' => 'SVG',
12231228
'ref' => '../tests/outputs/SVG_logo.svg.yaml',

cloc

+2
Original file line numberDiff line numberDiff line change
@@ -11118,6 +11118,8 @@ sub set_constants { # {{{1
1111811118
[ 'call_regexp_common' , 'C++' ],
1111911119
],
1112011120
'Svelte' => [
11121+
[ 'rm_comments_in_strings', "`", '/*', '*/' ],
11122+
[ 'rm_comments_in_strings', "'", '/*', '*/' ],
1112111123
[ 'rm_comments_in_strings', '"', '/*', '*/' ],
1112211124
[ 'rm_comments_in_strings', '"', '//', '' ],
1112311125
[ 'remove_html_comments', ],

tests/inputs/comments_in_str.svelte

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<script lang="ts">
2+
const x = "/*";
3+
const y = '/*';
4+
const z = `/*`;
5+
const re = /\/*/;
6+
</script>
7+
8+
<div>Hello</div>
+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
---
2+
# github.com/AlDanial/cloc
3+
header :
4+
cloc_url : github.com/AlDanial/cloc
5+
cloc_version : 2.05
6+
elapsed_seconds : 0.00450420379638672
7+
n_files : 1
8+
n_lines : 8
9+
files_per_second : 222.014821088291
10+
lines_per_second : 1776.11856870633
11+
report_file : ../outputs/comments_in_str.svelte.yaml
12+
'Svelte' :
13+
nFiles: 1
14+
blank: 1
15+
comment: 0
16+
code: 7
17+
SUM:
18+
blank: 1
19+
comment: 0
20+
code: 7
21+
nFiles: 1

0 commit comments

Comments
 (0)