Comments (5)
#53 fixes the issue for me.
from color.
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.
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:
- match an opening tag, either
<$name>
or<bg|fg...>
- match the smallest possible part til the next part
- match the closing tag
</>
Or, if we translate the example into HTML:
one <b>two</b> <three>
foo <b>two</b> <four>
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.
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.
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:
- match an opening tag, either
<$name>
or<bg|fg...>
- match the smallest possible part til the next part
- match the closing tag
</>
Or, if we translate the example into HTML:
one <b>two</b> <three> foo <b>two</b> <four>
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)
- There are some extra color code problems in different shells
- Use terminfo instead of hardcoding a list of terminals HOT 9
- More colors with hex colors HOT 2
- Not support in IDEA inner terminal on Windows 10 HOT 6
- How to use OpBold with RGB colors? HOT 1
- alpine support ? HOT 1
- feature request: provide func(RGBColor) C16() Color HOT 13
- panic when running on windows with multiple go routines HOT 4
- windows Using version v1.3.5 Printing does not display colors properly HOT 4
- colors don't work on windows with git for windows while using vscode HOT 35
- color don't work when using screen HOT 1
- Not all paths return value
- No color after v1.4.0 upgrade HOT 10
- color.Basic2hex returns empty string on background color
- feature: add hsl to and from methods HOT 4
- No color output on Windows 7 HOT 2
- How to use it on the command line HOT 1
- Question: How to escape color tags HOT 3
- `ClearCode` doesn't work as intended on Mac OS
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from color.