Skip to content

Commit 6dbe164

Browse files
committed
Auto-generated commit
1 parent 8e494aa commit 6dbe164

5 files changed

Lines changed: 99 additions & 3 deletions

File tree

CHANGELOG.md

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
55
<section class="release" id="unreleased">
66

7-
## Unreleased (2025-04-09)
7+
## Unreleased (2025-04-19)
88

99
<section class="packages">
1010

@@ -78,6 +78,28 @@
7878

7979
<!-- /.package -->
8080

81+
<section class="package" id="string-base-format-tokenize-unreleased">
82+
83+
#### [@stdlib/string/base/format-tokenize](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/string/base/format-tokenize)
84+
85+
<details>
86+
87+
<section class="bug-fixes">
88+
89+
##### Bug Fixes
90+
91+
- [`5d5742b`](https://github.com/stdlib-js/stdlib/commit/5d5742b1d6b22eb0e9d597242035be42833c004c) - update `format-tokenize` to correctly handle escaped percent signs [(#6695)](https://github.com/stdlib-js/stdlib/pull/6695)
92+
93+
</section>
94+
95+
<!-- /.bug-fixes -->
96+
97+
</details>
98+
99+
</section>
100+
101+
<!-- /.package -->
102+
81103
<section class="package" id="string-base-slice-unreleased">
82104

83105
#### [@stdlib/string/base/slice](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/string/base/slice)
@@ -196,9 +218,10 @@
196218

197219
### Contributors
198220

199-
A total of 4 people contributed to this release. Thank you to the following contributors:
221+
A total of 5 people contributed to this release. Thank you to the following contributors:
200222

201223
- Athan Reines
224+
- Karan Anand
202225
- Muhammad Haris
203226
- Philipp Burckhardt
204227
- Stephannie Jiménez Gacha
@@ -213,6 +236,7 @@ A total of 4 people contributed to this release. Thank you to the following cont
213236

214237
<details>
215238

239+
- [`5d5742b`](https://github.com/stdlib-js/stdlib/commit/5d5742b1d6b22eb0e9d597242035be42833c004c) - **fix:** update `format-tokenize` to correctly handle escaped percent signs [(#6695)](https://github.com/stdlib-js/stdlib/pull/6695) _(by Karan Anand)_
216240
- [`c30bb89`](https://github.com/stdlib-js/stdlib/commit/c30bb89ea18eec5fcff098f16a30cc19315150e4) - **feat:** add `string/base/slice-code-points` [(#5414)](https://github.com/stdlib-js/stdlib/pull/5414) _(by Muhammad Haris)_
217241
- [`4c404c7`](https://github.com/stdlib-js/stdlib/commit/4c404c78dcb1a575ddc8d4b770122affdec5751d) - **fix:** make CLI scripts executable [(#6085)](https://github.com/stdlib-js/stdlib/pull/6085) _(by stdlib-bot)_
218242
- [`5fd8af8`](https://github.com/stdlib-js/stdlib/commit/5fd8af8015ce57db86127c6deec0561273eb6a39) - **feat:** add `string/base/slice-grapheme-clusters` [(#5457)](https://github.com/stdlib-js/stdlib/pull/5457) _(by Muhammad Haris, Athan Reines)_

CONTRIBUTORS

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ Dorrin Sotoudeh <dorrinsotoudeh123@gmail.com>
5151
EuniceSim142 <77243938+EuniceSim142@users.noreply.github.com>
5252
Frank Kovacs <fran70kk@gmail.com>
5353
GK Bishnoi <gkishan1kyt@gmail.com>
54+
GURU PRASAD SHARMA <168292003+GURUPRASADSHARMA@users.noreply.github.com>
5455
Gaurav <gaurav70380@gmail.com>
5556
Gautam sharma <gautamkrishnasharma1@gmail.com>
5657
Golden Kumar <103646877+AuenKr@users.noreply.github.com>
@@ -87,6 +88,7 @@ Krishnendu Das <86651039+itskdhere@users.noreply.github.com>
8788
Kshitij-Dale <152467202+Kshitij-Dale@users.noreply.github.com>
8889
Lovelin Dhoni J B <100030865+lovelindhoni@users.noreply.github.com>
8990
MANI <77221000+Eternity0207@users.noreply.github.com>
91+
Mahfuza Humayra Mohona <mhmohona@gmail.com>
9092
Manik Sharma <maniksharma.rke@gmail.com>
9193
Manvith M <148960168+manvith2003@users.noreply.github.com>
9294
Marcus Fantham <mfantham@users.noreply.github.com>
@@ -119,6 +121,7 @@ Prashant Kumar Yadav <144602492+0PrashantYadav0@users.noreply.github.com>
119121
PrathamBhamare <164445568+PrathamBhamare@users.noreply.github.com>
120122
Pratik Singh <97464067+Pratik772846@users.noreply.github.com>
121123
Pratyush Kumar Chouhan <pratyushkumar0308@gmail.com>
124+
Pravesh Kunwar <praveshkunwar04@gmail.com>
122125
Priyansh Prajapati <88396544+itsspriyansh@users.noreply.github.com>
123126
Priyanshu Agarwal <113460573+AgPriyanshu18@users.noreply.github.com>
124127
Pulkit Gupta <65711278+pulkitgupta2@users.noreply.github.com>

base/format-tokenize/examples/index.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,3 +31,7 @@ console.log( out );
3131
out = formatTokenize( 'Multiple flags: %#+s' );
3232
console.log( out );
3333
// => [ 'Multiple flags: ', {...} ]
34+
35+
out = formatTokenize( 'Percent: %d%%' );
36+
console.log( out );
37+
// => [ 'Percent: ', {...}, '%' ]

base/format-tokenize/lib/main.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,12 @@ function formatTokenize( str ) {
7373
if ( content.length ) {
7474
tokens.push( content );
7575
}
76-
tokens.push( parse( match ) );
76+
// Check for an escaped percent sign `%%`...
77+
if ( match[ 6 ] === '%' ) {
78+
tokens.push( '%' );
79+
} else {
80+
tokens.push( parse( match ) );
81+
}
7782
prev = RE.lastIndex;
7883
match = RE.exec( str );
7984
}

base/format-tokenize/test/test.js

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -271,3 +271,63 @@ tape( 'the function tokenizes a string (extracting precision)', function test( t
271271

272272
t.end();
273273
});
274+
275+
tape( 'the function tokenizes a string (extracting escaped percent sign)', function test( t ) {
276+
var expected;
277+
var actual;
278+
var str;
279+
280+
str = 'Progress: 100%% complete';
281+
expected = [
282+
'Progress: 100',
283+
'%',
284+
' complete'
285+
];
286+
actual = formatTokenize( str );
287+
t.deepEqual( actual, expected, 'deep equal' );
288+
289+
str = 'Testing %%%% complete';
290+
expected = [
291+
'Testing ',
292+
'%',
293+
'%',
294+
' complete'
295+
];
296+
actual = formatTokenize( str );
297+
t.deepEqual( actual, expected, 'deep equal' );
298+
299+
str = 'Rate: %d%% success';
300+
expected = [
301+
'Rate: ',
302+
{
303+
'flags': '',
304+
'mapping': void 0,
305+
'width': void 0,
306+
'precision': void 0,
307+
'specifier': 'd'
308+
},
309+
'%',
310+
' success'
311+
];
312+
actual = formatTokenize( str );
313+
t.deepEqual( actual, expected, 'deep equal' );
314+
315+
str = 'Testing %%%d%% complete';
316+
expected = [
317+
'Testing ',
318+
'%',
319+
{
320+
'flags': '',
321+
'mapping': void 0,
322+
'width': void 0,
323+
'precision': void 0,
324+
'specifier': 'd'
325+
},
326+
'%',
327+
' complete'
328+
];
329+
actual = formatTokenize( str );
330+
t.deepEqual( actual, expected, 'deep equal' );
331+
332+
t.end();
333+
});

0 commit comments

Comments
 (0)