@lobehub/ui 2.11.2 → 2.11.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -36,29 +36,29 @@ function applyEmphasisFixes(text) {
36
36
 
37
37
  // Step 1: Remove trailing spaces inside emphasis markers
38
38
  var removeInternalSpaces = [
39
- // 处理 **bold** 格式(两个星号)- 只处理一个空格
39
+ // 处理 **bold** 格式(两个星号)- 只处理一个空格,确保内容不包含表格分隔符
40
40
  {
41
- pattern: /(\*\*)([^\n*]+?)( )(\*\*)/g,
41
+ pattern: /(\*\*)([^\n*|]+?)( )(\*\*)/g,
42
42
  replacement: '$1$2$4'
43
43
  },
44
- // 处理 __bold__ 格式(两个下划线)- 只处理一个空格
44
+ // 处理 __bold__ 格式(两个下划线)- 只处理一个空格,确保内容不包含表格分隔符
45
45
  {
46
- pattern: /(__)([^\n_]+?)( )(__)/g,
46
+ pattern: /(__)([^\n_|]+?)( )(__)/g,
47
47
  replacement: '$1$2$4'
48
48
  },
49
- // 处理 ~~strikethrough~~ 格式(删除线)- 只处理一个空格
49
+ // 处理 ~~strikethrough~~ 格式(删除线)- 只处理一个空格,确保内容不包含表格分隔符
50
50
  {
51
- pattern: /(~~)([^\n~]+?)( )(~~)/g,
51
+ pattern: /(~~)([^\n|~]+?)( )(~~)/g,
52
52
  replacement: '$1$2$4'
53
53
  },
54
- // 处理单个 * 格式 - 只处理一个空格,使用更精确的边界匹配
54
+ // 处理单个 * 格式 - 只处理一个空格,使用更精确的边界匹配,确保内容不包含表格分隔符
55
55
  {
56
- pattern: /(^|[^\w*])(\*(?!\*))([^\n*]+?)( )(\*(?!\*))/g,
56
+ pattern: /(^|[^\w*])(\*(?!\*))([^\n*|]+?)( )(\*(?!\*))/g,
57
57
  replacement: '$1$2$3$5'
58
58
  },
59
- // 处理单个 _ 格式 - 只处理一个空格,使用更精确的边界匹配
59
+ // 处理单个 _ 格式 - 只处理一个空格,使用更精确的边界匹配,确保内容不包含表格分隔符
60
60
  {
61
- pattern: /(^|\W)(_(?!_))([^\n_]+?)( )(_(?!_))/g,
61
+ pattern: /(^|\W)(_(?!_))([^\n_|]+?)( )(_(?!_))/g,
62
62
  replacement: '$1$2$3$5'
63
63
  }];
64
64
  result = removeInternalSpaces.reduce(function (text, _ref) {
@@ -70,30 +70,30 @@ function applyEmphasisFixes(text) {
70
70
  // Step 2: Add space after closing emphasis markers when followed by symbols/punctuation/Chinese characters
71
71
  // Define emphasis patterns
72
72
  var emphasisPatterns = [
73
- // ** (bold)
73
+ // ** (bold) - exclude table separators from content
74
74
  {
75
75
  markerChar: '*',
76
- pattern: /(\*\*)([^\n*]*?)(\*\*)(\S)/g
76
+ pattern: /(\*\*)([^\n*|]*?)(\*\*)(\S)/g
77
77
  },
78
- // __ (bold)
78
+ // __ (bold) - exclude table separators from content
79
79
  {
80
80
  markerChar: '_',
81
- pattern: /(__)([^\n_]*?)(__)(\S)/g
81
+ pattern: /(__)([^\n_|]*?)(__)(\S)/g
82
82
  },
83
- // * (italic) - need to avoid matching **
83
+ // * (italic) - need to avoid matching **, exclude table separators from content
84
84
  {
85
85
  markerChar: '*',
86
- pattern: /(\*(?!\*))([^\n*]*?)(\*(?!\*))(\S)/g
86
+ pattern: /(\*(?!\*))([^\n*|]*?)(\*(?!\*))(\S)/g
87
87
  },
88
- // _ (italic) - need to avoid matching __
88
+ // _ (italic) - need to avoid matching __, exclude table separators from content
89
89
  {
90
90
  markerChar: '_',
91
- pattern: /(_(?!_))([^\n_]*?)(_(?!_))(\S)/g
91
+ pattern: /(_(?!_))([^\n_|]*?)(_(?!_))(\S)/g
92
92
  },
93
- // ~~ (strikethrough)
93
+ // ~~ (strikethrough) - exclude table separators from content
94
94
  {
95
95
  markerChar: '~',
96
- pattern: /(~~)([^\n~]*?)(~~)(\S)/g
96
+ pattern: /(~~)([^\n|~]*?)(~~)(\S)/g
97
97
  }];
98
98
 
99
99
  // Apply space after closing markers for each emphasis type
@@ -104,8 +104,13 @@ function applyEmphasisFixes(text) {
104
104
  var lastChar = content.slice(-1);
105
105
  var isSymbolOrPunctuation = /[!"#$%&'()*+,./:;<=>?@[\\\]^_`{|}~、。《》【】!(),:;?{|}-]/.test(lastChar);
106
106
 
107
+ // Don't add space if next character is a table separator or other markdown structural characters
108
+ var isTableSeparator = nextChar === '|';
109
+ var isMarkdownStructural = /[()[\]{}]/.test(nextChar);
110
+
107
111
  // If content ends with symbol/punctuation and next character is not whitespace, add space
108
- if (isSymbolOrPunctuation && nextChar && !/\s/.test(nextChar)) {
112
+ // But skip if it's a table separator or markdown structural character
113
+ if (isSymbolOrPunctuation && nextChar && !/\s/.test(nextChar) && !isTableSeparator && !isMarkdownStructural) {
109
114
  return start + content + end + ' ' + nextChar;
110
115
  }
111
116
  return match;
@@ -1,4 +1,3 @@
1
- import { fixMarkdownEmphasisSpacing } from "./fixMarkdownEmphasisSpacing";
2
1
  import { preprocessLaTeX } from "./latex";
3
2
 
4
3
  // Cache configuration
@@ -134,5 +133,5 @@ export var preprocessContent = function preprocessContent(str) {
134
133
  if (enableCustomFootnotes) {
135
134
  content = transformCitations(content, citationsLength);
136
135
  }
137
- return fixMarkdownEmphasisSpacing(content);
136
+ return content;
138
137
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lobehub/ui",
3
- "version": "2.11.2",
3
+ "version": "2.11.4",
4
4
  "description": "Lobe UI is an open-source UI component library for building AIGC web apps",
5
5
  "keywords": [
6
6
  "lobehub",