Extract different types of text in a localized string
npm i narwhal-js
import { parseString } from 'narwhal-js';
parseString('[button]<<Click>> me to [bold]<<Sign in>>');
/**
[
{
type: 'button',
value: 'Click',
},
{
type: '',
value: ' me to ',
},
{
type: 'bold',
value: 'Sign in',
},
]
*/
parseString('[button]<<点>>我[bold]<<登录>>');
/**
[
{
type: 'button',
value: '点',
},
{
type: '',
value: '我',
},
{
type: 'bold',
value: '登录',
},
]
*/