~emersion/public-inbox

gamja: Fix stripping hex color formatting v1 APPLIED

delthas: 1
 Fix stripping hex color formatting

 1 files changed, 12 insertions(+), 0 deletions(-)
#854664 .build.yml success
Export patchset (mbox)
How do I use this?

Copy & paste the following snippet into your terminal to import this patchset into git:

curl -s https://lists.sr.ht/~emersion/public-inbox/patches/35768/mbox | git am -3
Learn more about email & git

[PATCH gamja] Fix stripping hex color formatting Export this patch

Hex colors can be set with the same formats as the regular colors:
<CODE>, <CODE><COLOR>, or <CODE><COLOR>,<COLOR>.

Previously we only supporteed <CODE><COLOR>.

This patch enables stripping colors for all valid color formats.
---
 lib/ansi.js | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/lib/ansi.js b/lib/ansi.js
index 108af27..f4e81da 100644
--- a/lib/ansi.js
+++ b/lib/ansi.js
@@ -14,6 +14,12 @@ function isDigit(ch) {
	return ch >= "0" && ch <= "9";
}

function isHexColor(text) {
	return text.length >= 6 && text.split('', 7).slice(0, 6).every(v =>
		(v >= "0" && v <= "9") || (v >= "a" && v <= "f") || (v >= "A" && v <= "F")
	);
}

export function strip(text) {
	let out = "";
	for (let i = 0; i < text.length; i++) {
@@ -43,7 +49,13 @@ export function strip(text) {
			}
			break;
		case COLOR_HEX:
			if (!isHexColor(text.slice(i + 1))) {
				break;
			}
			i += 6;
			if (text.length > i + 1 && text.length[i + 1] == "," && isHexColor(text.slice(i + 2))) {
				i += 7;
			}
			break;
		default:
			out += ch;

base-commit: bbc94c88c02515036b7276aae8ffbd141ea8a713
-- 
2.36.1
gamja/patches/.build.yml: SUCCESS in 39s

[Fix stripping hex color formatting][0] from [delthas][1]

[0]: https://lists.sr.ht/~emersion/public-inbox/patches/35768
[1]: mailto:delthas@dille.cc

✓ #854664 SUCCESS gamja/patches/.build.yml https://builds.sr.ht/~emersion/job/854664