Repository: zh-lx/pinyin-pro (ts)

Issue:
html api ：是否可以增加去掉 <rp> 标签生成的选项
## 功能描述

是否可以增加去掉 <rp> 标签生成的选项

减少数据量，不需要关注旧浏览器的情况

Pull request description:
feat: html api 支持不输出 rp 标签
## PR 的功能

feat: html api 支持不输出 rp 标签

close #270 

Patch:
diff --git a/lib/core/html/index.ts b/lib/core/html/index.ts
index 0a4d22e..be850b8 100644
--- a/lib/core/html/index.ts
+++ b/lib/core/html/index.ts
@@ -37,6 +37,12 @@ interface HtmlOptions {
    * @value false：不开启
    */
   toneSandhi?: boolean;
+  /**
+   * @description 是否保留  <rp>(</rp> 标签，默认为保留
+   * @value true：保留 <rp>(</rp>
+   * @value false：移除 <rp>(</rp>
+   */
+  rp?: boolean;
 }
 
 const DefaultHtmlOptions: HtmlOptions = {
@@ -48,6 +54,7 @@ const DefaultHtmlOptions: HtmlOptions = {
   toneType: 'symbol',
   customClassMap: {},
   toneSandhi: true,
+  rp: true,
 };
 
 /**
@@ -79,7 +86,7 @@ export const html = (text: string, options?: HtmlOptions) => {
       const resultClass = completeOptions.resultClass || DefaultHtmlOptions.resultClass;
       const chineseClass = completeOptions.chineseClass || DefaultHtmlOptions.chineseClass;
       const pinyinClass = completeOptions.pinyinClass || DefaultHtmlOptions.pinyinClass;
-      return `<span class="${resultClass}${additionalClass}"><ruby><span class="${chineseClass}">${item.origin}</span><rp>(</rp><rt class="${pinyinClass}">${item.pinyin}</rt><rp>)</rp></ruby></span>`;
+      return `<span class="${resultClass}${additionalClass}"><ruby><span class="${chineseClass}">${item.origin}</span>${completeOptions.rp ? '<rp>(</rp>' : ''}<rt class="${pinyinClass}">${item.pinyin}</rt>${completeOptions.rp ? '<rp>)</rp>' : ''}</ruby></span>`;
     } else {
       // 非汉字字符处理
       if (completeOptions.wrapNonChinese) {


Test patch:
diff --git a/test/html.test.js b/test/html.test.js
index 3aef583..a974254 100644
--- a/test/html.test.js
+++ b/test/html.test.js
@@ -103,4 +103,13 @@ describe('html', () => {
       `<span class="py-result-item"><ruby><span class="py-chinese-item">汉</span><rp>(</rp><rt class="py-pinyin-item">hàn</rt><rp>)</rp></ruby></span><span class="py-result-item"><ruby><span class="py-chinese-item">语</span><rp>(</rp><rt class="py-pinyin-item">yǔ</rt><rp>)</rp></ruby></span><span class="py-non-chinese-item">，</span><span class="py-result-item"><ruby><span class="py-chinese-item">拼</span><rp>(</rp><rt class="py-pinyin-item">pīn</rt><rp>)</rp></ruby></span><span class="py-result-item"><ruby><span class="py-chinese-item">音</span><rp>(</rp><rt class="py-pinyin-item">yīn</rt><rp>)</rp></ruby></span>`
     );
   });
+
+  it('[html-custom-class]remove rp', () => {
+    const result = html('汉语，拼音', {
+      rp: false,
+    });
+    expect(result).to.be.equal(
+      `<span class="py-result-item"><ruby><span class="py-chinese-item">汉</span><rt class="py-pinyin-item">hàn</rt></ruby></span><span class="py-result-item"><ruby><span class="py-chinese-item">语</span><rt class="py-pinyin-item">yǔ</rt></ruby></span>，<span class="py-result-item"><ruby><span class="py-chinese-item">拼</span><rt class="py-pinyin-item">pīn</rt></ruby></span><span class="py-result-item"><ruby><span class="py-chinese-item">音</span><rt class="py-pinyin-item">yīn</rt></ruby></span>`
+    );
+  });
 });