← every case · 6000 · another language inside the file

6120-script_inside_html_inside_php

three languages deep, the everyday shape of a page: the php file holds html between its blocks, and the html holds a script. Every line belongs to the innermost language, and a tag's own line to the language that encloses the tag, so the script tags are html and the html sits between the php blocks

read ascloc.defaultmezura.contentmezura.regionscc.defaulttokei.default
input.php
1code<?php
2code?>
3code HTML<div>
4code HTML<script>
5comments JavaScript// a js comment
6code JavaScriptvar x = 1;
7code HTML</script>
8code HTML</div>
9code<?php
10codeecho "hi";
11code?>

stringcommentthe tag around another language

What each tool answered

cloc.default ✗ fails

the file is read as php from beginning to end, so the js comment two languages deep survives only because php spells its line comment the same way, and neither language inside is named

the rules ask11 lines · 0 blanks · 10 code · 1 comments · HTML 4 · JavaScript 2
it answers11 lines · 0 blanks · 10 code · 1 comments

cloc --json cases/6000-another_language_inside_the_file/6120-script_inside_html_inside_php/input.php

mezura.content ✗ fails

the file is read as php from beginning to end, so neither block is found; the totals survive because php happens to bucket every line the same way the three languages do

the rules ask11 lines · 8 code · 1 comments · 2 extra · HTML 4 · JavaScript 2
it answers11 lines · 8 code · 1 comments · 2 extra

mezura cases/6000-another_language_inside_the_file/6120-script_inside_html_inside_php/input.php --output json --hide timing --counting content

mezura.region ✗ fails

the file is read as php from beginning to end, so neither block is found

the rules ask11 lines · 0 blanks · 10 code · 1 comments · HTML 4 · JavaScript 2
it answers11 lines · 0 blanks · 10 code · 1 comments

mezura cases/6000-another_language_inside_the_file/6120-script_inside_html_inside_php/input.php --output json --hide timing --counting region

scc.default ✗ fails

it has no notion of a file holding a second language, and the js comment survives only because php spells its line comment the same way

the rules ask11 lines · 0 blanks · 10 code · 1 comments · HTML 4 · JavaScript 2
it answers11 lines · 0 blanks · 10 code · 1 comments

scc --format json cases/6000-another_language_inside_the_file/6120-script_inside_html_inside_php/input.php

tokei.default ✗ fails

a php file never yields children, so the page that nests two levels deep in a markdown fence is counted flat here, everything php

the rules ask11 lines · 0 blanks · 10 code · 1 comments · HTML 4 · JavaScript 2
it answers11 lines · 0 blanks · 10 code · 1 comments

tokei --output json cases/6000-another_language_inside_the_file/6120-script_inside_html_inside_php/input.php