@lobehub/ui 2.13.3 → 2.13.5

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.
@@ -2,5 +2,5 @@ var _templateObject;
2
2
  function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); }
3
3
  import { css } from 'antd-style';
4
4
  export default (function (token) {
5
- return css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n :root {\n --font-settings: 'cv01', 'tnum', 'kern';\n --font-variations: 'opsz' auto, tabular-nums;\n }\n\n html {\n overscroll-behavior: none;\n color-scheme: ", ";\n }\n\n body {\n overflow: hidden auto;\n\n min-height: 100vh;\n margin: 0;\n padding: 0;\n\n font-family: ", ";\n font-size: ", "px;\n font-feature-settings: var(--font-settings);\n font-variation-settings: var(--font-variations);\n -webkit-font-smoothing: antialiased;\n -moz-osx-font-smoothing: grayscale;\n line-height: 1;\n color: ", ";\n text-size-adjust: none;\n text-rendering: optimizelegibility;\n word-wrap: break-word;\n vertical-align: baseline;\n\n background-color: ", ";\n\n -webkit-overflow-scrolling: touch;\n -webkit-tap-highlight-color: transparent;\n }\n\n code {\n font-family: ", " !important;\n\n span {\n font-family: ", " !important;\n }\n }\n\n ::selection {\n color: #000;\n background: ", ";\n\n -webkit-text-fill-color: unset !important;\n }\n\n * {\n scrollbar-color: ", " transparent;\n scrollbar-width: thin;\n box-sizing: border-box;\n vertical-align: baseline;\n }\n"])), token.isDarkMode ? 'dark' : 'light', token.fontFamily, token.fontSize, token.colorTextBase, token.colorBgLayout, token.fontFamilyCode, token.fontFamilyCode, token.yellow9, token.colorFill);
5
+ return css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n :root {\n --font-settings: 'cv01', 'tnum', 'kern';\n --font-variations: 'opsz' auto, tabular-nums;\n\n text-autospace: normal;\n }\n\n html {\n overscroll-behavior: none;\n color-scheme: ", ";\n }\n\n body {\n overflow: hidden auto;\n\n min-height: 100vh;\n margin: 0;\n padding: 0;\n\n font-family: ", ";\n font-size: ", "px;\n font-feature-settings: var(--font-settings);\n font-variation-settings: var(--font-variations);\n -webkit-font-smoothing: antialiased;\n -moz-osx-font-smoothing: grayscale;\n line-height: 1;\n color: ", ";\n text-size-adjust: none;\n text-rendering: optimizelegibility;\n word-wrap: break-word;\n vertical-align: baseline;\n\n background-color: ", ";\n\n -webkit-overflow-scrolling: touch;\n -webkit-tap-highlight-color: transparent;\n }\n\n code {\n font-family: ", " !important;\n\n span {\n font-family: ", " !important;\n }\n }\n\n ::selection {\n color: #000;\n background: ", ";\n\n -webkit-text-fill-color: unset !important;\n }\n\n * {\n scrollbar-color: ", " transparent;\n scrollbar-width: thin;\n box-sizing: border-box;\n vertical-align: baseline;\n }\n"])), token.isDarkMode ? 'dark' : 'light', token.fontFamily, token.fontSize, token.colorTextBase, token.colorBgLayout, token.fontFamilyCode, token.fontFamilyCode, token.yellow9, token.colorFill);
6
6
  });
@@ -32,6 +32,19 @@ export declare function escapeLatexPipes(text: string): string;
32
32
  * @returns The string with unescaped underscores escaped within \text{...} commands
33
33
  */
34
34
  export declare function escapeTextUnderscores(text: string): string;
35
+ /**
36
+ * Escapes dollar signs that appear to be currency symbols to prevent them from being
37
+ * interpreted as LaTeX math delimiters.
38
+ *
39
+ * This function identifies currency patterns such as:
40
+ * - $20, $100, $1,000
41
+ * - $20-50, $100+
42
+ * - Patterns within markdown tables
43
+ *
44
+ * @param text The input string containing potential currency symbols
45
+ * @returns The string with currency dollar signs escaped
46
+ */
47
+ export declare function escapeCurrencyDollars(text: string): string;
35
48
  /**
36
49
  * Preprocesses LaTeX content by performing multiple operations:
37
50
  * 1. Protects code blocks from processing
@@ -51,7 +51,8 @@ export function escapeLatexPipes(text) {
51
51
  // Replace unescaped '|' inside LaTeX math spans with '\vert' so that
52
52
  // remark-gfm table parsing won't treat them as column separators.
53
53
  // Leave code blocks/inline code untouched.
54
- var pattern = /(```[\S\s]*?```|`[^\n`]*`)|\$\$([\S\s]*?)\$\$|(?<!\$)\$(?!\$)([\S\s]*?)(?<!\$)\$(?!\$)/g;
54
+ // Also ignore escaped dollars (\$) which are currency symbols
55
+ var pattern = /(```[\S\s]*?```|`[^\n`]*`)|\$\$([\S\s]*?)\$\$|(?<!\\)(?<!\$)\$(?!\$)([\S\s]*?)(?<!\\)(?<!\$)\$(?!\$)/g;
55
56
  return text.replaceAll(pattern, function (match, code, display, inline) {
56
57
  if (code !== undefined) return code; // preserve code fences/inline code
57
58
  if (display !== undefined) return "$$".concat(replaceUnescapedPipes(display), "$$");
@@ -79,6 +80,41 @@ export function escapeTextUnderscores(text) {
79
80
  });
80
81
  }
81
82
 
83
+ /**
84
+ * Escapes dollar signs that appear to be currency symbols to prevent them from being
85
+ * interpreted as LaTeX math delimiters.
86
+ *
87
+ * This function identifies currency patterns such as:
88
+ * - $20, $100, $1,000
89
+ * - $20-50, $100+
90
+ * - Patterns within markdown tables
91
+ *
92
+ * @param text The input string containing potential currency symbols
93
+ * @returns The string with currency dollar signs escaped
94
+ */
95
+ export function escapeCurrencyDollars(text) {
96
+ // Protect code blocks and existing LaTeX expressions from processing
97
+ var protectedStrings = [];
98
+ var content = text.replaceAll(/(```[\S\s]*?```|`[^\n`]*`|\$\$[\S\s]*?\$\$|\\\[[\S\s]*?\\]|\\\(.*?\\\))/g, function (match) {
99
+ protectedStrings.push(match);
100
+ return "<<PROTECTED_".concat(protectedStrings.length - 1, ">>");
101
+ });
102
+
103
+ // Escape dollar signs that are clearly currency:
104
+ // - $ followed by a digit
105
+ // - Not preceded by another $ (to avoid breaking $$)
106
+ // - Followed by number patterns with optional commas, decimals, ranges, or plus signs
107
+ // Match patterns like: $20, $1,000, $19.99, $20-50, $300+, $1,000-2,000+
108
+ // In the replacement: \\ = backslash, $$ = literal $, $1 = capture group 1
109
+ content = content.replaceAll(/(?<!\$)\$(\d{1,3}(?:,\d{3})*(?:\.\d+)?(?:-\d{1,3}(?:,\d{3})*(?:\.\d+)?)?\+?)/g, '\\$$$1');
110
+
111
+ // Restore protected content
112
+ content = content.replaceAll(/<<PROTECTED_(\d+)>>/g, function (_, index) {
113
+ return protectedStrings[Number.parseInt(index)];
114
+ });
115
+ return content;
116
+ }
117
+
82
118
  /**
83
119
  * Preprocesses LaTeX content by performing multiple operations:
84
120
  * 1. Protects code blocks from processing
@@ -123,6 +159,8 @@ export function preprocessLaTeX(str) {
123
159
  var content = str;
124
160
 
125
161
  // Step 6: Apply additional escaping functions
162
+ // Escape currency dollar signs FIRST before other LaTeX processing
163
+ content = escapeCurrencyDollars(content);
126
164
  content = convertLatexDelimiters(content);
127
165
  content = escapeMhchemCommands(content);
128
166
  content = escapeLatexPipes(content);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lobehub/ui",
3
- "version": "2.13.3",
3
+ "version": "2.13.5",
4
4
  "description": "Lobe UI is an open-source UI component library for building AIGC web apps",
5
5
  "keywords": [
6
6
  "lobehub",