-
Notifications
You must be signed in to change notification settings - Fork 313
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
支持叠字符号「々」的注音 #201
Comments
“自己动手,丰衣足食。” var resolveIterationMark = function(string) {
var current = string.charAt(0);
var result = current;
for (var i = 1; i < string.length; ++i) {
if (string.charAt(i) !== '々') {
current = string.charAt(i);
}
result += current;
}
return result;
}; |
const resolveIterationMark = (str) => typeof str === 'string'
? str.split('々').reduce((s,c, i, a)=> a.length===1?s:`${s}${s.slice(-1)}${c}`)
: str; import { html } from 'pinyin-pro';
const resolveIterationMark = (str:string) => typeof str === 'string' && !/^々{1,}$/ig.test(str)
? str.split('々').reduce((s,c, _, a)=> a.length===1?s:`${s}${s.slice(-1)}${c}`)
: str;
const htmlString = [
html(resolveIterationMark('天々向上')),
html(resolveIterationMark('天々向上,好々学习')),
html(resolveIterationMark('々')),
html(resolveIterationMark('々々')),
html(resolveIterationMark('')),
html(resolveIterationMark('々天々')),//开头的“々”会被抛弃
html(resolveIterationMark('施氏食狮史')),
html(resolveIterationMark('牛逼々々')),
].map(html => html?`<div>${html}</div>`:'<div><空行></div>').join('');
document.body.innerHTML = htmlString; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
功能描述
这是一个特殊功能,建议增加一个选项,默认关闭。
々的读音就是读被反复的字的读音,例如,天々(tiān)向上,这里读前面一个字的音。
The text was updated successfully, but these errors were encountered: