Git Product home page Git Product logo

Comments (3)

oae avatar oae commented on May 31, 2024

This is really hard to detect. I use highlight.js to determine the language but it is not always accurate. Also, I experimented with guesslang models that vscode uses to detect the code. That seems a little bit better but extension bundle size skyrockets(because of TensorFlow dependencies). I am open to ideas about other solutions.

from gnome-shell-pano.

JoseBritto avatar JoseBritto commented on May 31, 2024

Highlightjs seems to have no state for plain text input. Imo, doing some basic analysis before passing it would be a better solution for now.

Im thinking of having different conditions with weights.

Some sample conditions with weights I can think of:
Line starts with // - 1
Line starts with # - 0.75
Has words seperated by only dots - 0.5
Has // somewhere in a line - 0.2
Has more than one line with only { or } - 1
Has a ( following a word without space- 0.25
Has () following a word - 1
Contains some number of predifined keywords like if while for - 1
Has more than one PascalCase snake_case or camelCase words - 1
Has some math symbols - 1
Has multiple < and > with a word in between - 1

This is just a rough idea and having some library handle this in a better way would be the best solution.

Found this while writing: https://softwareengineering.stackexchange.com/a/87622
Those are some better conditions.

from gnome-shell-pano.

oae avatar oae commented on May 31, 2024

I am considering removing code blocks.

from gnome-shell-pano.

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.