Giter VIP home page Giter VIP logo

regex-colorizer's People

Contributors

slevithan avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

regex-colorizer's Issues

Highlight regex comments

It would be nice to be able to highlight regex comments explicitly with this, since I'm using this lib to highlight a regex that I split into parts, and indent and comment to explain. Something like the # character perhaps.

Thanks for the awesome library! I might even just do it myself and send a PR, we'll see :)

Provide minified version

I'd prefer not to minify this library myself, especially since minifiers can introduce their own issues.

Could you provide a minified version of your code in the code base?

Mark invalid values for \p{...} with flag u as errors

When using flag u, Regex Colorizer (as of v1.0.0) uses a simplistic regex to identify Unicode properties with \p{...} and \P{...}. It would be better to flag any values that are not actually supported by ECMAScript.

@mathiasbynens has a bunch of great, related libraries. See:

Not yet sure which of these are the most relevant.

Ideas for future redesign

  • Update supported syntax to include features and escaping rules from JavaScript flag v (ES2024).
  • Rewrite on top of an AST (ex: regexp-tree, regexpp).
  • Consider becoming a CodeMirror mode, similar to CodeMirror PCRE mode.
    • Potentially extract RegExr's highlighting/tooltips as a starting point.
  • Add more options to the options argument used by colorizeAll and colorizePattern:
    • flavor - Ex: 'JavaScript', 'EMCAScript' (alternative name: 'JavaScript-WithoutWebReality'), 'PCRE', 'XRegExp'.
      • Default: 'JavaScript'.
      • Use the latest known version for the flavor if version is not provided.
    • version - Regex flavor version. Ex: JavaScript/ECMAScript: '3', '5', '2024'; PCRE: '8.45', '10.39'.
      • Default: 'latest'.
      • Throw if unexpected value or if flavor is not provided.
      • Potential implementation: By using e.g. 'JavaScript'+'2024', it sets of bunch of feature flags, and parsing code can check for the feature flags rather than flavor/version. New flavor versions can then just augment existing objects of feature flags.
    • format - Options: '...' (default), '/.../flags', and maybe others.
      • '/.../flags' allows:
        1. Applying flags (can change syntax rules).
        2. Highlighting invalid flags/combinations and duplicates.
        3. Changing syntax rules, independent of flags: Only need to escape / in regex literals. Note: ES5 included a change to allow unescaped [/] in regex literals.
      • Throw if both format and flags are provided.
    • warningsOn - On by default? Ex: || at top level, range overflow, quantified lookaround, incomplete tokens \c,\x,\u.
    • compatibilityOn - For differences in behavior for the same syntax across regex flavors (not for when some flavors don't support a feature). Ex: Empty char classes [], [^] (JS), leading unescaped ] in char classes (non-JS).
    • suggestionsOn - Ex: Use of octals, escaped literals, [0-9] โ†’ \d (for flavors where \d is ASCII only), [\S\s] โ†’ dot with /s (if /s is active or no existing dots).
  • Render whitespace characters.
  • Add replacement text highlighting (also accepts options argument, with flavor, version, format).

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.