Giter VIP home page Giter VIP logo

nano-syntax-highlighting_batch-file's Introduction

Hi there ๐Ÿ‘‹

  • ๐Ÿ”ญ Iโ€™m planning to work on: 1) Change Nano syntax highlight on-the-fly, 2) A project about wiki users.
  • โšก Fun fact: This guy dreams of being a white hat hacker who can hack whatever he sees.
  • ๐Ÿ–‹ Find more snippets I wrote on Gist

nano-syntax-highlighting_batch-file's People

Contributors

davidhcefx avatar

Stargazers

 avatar  avatar

Watchers

 avatar

nano-syntax-highlighting_batch-file's Issues

Incorrect highlighting of variable names (confusing with %)

I discovered a bug that, when there are multiple percentages, the highlighting of variable names would be problematic:

  • %var%3
    • expected: %var% 3 (only %var% be highlighted)
    • actual: %var%3
  • %%i do echo %b%
    • expected: %%i do echo %b%
    • actual: %%i do echo % b%

The reason is that the %<name>% rule in line 21 doesn't care about word-boundaries. Therefore, it would highlight %var%3 despite that %3 had already been highlighted by another rule. It's the same for the second test case.

color brightred "%([[:alpha:]`~@#$*(){}:',.?+=_-]|\[|\])([[:alnum:]`~@#$*(){}:',.?\ +=_-]|\[|\])*%"
color brightred "!([[:alnum:]`~@#$%*(){}:',.?+=_-]|\[|\])([[:alnum:]`~@#$%*(){}:',.?\ +=_-]|\[|\])*!"
# Parameter names for arguments and loop.
color brightred "%(~[[:alpha:]$]*)?[0-9*]\>" "%%(~[[:alpha:]$]*)?[[:alpha:]]\>"

As for the solution, the ideal solution is by using lookahead or lookafter regex syntax to rule out special cases for %<name>% rule. However, Posix Extended Regex doesn't support this feature. So, I have set a limit that no spaces can be within variable names to avoid this problem.

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.