Git Product home page Git Product logo

explainsyntax's People

Stargazers

 avatar

Watchers

 avatar  avatar  avatar

explainsyntax's Issues

Highlighting logic

We maintain a set of "interesting" node types in the AST, e.g. "VariableDeclaration" and "VariableDeclarator" for JavaScript. For each such node type, we also store additional information such as an MDN URL. When the CodeEditor component encounters such node types in the user code, it adds highlighting to them, i.e. an underline connected to a line going towards the right edge of the editor (to be connected with the information blob in the ExplainPane component). Highlight underlines should not overlap, e.g. in the case of a "VariableDeclarator" (x = 0) inside a "VariableDeclaration" (let x = 0), x = 0 would get an underline for "VariableDeclarator and let would get an underline for "VariableDeclaration". Whenever the highlighting changes, the CodeEditor fires an event that tells the parent componet (the App) what the highlights are, i.e. what node types they correspond to and at what vertical position their lines end; that information can be propagated by the parent component to the ExplainPane component.

To experiment with ASTs & node types: https://astexplorer.net/

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.