File tree Expand file tree Collapse file tree 4 files changed +10
-3
lines changed Expand file tree Collapse file tree 4 files changed +10
-3
lines changed Original file line number Diff line number Diff line change @@ -85,8 +85,9 @@ export interface BasicOptions {
85
85
* @description 对于 ü 的返回是否转换成 v(仅在 toneType: none 启用时生效)
86
86
* @value false:返回值中保留 ü (默认值)
87
87
* @value true:返回值中 ü 转换成 v
88
+ * @value string:返回值中 ü 转换成指定字符
88
89
*/
89
- v ?: boolean ;
90
+ v ?: boolean | string ;
90
91
/**
91
92
* @description 是否开启「一」和 「不」字的变调。默认开启。参考:https://zh.wiktionary.org/wiki/Appendix:%E2%80%9C%E4%B8%80%E2%80%9D%E5%8F%8A%E2%80%9C%E4%B8%8D%E2%80%9D%E7%9A%84%E5%8F%98%E8%B0%83
92
93
* @value true:开启
Original file line number Diff line number Diff line change @@ -157,7 +157,7 @@ export const middlewareV = (
157
157
if ( options . v ) {
158
158
list . forEach ( ( item ) => {
159
159
if ( item . isZh ) {
160
- item . result = item . result . replace ( / ü / g, "v" ) ;
160
+ item . result = item . result . replace ( / ü / g, typeof options . v === 'string' ? options . v : "v" ) ;
161
161
}
162
162
} ) ;
163
163
}
Original file line number Diff line number Diff line change @@ -26,4 +26,9 @@ describe('v', () => {
26
26
const result4 = pinyin ( '吕布ü' , { toneType : 'none' , v : true } ) ;
27
27
expect ( result4 ) . to . be . equal ( 'lv bu ü' ) ;
28
28
} ) ;
29
+
30
+ it ( '[v]string' , ( ) => {
31
+ const result4 = pinyin ( '吕和平' , { toneType : 'none' , v : 'yu' } ) ;
32
+ expect ( result4 ) . to . be . equal ( 'lyu he ping' ) ;
33
+ } ) ;
29
34
} ) ;
Original file line number Diff line number Diff line change @@ -60,8 +60,9 @@ export interface BasicOptions {
60
60
* @description 对于 ü 的返回是否转换成 v(仅在 toneType: none 启用时生效)
61
61
* @value false:返回值中保留 ü (默认值)
62
62
* @value true:返回值中 ü 转换成 v
63
+ * @value string:返回值中 ü 转换成指定字符
63
64
*/
64
- v ?: boolean ;
65
+ v ?: boolean | string ;
65
66
/**
66
67
* @description 是否开启「一」和 「不」字的变调。默认开启。参考:https://zh.wiktionary.org/wiki/Appendix:%E2%80%9C%E4%B8%80%E2%80%9D%E5%8F%8A%E2%80%9C%E4%B8%8D%E2%80%9D%E7%9A%84%E5%8F%98%E8%B0%83
67
68
* @value true:开启
You can’t perform that action at this time.
0 commit comments