entari-plugin-hyw 3.2.106__py3-none-any.whl → 3.2.107__py3-none-any.whl
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.
Potentially problematic release.
This version of entari-plugin-hyw might be problematic. Click here for more details.
- entari_plugin_hyw/core/render.py +38 -2
- {entari_plugin_hyw-3.2.106.dist-info → entari_plugin_hyw-3.2.107.dist-info}/METADATA +1 -1
- {entari_plugin_hyw-3.2.106.dist-info → entari_plugin_hyw-3.2.107.dist-info}/RECORD +5 -5
- {entari_plugin_hyw-3.2.106.dist-info → entari_plugin_hyw-3.2.107.dist-info}/WHEEL +0 -0
- {entari_plugin_hyw-3.2.106.dist-info → entari_plugin_hyw-3.2.107.dist-info}/top_level.txt +0 -0
entari_plugin_hyw/core/render.py
CHANGED
|
@@ -178,12 +178,48 @@ class ContentRenderer:
|
|
|
178
178
|
last_exc = None
|
|
179
179
|
for attempt in range(1, max_attempts + 1):
|
|
180
180
|
try:
|
|
181
|
-
#
|
|
181
|
+
# 1. Protect math blocks
|
|
182
|
+
# We look for $$...$$, \[...\], \(...\)
|
|
183
|
+
# We'll replace them with placeholders so markdown extensions (like nl2br) don't touch them.
|
|
184
|
+
math_blocks = {}
|
|
185
|
+
|
|
186
|
+
def protect_math(match):
|
|
187
|
+
key = f"__MATH_BLOCK_{len(math_blocks)}__"
|
|
188
|
+
math_blocks[key] = match.group(0)
|
|
189
|
+
return key
|
|
190
|
+
|
|
191
|
+
# Patterns for math:
|
|
192
|
+
# 1) $$ ... $$ (display math)
|
|
193
|
+
# 2) \[ ... \] (display math)
|
|
194
|
+
# 3) \( ... \) (inline math)
|
|
195
|
+
# Note: We must handle multiline for $$ and \[
|
|
196
|
+
|
|
197
|
+
# Regex for $$...$$
|
|
198
|
+
markdown_content = re.sub(r'\$\$(.*?)\$\$\s*', protect_math, markdown_content, flags=re.DOTALL)
|
|
199
|
+
|
|
200
|
+
# Regex for \[...\]
|
|
201
|
+
markdown_content = re.sub(r'\\\[(.*?)\\\]\s*', protect_math, markdown_content, flags=re.DOTALL)
|
|
202
|
+
|
|
203
|
+
# Regex for \(...\) (usually single line, but DOTALL is safest if user wraps lines)
|
|
204
|
+
markdown_content = re.sub(r'\\\((.*?)\\\)', protect_math, markdown_content, flags=re.DOTALL)
|
|
205
|
+
|
|
206
|
+
# 2. Render Markdown
|
|
207
|
+
# Use 'nl2br' to turn newlines into <br>, 'fenced_code' for code blocks
|
|
182
208
|
content_html = markdown.markdown(
|
|
183
|
-
markdown_content.strip(),
|
|
209
|
+
markdown_content.strip(),
|
|
184
210
|
extensions=['fenced_code', 'tables', 'nl2br', 'sane_lists']
|
|
185
211
|
)
|
|
186
212
|
|
|
213
|
+
# 3. Restore math blocks
|
|
214
|
+
def restore_math(text):
|
|
215
|
+
# We assume placeholders are intact. We do a simple string replace or regex.
|
|
216
|
+
# Since placeholders are unique strings, we can just replace them.
|
|
217
|
+
for key, val in math_blocks.items():
|
|
218
|
+
text = text.replace(key, val)
|
|
219
|
+
return text
|
|
220
|
+
|
|
221
|
+
content_html = restore_math(content_html)
|
|
222
|
+
|
|
187
223
|
# Post-process to style citation markers
|
|
188
224
|
parts = re.split(r'(<code.*?>.*?</code>)', content_html, flags=re.DOTALL)
|
|
189
225
|
for i, part in enumerate(parts):
|
|
@@ -32,7 +32,7 @@ entari_plugin_hyw/core/config.py,sha256=LUP1LY0U9xfF_rzV2HxnNfJnfi929RNUZeFgbFFs
|
|
|
32
32
|
entari_plugin_hyw/core/history.py,sha256=vqp7itwR5-KaqC4Ftmq6GOz7OM9GsiFJnSN9JJ2P6L4,5894
|
|
33
33
|
entari_plugin_hyw/core/hyw.py,sha256=QwLB2YpUnzbVCWXcJF0uUeDAjxd4LWMzm9EjB9T1G1g,1671
|
|
34
34
|
entari_plugin_hyw/core/pipeline.py,sha256=nV07UxzCXLLvAYDzcxgoYTxbxcHzD-_Ym4ZluvM82xg,38673
|
|
35
|
-
entari_plugin_hyw/core/render.py,sha256=
|
|
35
|
+
entari_plugin_hyw/core/render.py,sha256=MWJMfwyOcN_DMo1rLiYdO648ro6ztNH3wdztfeVUBV0,25835
|
|
36
36
|
entari_plugin_hyw/core/render.py.bak,sha256=qMd6Tk0p6ItqGmErR6dkWRwCuKQYXINc7KRxnP-mb_s,48768
|
|
37
37
|
entari_plugin_hyw/utils/__init__.py,sha256=2JEC3lqFoa8FgR1kUjNUbwSph23YSOxbCaqYSgFomxs,128
|
|
38
38
|
entari_plugin_hyw/utils/browser.py,sha256=Szr7oIx8My9Qnh8_bQsEm7o3iUZYk9Gamtz7kvwTNyg,2086
|
|
@@ -41,7 +41,7 @@ entari_plugin_hyw/utils/misc.py,sha256=_7iHVYj_mJ6OGq6FU1s_cFeS1Ao-neBjZYd6eI2p9
|
|
|
41
41
|
entari_plugin_hyw/utils/playwright_tool.py,sha256=eSIfur64U8Z5rN0UlZK8qg3vJrGgZZHjhyIId1jSHzs,1507
|
|
42
42
|
entari_plugin_hyw/utils/prompts.py,sha256=uRFuPuDl6Eg_mi-GNc8ZP5OaCvNK6EvluODoqeJc0AM,3114
|
|
43
43
|
entari_plugin_hyw/utils/search.py,sha256=v9lW18V8rAGneejAiqJ4hCiCy7mIjkRCmR4UuiBqRxY,8048
|
|
44
|
-
entari_plugin_hyw-3.2.
|
|
45
|
-
entari_plugin_hyw-3.2.
|
|
46
|
-
entari_plugin_hyw-3.2.
|
|
47
|
-
entari_plugin_hyw-3.2.
|
|
44
|
+
entari_plugin_hyw-3.2.107.dist-info/METADATA,sha256=YK7RiyNyYrZ6sjeVe6ktcm6-HZDXJIO4_1Woe8n6-cY,4697
|
|
45
|
+
entari_plugin_hyw-3.2.107.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
46
|
+
entari_plugin_hyw-3.2.107.dist-info/top_level.txt,sha256=TIDsn6XPs6KA5e3ezsE65JoXsy03ejDdrB41I4SPjmo,18
|
|
47
|
+
entari_plugin_hyw-3.2.107.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|