Prathamesh Sarjerao Vaidya
commited on
Commit
Β·
6a90a55
1
Parent(s):
ffb9af5
update main & check.yml
Browse files- .github/workflows/check.yml +35 -16
- .github/workflows/main.yml +35 -16
.github/workflows/check.yml
CHANGED
@@ -59,6 +59,8 @@ jobs:
|
|
59 |
run: |
|
60 |
npm install -g @mermaid-js/mermaid-cli
|
61 |
npm install -g puppeteer
|
|
|
|
|
62 |
|
63 |
# Install Python dependencies
|
64 |
- name: Install Python dependencies
|
@@ -89,6 +91,16 @@ jobs:
|
|
89 |
\usepackage{fancyhdr}
|
90 |
\usepackage{xcolor}
|
91 |
\usepackage{hyperref}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
92 |
|
93 |
% Better image positioning and scaling
|
94 |
\floatplacement{figure}{H}
|
@@ -222,7 +234,7 @@ jobs:
|
|
222 |
}
|
223 |
EOF
|
224 |
|
225 |
-
# Fixed preprocessing script
|
226 |
- name: Create preprocessing script
|
227 |
run: |
|
228 |
cat > preprocess_markdown.py << 'EOF'
|
@@ -254,10 +266,11 @@ jobs:
|
|
254 |
return f'\n```\n{mermaid_code}\n```\n'
|
255 |
|
256 |
try:
|
257 |
-
# Convert to SVG first
|
258 |
result = subprocess.run([
|
259 |
'mmdc', '-i', mermaid_file, '-o', svg_file,
|
260 |
-
'--theme', 'default', '--backgroundColor', 'white'
|
|
|
261 |
], check=True, capture_output=True, text=True)
|
262 |
|
263 |
# Convert SVG to PNG for better PDF compatibility
|
@@ -269,9 +282,6 @@ jobs:
|
|
269 |
# Clean up intermediate files
|
270 |
try:
|
271 |
os.remove(mermaid_file)
|
272 |
-
except:
|
273 |
-
pass
|
274 |
-
try:
|
275 |
if os.path.exists(svg_file):
|
276 |
os.remove(svg_file)
|
277 |
except:
|
@@ -291,7 +301,6 @@ jobs:
|
|
291 |
return f'\n```\n{mermaid_code}\n```\n'
|
292 |
except Exception as e:
|
293 |
print(f"Unexpected error with mermaid: {e}")
|
294 |
-
# Clean up files on error
|
295 |
try:
|
296 |
os.remove(mermaid_file)
|
297 |
except:
|
@@ -300,8 +309,22 @@ jobs:
|
|
300 |
|
301 |
return re.sub(mermaid_pattern, replace_mermaid, content, flags=re.DOTALL)
|
302 |
|
303 |
-
def
|
304 |
-
"""
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
305 |
# Pattern to match markdown images
|
306 |
img_pattern = r'!\[([^\]]*)\]\(([^)]+)\)'
|
307 |
|
@@ -319,7 +342,6 @@ jobs:
|
|
319 |
# Add HTML img tag with better control
|
320 |
return f'<img src="{img_path}" alt="{alt_text}" style="max-width: 100%; height: auto; display: block; margin: 1em auto;" />'
|
321 |
|
322 |
-
# Also handle HTML img tags and ensure they have proper styling
|
323 |
content = re.sub(img_pattern, replace_image, content)
|
324 |
|
325 |
# Fix existing HTML img tags
|
@@ -338,7 +360,6 @@ jobs:
|
|
338 |
|
339 |
md_file = sys.argv[1]
|
340 |
|
341 |
-
# Check if file exists
|
342 |
if not os.path.exists(md_file):
|
343 |
print(f"Error: File {md_file} does not exist")
|
344 |
sys.exit(1)
|
@@ -354,12 +375,11 @@ jobs:
|
|
354 |
print(f"Content length: {len(content)} characters")
|
355 |
|
356 |
# Process mermaid diagrams
|
357 |
-
original_content_length = len(content)
|
358 |
content = process_mermaid_diagrams(content, file_dir)
|
359 |
print(f"Mermaid processing complete. Content length: {len(content)}")
|
360 |
|
361 |
-
#
|
362 |
-
content =
|
363 |
print(f"Image path fixing complete. Content length: {len(content)}")
|
364 |
|
365 |
# Write processed content
|
@@ -368,8 +388,7 @@ jobs:
|
|
368 |
f.write(content)
|
369 |
|
370 |
print(f"Processed file saved as: {processed_file}")
|
371 |
-
print(processed_file)
|
372 |
-
return processed_file
|
373 |
|
374 |
except Exception as e:
|
375 |
print(f"Error processing {md_file}: {e}")
|
|
|
59 |
run: |
|
60 |
npm install -g @mermaid-js/mermaid-cli
|
61 |
npm install -g puppeteer
|
62 |
+
# Set up chrome for mermaid-cli in GitHub Actions
|
63 |
+
sudo apt-get install -y google-chrome-stable
|
64 |
|
65 |
# Install Python dependencies
|
66 |
- name: Install Python dependencies
|
|
|
91 |
\usepackage{fancyhdr}
|
92 |
\usepackage{xcolor}
|
93 |
\usepackage{hyperref}
|
94 |
+
\usepackage{fontspec}
|
95 |
+
\usepackage{unicode-math}
|
96 |
+
|
97 |
+
% Set fonts with emoji support
|
98 |
+
\setmainfont{DejaVu Sans}
|
99 |
+
\setsansfont{DejaVu Sans}
|
100 |
+
\setmonofont{DejaVu Sans Mono}
|
101 |
+
|
102 |
+
% Try to set a font with emoji support as fallback
|
103 |
+
\newfontfamily\emojifont{Apple Color Emoji}[Renderer=Harfbuzz]
|
104 |
|
105 |
% Better image positioning and scaling
|
106 |
\floatplacement{figure}{H}
|
|
|
234 |
}
|
235 |
EOF
|
236 |
|
237 |
+
# Fixed preprocessing script with no-sandbox mermaid
|
238 |
- name: Create preprocessing script
|
239 |
run: |
|
240 |
cat > preprocess_markdown.py << 'EOF'
|
|
|
266 |
return f'\n```\n{mermaid_code}\n```\n'
|
267 |
|
268 |
try:
|
269 |
+
# Convert to SVG first with no-sandbox flags
|
270 |
result = subprocess.run([
|
271 |
'mmdc', '-i', mermaid_file, '-o', svg_file,
|
272 |
+
'--theme', 'default', '--backgroundColor', 'white',
|
273 |
+
'--puppeteerConfig', '{"args": ["--no-sandbox", "--disable-setuid-sandbox", "--disable-dev-shm-usage"]}'
|
274 |
], check=True, capture_output=True, text=True)
|
275 |
|
276 |
# Convert SVG to PNG for better PDF compatibility
|
|
|
282 |
# Clean up intermediate files
|
283 |
try:
|
284 |
os.remove(mermaid_file)
|
|
|
|
|
|
|
285 |
if os.path.exists(svg_file):
|
286 |
os.remove(svg_file)
|
287 |
except:
|
|
|
301 |
return f'\n```\n{mermaid_code}\n```\n'
|
302 |
except Exception as e:
|
303 |
print(f"Unexpected error with mermaid: {e}")
|
|
|
304 |
try:
|
305 |
os.remove(mermaid_file)
|
306 |
except:
|
|
|
309 |
|
310 |
return re.sub(mermaid_pattern, replace_mermaid, content, flags=re.DOTALL)
|
311 |
|
312 |
+
def clean_emojis_and_fix_images(content, file_dir):
|
313 |
+
"""Remove/replace emojis and fix image paths"""
|
314 |
+
# Remove or replace problematic emojis that cause LaTeX issues
|
315 |
+
emoji_replacements = {
|
316 |
+
'π΅': '[Audio]',
|
317 |
+
'π¬': '[Video]',
|
318 |
+
'π': '[Document]',
|
319 |
+
'π': '[Analytics]',
|
320 |
+
'π§ ': '[AI]',
|
321 |
+
'π₯': '[Media]',
|
322 |
+
'π': '[File]'
|
323 |
+
}
|
324 |
+
|
325 |
+
for emoji, replacement in emoji_replacements.items():
|
326 |
+
content = content.replace(emoji, replacement)
|
327 |
+
|
328 |
# Pattern to match markdown images
|
329 |
img_pattern = r'!\[([^\]]*)\]\(([^)]+)\)'
|
330 |
|
|
|
342 |
# Add HTML img tag with better control
|
343 |
return f'<img src="{img_path}" alt="{alt_text}" style="max-width: 100%; height: auto; display: block; margin: 1em auto;" />'
|
344 |
|
|
|
345 |
content = re.sub(img_pattern, replace_image, content)
|
346 |
|
347 |
# Fix existing HTML img tags
|
|
|
360 |
|
361 |
md_file = sys.argv[1]
|
362 |
|
|
|
363 |
if not os.path.exists(md_file):
|
364 |
print(f"Error: File {md_file} does not exist")
|
365 |
sys.exit(1)
|
|
|
375 |
print(f"Content length: {len(content)} characters")
|
376 |
|
377 |
# Process mermaid diagrams
|
|
|
378 |
content = process_mermaid_diagrams(content, file_dir)
|
379 |
print(f"Mermaid processing complete. Content length: {len(content)}")
|
380 |
|
381 |
+
# Clean emojis and fix image paths
|
382 |
+
content = clean_emojis_and_fix_images(content, file_dir)
|
383 |
print(f"Image path fixing complete. Content length: {len(content)}")
|
384 |
|
385 |
# Write processed content
|
|
|
388 |
f.write(content)
|
389 |
|
390 |
print(f"Processed file saved as: {processed_file}")
|
391 |
+
print(processed_file)
|
|
|
392 |
|
393 |
except Exception as e:
|
394 |
print(f"Error processing {md_file}: {e}")
|
.github/workflows/main.yml
CHANGED
@@ -47,6 +47,8 @@ jobs:
|
|
47 |
run: |
|
48 |
npm install -g @mermaid-js/mermaid-cli
|
49 |
npm install -g puppeteer
|
|
|
|
|
50 |
|
51 |
# Install Python dependencies
|
52 |
- name: Install Python dependencies
|
@@ -77,6 +79,16 @@ jobs:
|
|
77 |
\usepackage{fancyhdr}
|
78 |
\usepackage{xcolor}
|
79 |
\usepackage{hyperref}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
80 |
|
81 |
% Better image positioning and scaling
|
82 |
\floatplacement{figure}{H}
|
@@ -210,7 +222,7 @@ jobs:
|
|
210 |
}
|
211 |
EOF
|
212 |
|
213 |
-
# Fixed preprocessing script
|
214 |
- name: Create preprocessing script
|
215 |
run: |
|
216 |
cat > preprocess_markdown.py << 'EOF'
|
@@ -242,10 +254,11 @@ jobs:
|
|
242 |
return f'\n```\n{mermaid_code}\n```\n'
|
243 |
|
244 |
try:
|
245 |
-
# Convert to SVG first
|
246 |
result = subprocess.run([
|
247 |
'mmdc', '-i', mermaid_file, '-o', svg_file,
|
248 |
-
'--theme', 'default', '--backgroundColor', 'white'
|
|
|
249 |
], check=True, capture_output=True, text=True)
|
250 |
|
251 |
# Convert SVG to PNG for better PDF compatibility
|
@@ -257,9 +270,6 @@ jobs:
|
|
257 |
# Clean up intermediate files
|
258 |
try:
|
259 |
os.remove(mermaid_file)
|
260 |
-
except:
|
261 |
-
pass
|
262 |
-
try:
|
263 |
if os.path.exists(svg_file):
|
264 |
os.remove(svg_file)
|
265 |
except:
|
@@ -279,7 +289,6 @@ jobs:
|
|
279 |
return f'\n```\n{mermaid_code}\n```\n'
|
280 |
except Exception as e:
|
281 |
print(f"Unexpected error with mermaid: {e}")
|
282 |
-
# Clean up files on error
|
283 |
try:
|
284 |
os.remove(mermaid_file)
|
285 |
except:
|
@@ -288,8 +297,22 @@ jobs:
|
|
288 |
|
289 |
return re.sub(mermaid_pattern, replace_mermaid, content, flags=re.DOTALL)
|
290 |
|
291 |
-
def
|
292 |
-
"""
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
293 |
# Pattern to match markdown images
|
294 |
img_pattern = r'!\[([^\]]*)\]\(([^)]+)\)'
|
295 |
|
@@ -307,7 +330,6 @@ jobs:
|
|
307 |
# Add HTML img tag with better control
|
308 |
return f'<img src="{img_path}" alt="{alt_text}" style="max-width: 100%; height: auto; display: block; margin: 1em auto;" />'
|
309 |
|
310 |
-
# Also handle HTML img tags and ensure they have proper styling
|
311 |
content = re.sub(img_pattern, replace_image, content)
|
312 |
|
313 |
# Fix existing HTML img tags
|
@@ -326,7 +348,6 @@ jobs:
|
|
326 |
|
327 |
md_file = sys.argv[1]
|
328 |
|
329 |
-
# Check if file exists
|
330 |
if not os.path.exists(md_file):
|
331 |
print(f"Error: File {md_file} does not exist")
|
332 |
sys.exit(1)
|
@@ -342,12 +363,11 @@ jobs:
|
|
342 |
print(f"Content length: {len(content)} characters")
|
343 |
|
344 |
# Process mermaid diagrams
|
345 |
-
original_content_length = len(content)
|
346 |
content = process_mermaid_diagrams(content, file_dir)
|
347 |
print(f"Mermaid processing complete. Content length: {len(content)}")
|
348 |
|
349 |
-
#
|
350 |
-
content =
|
351 |
print(f"Image path fixing complete. Content length: {len(content)}")
|
352 |
|
353 |
# Write processed content
|
@@ -356,8 +376,7 @@ jobs:
|
|
356 |
f.write(content)
|
357 |
|
358 |
print(f"Processed file saved as: {processed_file}")
|
359 |
-
print(processed_file)
|
360 |
-
return processed_file
|
361 |
|
362 |
except Exception as e:
|
363 |
print(f"Error processing {md_file}: {e}")
|
|
|
47 |
run: |
|
48 |
npm install -g @mermaid-js/mermaid-cli
|
49 |
npm install -g puppeteer
|
50 |
+
# Set up chrome for mermaid-cli in GitHub Actions
|
51 |
+
sudo apt-get install -y google-chrome-stable
|
52 |
|
53 |
# Install Python dependencies
|
54 |
- name: Install Python dependencies
|
|
|
79 |
\usepackage{fancyhdr}
|
80 |
\usepackage{xcolor}
|
81 |
\usepackage{hyperref}
|
82 |
+
\usepackage{fontspec}
|
83 |
+
\usepackage{unicode-math}
|
84 |
+
|
85 |
+
% Set fonts with emoji support
|
86 |
+
\setmainfont{DejaVu Sans}
|
87 |
+
\setsansfont{DejaVu Sans}
|
88 |
+
\setmonofont{DejaVu Sans Mono}
|
89 |
+
|
90 |
+
% Try to set a font with emoji support as fallback
|
91 |
+
\newfontfamily\emojifont{Apple Color Emoji}[Renderer=Harfbuzz]
|
92 |
|
93 |
% Better image positioning and scaling
|
94 |
\floatplacement{figure}{H}
|
|
|
222 |
}
|
223 |
EOF
|
224 |
|
225 |
+
# Fixed preprocessing script with no-sandbox mermaid
|
226 |
- name: Create preprocessing script
|
227 |
run: |
|
228 |
cat > preprocess_markdown.py << 'EOF'
|
|
|
254 |
return f'\n```\n{mermaid_code}\n```\n'
|
255 |
|
256 |
try:
|
257 |
+
# Convert to SVG first with no-sandbox flags
|
258 |
result = subprocess.run([
|
259 |
'mmdc', '-i', mermaid_file, '-o', svg_file,
|
260 |
+
'--theme', 'default', '--backgroundColor', 'white',
|
261 |
+
'--puppeteerConfig', '{"args": ["--no-sandbox", "--disable-setuid-sandbox", "--disable-dev-shm-usage"]}'
|
262 |
], check=True, capture_output=True, text=True)
|
263 |
|
264 |
# Convert SVG to PNG for better PDF compatibility
|
|
|
270 |
# Clean up intermediate files
|
271 |
try:
|
272 |
os.remove(mermaid_file)
|
|
|
|
|
|
|
273 |
if os.path.exists(svg_file):
|
274 |
os.remove(svg_file)
|
275 |
except:
|
|
|
289 |
return f'\n```\n{mermaid_code}\n```\n'
|
290 |
except Exception as e:
|
291 |
print(f"Unexpected error with mermaid: {e}")
|
|
|
292 |
try:
|
293 |
os.remove(mermaid_file)
|
294 |
except:
|
|
|
297 |
|
298 |
return re.sub(mermaid_pattern, replace_mermaid, content, flags=re.DOTALL)
|
299 |
|
300 |
+
def clean_emojis_and_fix_images(content, file_dir):
|
301 |
+
"""Remove/replace emojis and fix image paths"""
|
302 |
+
# Remove or replace problematic emojis that cause LaTeX issues
|
303 |
+
emoji_replacements = {
|
304 |
+
'π΅': '[Audio]',
|
305 |
+
'π¬': '[Video]',
|
306 |
+
'π': '[Document]',
|
307 |
+
'π': '[Analytics]',
|
308 |
+
'π§ ': '[AI]',
|
309 |
+
'π₯': '[Media]',
|
310 |
+
'π': '[File]'
|
311 |
+
}
|
312 |
+
|
313 |
+
for emoji, replacement in emoji_replacements.items():
|
314 |
+
content = content.replace(emoji, replacement)
|
315 |
+
|
316 |
# Pattern to match markdown images
|
317 |
img_pattern = r'!\[([^\]]*)\]\(([^)]+)\)'
|
318 |
|
|
|
330 |
# Add HTML img tag with better control
|
331 |
return f'<img src="{img_path}" alt="{alt_text}" style="max-width: 100%; height: auto; display: block; margin: 1em auto;" />'
|
332 |
|
|
|
333 |
content = re.sub(img_pattern, replace_image, content)
|
334 |
|
335 |
# Fix existing HTML img tags
|
|
|
348 |
|
349 |
md_file = sys.argv[1]
|
350 |
|
|
|
351 |
if not os.path.exists(md_file):
|
352 |
print(f"Error: File {md_file} does not exist")
|
353 |
sys.exit(1)
|
|
|
363 |
print(f"Content length: {len(content)} characters")
|
364 |
|
365 |
# Process mermaid diagrams
|
|
|
366 |
content = process_mermaid_diagrams(content, file_dir)
|
367 |
print(f"Mermaid processing complete. Content length: {len(content)}")
|
368 |
|
369 |
+
# Clean emojis and fix image paths
|
370 |
+
content = clean_emojis_and_fix_images(content, file_dir)
|
371 |
print(f"Image path fixing complete. Content length: {len(content)}")
|
372 |
|
373 |
# Write processed content
|
|
|
376 |
f.write(content)
|
377 |
|
378 |
print(f"Processed file saved as: {processed_file}")
|
379 |
+
print(processed_file)
|
|
|
380 |
|
381 |
except Exception as e:
|
382 |
print(f"Error processing {md_file}: {e}")
|