Coder Social home page Coder Social logo

Comments (5)

AlDanial avatar AlDanial commented on July 17, 2024

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.

  1. 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
  2. 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.

rschaeferhig avatar rschaeferhig commented on July 17, 2024

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.

  1. 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
  2. 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.

AlDanial avatar AlDanial commented on July 17, 2024

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.

rschaeferhig avatar rschaeferhig commented on July 17, 2024

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.

AlDanial avatar AlDanial commented on July 17, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.