GithubHelp home page GithubHelp logo

Comments (4)

alecthomas avatar alecthomas commented on June 16, 2024

Sorry, I have no idea what this issue is asking for?

from chroma.

alecthomas avatar alecthomas commented on June 16, 2024

Are you suggesting using it for file extension detection, or something else?

I think the issue is that the mapping from Linguist file types to Chroma file types won't be 1:1

from chroma.

silverwind avatar silverwind commented on June 16, 2024

Take for example the json lexer, Chroma only knows 2 filename for it:

<filename>*.json</filename>
<filename>*.avsc</filename>

Linguist knows 17 extensions and 15 filenames:

https://github.com/github-linguist/linguist/blob/559a6426942abcae16b6d6b328147476432bf6cb/lib/linguist/languages.yml#L3159-L3193

This rich data from the linguist file could for example be extracted from the linguist file and written into chroma lexer's .xml and .go files so chroma ends up with much better filename-based language detection in lexers.Match. But overall I think it might be better to just reduce and embed the linguist file in a build script that runs before each release.

Yes, it won't be a 1:1 mapping but the data extraction could be made best-effort where we map linguist name to chroma lexer name.

from chroma.

silverwind avatar silverwind commented on June 16, 2024

Not sure how you would feel about an additional dependency, but there is also https://github.com/go-enry/go-enry which offers various ways to detect a language based on filename or content (think bash scripts with no file extension). As far as I know, it is based on a somewhat-regularily updated dataset sourced from linguist. All that's left to do for chroma would be to map the detected language to a lexer.

from chroma.

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.