← every case · 2000 · string forms

2064-template_inside_a_template_hole

a template literal opens inside the hole of another one and runs on to the next line. Templates and holes nest, so the second backtick on the first line opens the inner template and ends nothing. A counter that pairs the backticks in order ends the outer template there, and the line inside the inner template comes out as a comment

read ascloc.defaultcloc.docstring-as-codecodestats.defaultmezura.contentmezura.regionscc.defaulttokei.default
input.js
1codeconst s = `a ${ `b
2code// still inside the inner template
3codec` } d`;
4comments// a real comment
5codelet y = 1;

stringcommentthe tag around another language

What each tool answered

cloc.default ✗ fails

a // at the head of a line opens a comment inside a backtick template as readily as outside one, so the line inside the inner template counts as a comment. One template over the same three lines, with no hole, is counted the same way

the rules ask5 lines · 0 blanks · 4 code · 1 comments
it answers5 lines · 0 blanks · 3 code · 2 comments

cloc --json --config /tmp/linejudge-empty-file cases/2000-string_forms/2064-template_inside_a_template_hole/input.js

cloc.default ✗ fails

--strip-str-comments

a // at the head of a line opens a comment inside a backtick template as readily as outside one, so the line inside the inner template counts as a comment. One template over the same three lines, with no hole, is counted the same way

the rules ask5 lines · 0 blanks · 4 code · 1 comments
it answers5 lines · 0 blanks · 3 code · 2 comments

cloc --json --config /tmp/linejudge-empty-file cases/2000-string_forms/2064-template_inside_a_template_hole/input.js --strip-str-comments

cloc.docstring-as-code ✗ fails

a // at the head of a line opens a comment inside a backtick template as readily as outside one, so the line inside the inner template counts as a comment. One template over the same three lines, with no hole, is counted the same way

the rules ask5 lines · 0 blanks · 4 code · 1 comments
it answers5 lines · 0 blanks · 3 code · 2 comments

cloc --json --config /tmp/linejudge-empty-file cases/2000-string_forms/2064-template_inside_a_template_hole/input.js --docstring-as-code

codestats.default ✓ agrees
the rules ask5 lines · 0 blanks · 4 code · 1 comments
it answers5 lines · 0 blanks · 4 code · 1 comments

codestats cases/2000-string_forms/2064-template_inside_a_template_hole/input.js --output json-compact --include-generated --no-gitignore --hidden --no-config

mezura.content ✓ agrees
the rules ask5 lines · 4 code · 1 comments · 0 extra
it answers5 lines · 4 code · 1 comments · 0 extra

mezura cases/2000-string_forms/2064-template_inside_a_template_hole/input.js --output json --hide timing --no-default-config --no-local --counting content

mezura.region ✓ agrees
the rules ask5 lines · 0 blanks · 4 code · 1 comments
it answers5 lines · 0 blanks · 4 code · 1 comments

mezura cases/2000-string_forms/2064-template_inside_a_template_hole/input.js --output json --hide timing --no-default-config --no-local --counting region

scc.default ✗ fails

the backticks pair off in order, hole or no hole, so the second one ends the outer template and the line inside the inner template counts as a comment. The file is counted the same with the ${ taken out

the rules ask5 lines · 0 blanks · 4 code · 1 comments
it answers5 lines · 0 blanks · 3 code · 2 comments

scc --format json --no-config cases/2000-string_forms/2064-template_inside_a_template_hole/input.js

tokei.default ✗ fails

the backticks pair off in order, hole or no hole, so the second one ends the outer template and the line inside the inner template counts as a comment. The file is counted the same with the ${ taken out

the rules ask5 lines · 0 blanks · 4 code · 1 comments
it answers5 lines · 0 blanks · 3 code · 2 comments

tokei --output json cases/2000-string_forms/2064-template_inside_a_template_hole/input.js