Prathamesh Sarjerao Vaidya
commited on
Commit
·
f9a6740
1
Parent(s):
da95057
made changes again
Browse files
.github/workflows/scripts/latex-header.tex
CHANGED
|
@@ -3,7 +3,6 @@
|
|
| 3 |
\usepackage{adjustbox}
|
| 4 |
\usepackage{caption}
|
| 5 |
\usepackage{subcaption}
|
| 6 |
-
% \usepackage[top=0.5in,left=0.5in,right=0.5in,bottom=0.5in]{geometry}
|
| 7 |
\usepackage[a4paper,top=2.25cm,bottom=2.25cm,left=1.9cm,right=1.9cm]{geometry}
|
| 8 |
\usepackage{fancyhdr}
|
| 9 |
\usepackage{xcolor}
|
|
|
|
| 3 |
\usepackage{adjustbox}
|
| 4 |
\usepackage{caption}
|
| 5 |
\usepackage{subcaption}
|
|
|
|
| 6 |
\usepackage[a4paper,top=2.25cm,bottom=2.25cm,left=1.9cm,right=1.9cm]{geometry}
|
| 7 |
\usepackage{fancyhdr}
|
| 8 |
\usepackage{xcolor}
|
.github/workflows/scripts/preprocess_markdown.py
CHANGED
|
@@ -26,12 +26,20 @@ def process_mermaid_diagrams(content, file_dir):
|
|
| 26 |
return f'\n```\n{mermaid_code}\n```\n'
|
| 27 |
|
| 28 |
try:
|
| 29 |
-
#
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 35 |
|
| 36 |
# Convert SVG to PNG for better PDF compatibility
|
| 37 |
subprocess.run([
|
|
@@ -57,11 +65,41 @@ def process_mermaid_diagrams(content, file_dir):
|
|
| 57 |
except subprocess.CalledProcessError as e:
|
| 58 |
print(f"Error converting mermaid diagram: {e}")
|
| 59 |
print(f"Command output: {e.stderr if e.stderr else 'No stderr'}")
|
|
|
|
|
|
|
| 60 |
try:
|
| 61 |
-
|
| 62 |
-
|
| 63 |
-
|
| 64 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 65 |
|
| 66 |
except Exception as e:
|
| 67 |
print(f"Unexpected error with mermaid: {e}")
|
|
|
|
| 26 |
return f'\n```\n{mermaid_code}\n```\n'
|
| 27 |
|
| 28 |
try:
|
| 29 |
+
# Method 1: Try with config file (newer versions)
|
| 30 |
+
config_file = os.path.join(file_dir, '..', '..', '.github', 'workflows', 'puppeteer-config.json')
|
| 31 |
+
if os.path.exists(config_file):
|
| 32 |
+
result = subprocess.run([
|
| 33 |
+
'mmdc', '-i', mermaid_file, '-o', svg_file,
|
| 34 |
+
'--theme', 'default', '--backgroundColor', 'white',
|
| 35 |
+
'--configFile', config_file
|
| 36 |
+
], check=True, capture_output=True, text=True)
|
| 37 |
+
else:
|
| 38 |
+
# Method 2: Try without puppeteer config (fallback)
|
| 39 |
+
result = subprocess.run([
|
| 40 |
+
'mmdc', '-i', mermaid_file, '-o', svg_file,
|
| 41 |
+
'--theme', 'default', '--backgroundColor', 'white'
|
| 42 |
+
], check=True, capture_output=True, text=True)
|
| 43 |
|
| 44 |
# Convert SVG to PNG for better PDF compatibility
|
| 45 |
subprocess.run([
|
|
|
|
| 65 |
except subprocess.CalledProcessError as e:
|
| 66 |
print(f"Error converting mermaid diagram: {e}")
|
| 67 |
print(f"Command output: {e.stderr if e.stderr else 'No stderr'}")
|
| 68 |
+
|
| 69 |
+
# Fallback: Try basic mmdc command without any config
|
| 70 |
try:
|
| 71 |
+
print("Trying basic mmdc command...")
|
| 72 |
+
subprocess.run([
|
| 73 |
+
'mmdc', '-i', mermaid_file, '-o', svg_file
|
| 74 |
+
], check=True, capture_output=True, text=True)
|
| 75 |
+
|
| 76 |
+
# Convert to PNG
|
| 77 |
+
subprocess.run([
|
| 78 |
+
'rsvg-convert', '-f', 'png', '-o', png_file,
|
| 79 |
+
'--width', '1200', '--height', '800', svg_file
|
| 80 |
+
], check=True, capture_output=True, text=True)
|
| 81 |
+
|
| 82 |
+
# Clean up
|
| 83 |
+
try:
|
| 84 |
+
os.remove(mermaid_file)
|
| 85 |
+
if os.path.exists(svg_file):
|
| 86 |
+
os.remove(svg_file)
|
| 87 |
+
except:
|
| 88 |
+
pass
|
| 89 |
+
|
| 90 |
+
return (
|
| 91 |
+
f'\n<div class="mermaid-container">\n\n'
|
| 92 |
+
f'})\n\n'
|
| 93 |
+
f'</div>\n'
|
| 94 |
+
)
|
| 95 |
+
|
| 96 |
+
except subprocess.CalledProcessError as e2:
|
| 97 |
+
print(f"Basic mmdc also failed: {e2}")
|
| 98 |
+
try:
|
| 99 |
+
os.remove(mermaid_file)
|
| 100 |
+
except:
|
| 101 |
+
pass
|
| 102 |
+
return f'\n```\n{mermaid_code}\n```\n'
|
| 103 |
|
| 104 |
except Exception as e:
|
| 105 |
print(f"Unexpected error with mermaid: {e}")
|
.github/workflows/scripts/setup_system.sh
CHANGED
|
@@ -17,7 +17,7 @@ sudo apt-get install -y \
|
|
| 17 |
wkhtmltopdf
|
| 18 |
|
| 19 |
echo "Installing Node.js dependencies for Mermaid..."
|
| 20 |
-
npm install -g @mermaid-js/mermaid-cli
|
| 21 |
npm install -g puppeteer
|
| 22 |
sudo apt-get install -y google-chrome-stable
|
| 23 |
|
|
|
|
| 17 |
wkhtmltopdf
|
| 18 |
|
| 19 |
echo "Installing Node.js dependencies for Mermaid..."
|
| 20 |
+
npm install -g @mermaid-js/mermaid-cli@latest
|
| 21 |
npm install -g puppeteer
|
| 22 |
sudo apt-get install -y google-chrome-stable
|
| 23 |
|