Comments (5)
cloc isn't smart enough to see there is Javascript inside the HTML. Basically it works as one file = one language. I can think of a couple of work-arounds, but they will just count the Javascript block as comments, not as actual Javascript code.
- You could create a custom language definition file (ref --write-lang-def/--read-lang-def, https://github.com/AlDanial/cloc#custom_lang) that recognizes /* and */ as comments for HTML
- You could surround your Javascript code with HTML comment markers , ie But that would mean modifying all your HTML files which would be a total drag.
from cloc.
Given the prevalence of models such as MVC where HTML pages contain large amounts of Javascript I would think that it might be beneficial for the strategic direction of cloc to be able to count Javascript lines inside HTML. I’m not a developer so writing that level of code is beyond me, but as a DevOps Engineer the functionality is important. Any chance to put it on the backlog of potential enhancements that another contributor might pick up? I can’t be the only person wondering about this…
Thanks for the quick response.
From: AlDanial [mailto:[email protected]]
Sent: Monday, October 05, 2015 11:43 PM
To: AlDanial/cloc
Cc: Schaefer, Richard W (CTO Technology)
Subject: Re: [cloc] Appear to be getting invalid counts for .htm file (#7)
cloc isn't smart enough to see there is Javascript inside the HTML. Basically it works as one file = one language. I can think of a couple of work-arounds, but they will just count the Javascript block as comments, not as actual Javascript code.
- You could create a custom language definition file (ref --write-lang-def/--read-lang-def, https://github.com/AlDanial/cloc#custom_lang) that recognizes /* and */ as comments for HTML
- You could surround your Javascript code with HTML comment markers , ie But that would mean modifying all your HTML files which would be a total drag.
—
Reply to this email directly or view it on GitHubhttps://github.com//issues/7#issuecomment-145734366.
This communication, including attachments, is for the exclusive use of addressee and may contain proprietary, confidential and/or privileged information. If you are not the intended recipient, any use, copying, disclosure, dissemination or distribution is strictly prohibited. If you are not the intended recipient, please notify the sender immediately by return e-mail, delete this communication and destroy all copies.
from cloc.
I'm certainly not opposed to counting code embedded within HTML, it's just that I don't know how to do it properly. I'm happy to accept pull requests from smarter people who can implement this.
from cloc.
Do you have a backlog of enhancements that people can look at? If not you might want to consider publishing a list of potential enhancements that contributors could look at and tackle if they so desire.
Anyway, thanks for the explanation. It’s a great tool.
From: AlDanial [mailto:[email protected]]
Sent: Tuesday, October 06, 2015 10:04 PM
To: AlDanial/cloc
Cc: Schaefer, Richard W (CTO Technology)
Subject: Re: [cloc] Appear to be getting invalid counts for .htm file (#7)
I'm certainly not opposed to counting code embedded within HTML, it's just that I don't know how to do it properly. I'm happy to accept pull requests from smarter people who can implement this.
—
Reply to this email directly or view it on GitHubhttps://github.com//issues/7#issuecomment-146057375.
This communication, including attachments, is for the exclusive use of addressee and may contain proprietary, confidential and/or privileged information. If you are not the intended recipient, any use, copying, disclosure, dissemination or distribution is strictly prohibited. If you are not the intended recipient, please notify the sender immediately by return e-mail, delete this communication and destroy all copies.
from cloc.
Good idea. I added a new section to the README,
https://github.com/AlDanial/cloc/blob/master/README.md#in_progress, that
shows what I'm working on (or at least thinking of working on).
from cloc.
Related Issues (20)
- Trying to ignore the C# generated files using --no-autogen but its not working HOT 3
- Wrong comment results for Java HOT 1
- Add support of Java text blocks HOT 7
- Wrong code results for Java HOT 1
- Wrong line calculations with strings in C HOT 1
- Cloc doesn't count XML file HOT 1
- Cloc doesn't support <![CDATA[ .... ]]]]><![CDATA[> ...]]> in XML HOT 2
- Cloc counts line where comment starts as comment in XML HOT 1
- Nickel config lang support
- exe version of cloc not support file name with chinese character HOT 4
- Language support for Luau .luau HOT 1
- List winget in README package maganers HOT 1
- Cloc has problems with */* in Go HOT 3
- Cloc doesn't count correctly Visual Basic code HOT 1
- Add Modelica language HOT 3
- support Processing Language
- Documentation for --force-lang is slightly wrong HOT 3
- --fullpath does not work with --vcs=git HOT 4
- Possible inconsistent counting of "same" lines HOT 5
- Add option to exclude shebang from the count HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from cloc.