From 78048a8765c1050499f95ad8a326245a7dd537b6 Mon Sep 17 00:00:00 2001 From: Amos Date: Sun, 10 Mar 2024 22:42:22 +0800 Subject: [PATCH] Update: TOC Style (#1419) --- tool/translator/gulpfile.js | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/tool/translator/gulpfile.js b/tool/translator/gulpfile.js index 3684956e15..43b7ca0798 100644 --- a/tool/translator/gulpfile.js +++ b/tool/translator/gulpfile.js @@ -1,14 +1,17 @@ const gulp = require('gulp'); const replace = require('gulp-replace'); +// 去掉中文标点与中文间的空格 gulp.task('remove-space', () => { return gulp.src(['../../_site/**/*.html']) - .pipe(replace(/([\u3000-\u303F\u4e00-\u9fa5\uF900-\uFFEF])\s+(?=[\u3000-\u303F\u4e00-\u9fa5\uF900-\uFFEF])/gs, '$1')) - .pipe(gulp.dest('../../_site')); + .pipe(replace(/([\u3000-\u303F\u4e00-\u9fa5\uF900-\uFFEF])\s+(?=[\u3000-\u303F\u4e00-\u9fa5\uF900-\uFFEF])/gs, '$1')) + .pipe(gulp.dest('../../_site')); }); +// 匹配替换目录相关格式 gulp.task('mark-side-toc', () => { + const tocRegexp = /
  • (?!.*[\u4e00-\u9fa5])(.*?)<\/a><\/li>\n.*>(?=.*[\u4e00-\u9fa5])(.*?)<\/a>/g; return gulp.src(['../../_site/**/*.html']) - .pipe(replace(/
  • (?!.*[\u4e00-\u9fa5])(.*?)<\/a><\/li>\n.*>(?=.*[\u4e00-\u9fa5])(.*?)<\/a>/g, '
  • $5

    $6

    ')) - .pipe(gulp.dest('../../_site')); + .pipe(replace(tocRegexp, `
  • $5$6`)) + .pipe(gulp.dest('../../_site')); });