Giter Club home page Giter Club logo

Comments (5)

TLINDEN avatar TLINDEN commented on June 30, 2024 1

#53 fixes the issue for me.

from color.

inhere avatar inhere commented on June 30, 2024

hi @TLINDEN

FAILS:
one <bg=lightGreen;fg=black>two</> <three>
foo <bg=lightGreen;fg=black>two</> <four>

On fails, will match: <bg=lightGreen;fg=black>two</> <three>\nfoo <bg=lightGreen;fg=black>two</> ... Maybe is right, because color support match like <info> contents </>

If change regex s to m, will be not match mulit line contents:

foo <bg=lightGreen;fg=black>
two
</>

from color.

TLINDEN avatar TLINDEN commented on June 30, 2024

But then, there's still an issue, since <three> is no valid color tag. However - even if it were, the color module shall throw an error because there's no matching </> closing tag for it. And it's also too greedy, from my understanding as a user, it should be:

  1. match an opening tag, either <$name> or <bg|fg...>
  2. match the smallest possible part til the next part
  3. match the closing tag </>

Or, if we translate the example into HTML:

one <b>two</b> &lt;three&gt;
foo <b>two</b> &lt;four&gt;

You'll get:
one two <three>
foo two <four>

But not:
one two <three>
foo two
<four>

Now, I see that the s flag needs to be there in order to be able to match color tags spanning multiple lines. And since GO doesn't support negative lookahead lookups (which would fix it!), how can both cases be satisfied?

from color.

TLINDEN avatar TLINDEN commented on June 30, 2024

Ok, while I still think that this behavior is somewhat buggy, I resolved my issue by using regexp.ReplaceAllStringFunc() and inside I am using the color.Style.Sprint() function directly. That way I don't have to cope with any disambiguities.

So, from my point of view the case could be closed. Thanks for the fast response!

from color.

inhere avatar inhere commented on June 30, 2024

Thanks you
I didn't think of a good way :)

Maybe ... can direct limit all color tag name. eg: info|red|yellow....

But then, there's still an issue, since <three> is no valid color tag. However - even if it were, the color module shall throw an error because there's no matching </> closing tag for it. And it's also too greedy, from my understanding as a user, it should be:

  1. match an opening tag, either <$name> or <bg|fg...>
  2. match the smallest possible part til the next part
  3. match the closing tag </>

Or, if we translate the example into HTML:

one <b>two</b> &lt;three&gt;
foo <b>two</b> &lt;four&gt;

You'll get: one two foo two

But not: one two foo two

Now, I see that the s flag needs to be there in order to be able to match color tags spanning multiple lines. And since GO doesn't support negative lookahead lookups (which would fix it!), how can both cases be satisfied?

from color.

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.