@@ -399,77 +399,151 @@ extraApiStatsFinder.getContentWordCount({
399399
400400### 渲染 API
401401
402- 此功能在轻量版和全量版中均可用。
403-
404402** Finder 名称:** ` extraApiRenderFinder `
405403
406404#### 中英文混排格式化 API
407405
408406** 描述**
409407
410- 提供中英文混排自动空格功能,自动在中日韩(CJK)字符与英文字母、数字、符号之间插入空格,提升内容可读性。此功能在轻量版和全量版中均可用。
408+ 提供中英文混排自动空格功能,自动在中日韩(CJK)字符与英文字母、数字、符号之间插入空格,提升内容可读性。
411409
412- ** API 方法**
410+ ** 处理纯文本内容的 API 方法**
411+
412+ ``` javascript
413+ // 对纯文本应用 Pangu 空格处理
414+ extraApiRenderFinder .applySpacingInText (text)
415+ ```
416+
417+ ** 参数**
418+
419+ - ` text `
420+ - 类型:` string `
421+ - 解释:要处理的纯文本内容
422+
423+ ** 返回值**
424+
425+ - 类型:` string `
426+ - 解释:处理后的内容,失败时返回原始内容
427+
428+ ** 描述**
429+
430+ - 处理规则
431+ - 在中日韩字符和英文字母之间添加空格
432+ - 在中日韩字符和数字之间添加空格
433+ - 在中日韩字符和常见符号之间添加空格
434+ - 性能说明
435+ - 纯 Java 实现,处理速度快,适合在模板中直接使用
436+ - 不涉及缓存,每次调用都会重新处理
437+ - 错误处理
438+ - 输入为空或 null 时返回空字符串
439+ - HTML 解析失败时返回原始内容
440+ - 不会抛出异常,保证页面渲染稳定性
441+
442+ ** 使用示例**
443+
444+ ``` html
445+ <!-- /* 对纯文本应用 Pangu 处理 */-->
446+ <span th:text =" ${extraApiRenderFinder.applySpacingInText('请问Jackie的鼻子有几个?123个!')}" ></span >
447+ <!-- /* 输出:请问 Jackie 的鼻子有几个?123 个! */-->
448+ ```
449+
450+ ** 处理 HTML 内容的 API 方法(传入字符串形式参数)**
413451
414452``` javascript
415453// 对整个 HTML 内容应用 Pangu 空格处理
416454extraApiRenderFinder .applySpacingInHtml (htmlContent)
455+ ```
456+
457+ ** 参数**
458+
459+ - ` htmlContent `
460+ - 类型:` string `
461+ - 解释:包含 HTML 标签的内容
462+
463+ ** 返回值**
464+
465+ - 类型:` string `
466+ - 解释:处理后的内容,失败时返回原始内容
417467
468+ ** 描述**
469+
470+ - 处理规则
471+ - 在中日韩字符和英文字母之间添加空格
472+ - 在中日韩字符和数字之间添加空格
473+ - 在中日韩字符和常见符号之间添加空格
474+ - 跳过规则:自动跳过 ` <code> ` 、` <pre> ` 、` <script> ` 、` <style> ` 、` <textarea> ` 等标签,保留其原始格式
475+ - 性能说明
476+ - 纯 Java 实现,处理速度快,适合在模板中直接使用
477+ - 不涉及缓存,每次调用都会重新处理
478+ - 错误处理
479+ - 输入为空或 null 时返回空字符串
480+ - HTML 解析失败时返回原始内容
481+ - 不会抛出异常,保证页面渲染稳定性
482+
483+ ** 使用示例**
484+
485+ ``` html
486+ <!-- /* 处理整个 HTML 内容(自动跳过 code、pre 等标签) */-->
487+ <div th:utext =" ${extraApiRenderFinder.applySpacingInHtml(post.content?.content)}" ></div >
488+
489+ <!-- /* 在变量中使用 */-->
490+ <div th:with =" processedContent=${extraApiRenderFinder.applySpacingInHtml(moment.spec.content?.html)}" >
491+ <div th:utext =" ${processedContent}" ></div >
492+ </div >
493+ ```
494+
495+ ** 处理 HTML 内容的 API 方法(传入映射形式参数)**
496+
497+ ``` javascript
418498// 使用灵活参数对 HTML 内容应用 Pangu 空格处理
419499extraApiRenderFinder .applySpacingInHtml ({
420500 htmlContent: ' <p>HTML 内容</p>' , // 必需
421501 selector: ' p' // 可选,CSS 选择器
422502})
423-
424- // 对纯文本应用 Pangu 空格处理
425- extraApiRenderFinder .applySpacingInText (text)
426503```
427504
428505** 参数**
429506
430- - ` applySpacingInHtml(htmlContent) `
431- - ` htmlContent `
432- - 类型:` string `
433- - 解释:包含 HTML 标签的内容
434- - ` applySpacingInHtml(params) `
435- - ` params ` - 映射形式参数
436- - ` htmlContent `
437- - 类型:` string `
438- - 解释:包含 HTML 标签的内容(必需)
439- - ` selector `
440- - 类型:` string `
441- - 解释:CSS 选择器,用于定位特定元素(可选)
442- - 支持所有 JSoup CSS 选择器,包括:
443- - 标签选择器:` p ` , ` div ` , ` span `
444- - ID 选择器:` #main ` , ` #content `
445- - Class 选择器:` .article ` , ` .comment `
446- - 属性选择器:` [attr] ` , ` [attr=value] `
447- - 后代选择器:` div p ` , ` .article .content `
448- - 子选择器:` div > p `
449- - 伪类选择器:` :first-child ` , ` :nth-child(n) `
450- - ` applySpacingInText(text) `
451- - ` text `
452- - 类型:` string `
453- - 解释:要处理的纯文本内容
507+ - ` htmlContent `
508+ - 类型:` string `
509+ - 解释:包含 HTML 标签的内容(必需)
510+ - ` selector `
511+ - 类型:` string `
512+ - 解释:CSS 选择器,用于定位特定元素(可选)
513+ - 支持所有 JSoup CSS 选择器,包括:
514+ - 标签选择器:` p ` , ` div ` , ` span `
515+ - ID 选择器:` #main ` , ` #content `
516+ - Class 选择器:` .article ` , ` .comment `
517+ - 属性选择器:` [attr] ` , ` [attr=value] `
518+ - 后代选择器:` div p ` , ` .article .content `
519+ - 子选择器:` div > p `
520+ - 伪类选择器:` :first-child ` , ` :nth-child(n) `
454521
455522** 返回值**
456523
457- - 类型:` Mono<String> `
524+ - 类型:` string `
458525- 解释:处理后的内容,失败时返回原始内容
459526
460- ** 处理规则**
527+ ** 描述**
528+
529+ ** 描述**
461530
462- - 在中日韩字符和英文字母之间添加空格
463- - 在中日韩字符和数字之间添加空格
464- - 在中日韩字符和常见符号之间添加空格
465- - 自动跳过 ` <code> ` 、` <pre> ` 、` <script> ` 、` <style> ` 、` <textarea> ` 等标签,保留其原始格式
531+ - 处理规则
532+ - 在中日韩字符和英文字母之间添加空格
533+ - 在中日韩字符和数字之间添加空格
534+ - 在中日韩字符和常见符号之间添加空格
535+ - 省略 ` selector ` 时应用跳过规则:自动跳过 ` <code> ` 、` <pre> ` 、` <script> ` 、` <style> ` 、` <textarea> ` 等标签,保留其原始格式
536+ - 性能说明
537+ - 纯 Java 实现,处理速度快,适合在模板中直接使用
538+ - 不涉及缓存,每次调用都会重新处理
539+ - 错误处理
540+ - 输入为空或 null 时返回空字符串
541+ - HTML 解析失败时返回原始内容
542+ - 不会抛出异常,保证页面渲染稳定性
466543
467544** 使用示例**
468545
469546``` html
470- <!-- /* 处理整个 HTML 内容(自动跳过 code、pre 等标签) */-->
471- <div th:utext =" ${extraApiRenderFinder.applySpacingInHtml(post.content?.content)}" ></div >
472-
473547<!-- /* 使用 CSS 选择器仅处理段落标签 */-->
474548<div th:utext =" ${extraApiRenderFinder.applySpacingInHtml({htmlContent: post.content?.content, selector: 'p'})}" ></div >
475549
@@ -482,33 +556,12 @@ extraApiRenderFinder.applySpacingInText(text)
482556<!-- /* 使用复合选择器处理 */-->
483557<div th:utext =" ${extraApiRenderFinder.applySpacingInHtml({htmlContent: content, selector: 'div.article > p'})}" ></div >
484558
485- <!-- /* 对纯文本应用 Pangu 处理 */-->
486- <span th:text =" ${extraApiRenderFinder.applySpacingInText('请问Jackie的鼻子有几个?123个!')}" ></span >
487- <!-- /* 输出:请问 Jackie 的鼻子有几个?123 个! */-->
488-
489- <!-- /* 在变量中使用 */-->
490- <div th:with =" processedContent=${extraApiRenderFinder.applySpacingInHtml(moment.spec.content?.html)}" >
491- <div th:utext =" ${processedContent}" ></div >
492- </div >
493-
494559<!-- /* 处理瞬间内容中的特定元素 */-->
495560<div th:with =" processedContent=${extraApiRenderFinder.applySpacingInHtml({htmlContent: moment.spec.content?.html, selector: '.moment-text'})}" >
496561 <div th:utext =" ${processedContent}" ></div >
497562</div >
498563```
499564
500- ** 性能说明**
501-
502- - 纯 Java 实现,无需 JavaScript 运行时
503- - 处理速度快,适合在模板中直接使用
504- - 不涉及缓存,每次调用都会重新处理
505-
506- ** 错误处理**
507-
508- - 输入为空或 null 时返回原始内容
509- - HTML 解析失败时返回原始内容
510- - 不会抛出异常,保证页面渲染稳定性
511-
512565### 渲染 API(需要 JS 运行时)
513566
514567此功能仅在全量版中可用。
@@ -555,8 +608,6 @@ extraApiJsRenderFinder.highlightCodeInHtml(htmlContent)
555608
556609插件提供了自动化的中英文混排格式化处理器,无需在模板中手动调用,即可对文章和页面内容自动应用 Pangu 空格处理。
557610
558- 此功能在轻量版和全量版中均可用。
559-
560611#### 功能说明
561612
562613- 自动处理范围:
0 commit comments