Skip to content

Commit 2272417

Browse files
Refactor LaTeX title generation and PDF build process
Updated LaTeX title generation and added handling for special characters. Enhanced directory detection for PDF generation and improved artifact upload paths.
1 parent 09c0bed commit 2272417

1 file changed

Lines changed: 37 additions & 18 deletions

File tree

.github/workflows/build_preprint.yml

Lines changed: 37 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,15 @@ jobs:
2424
run: |
2525
python3 - << 'PYEOF'
2626
import yaml
27+
import os
2728
28-
with open('paper/paper.md', 'r') as f:
29+
# Ensure we are reading the correct path
30+
file_path = 'paper/paper.md'
31+
if not os.path.exists(file_path):
32+
# Fallback for different repo structures
33+
file_path = 'paper.md'
34+
35+
with open(file_path, 'r') as f:
2936
content = f.read()
3037
3138
parts = content.split('---\n')
@@ -50,29 +57,30 @@ jobs:
5057
5158
# 2. Build LaTeX Title Block
5259
lines = [r'\begin{center}']
53-
lines.append(r'{\LARGE\bfseries ' + fm.get('title','') + r'}\\[1.2em]')
60+
lines.append(r'{\LARGE\bfseries ' + fm.get('title','').replace('&', r'\&') + r'}\\[1.2em]')
5461
5562
auth_line = []
5663
for a in authors:
57-
name = a['name']
64+
name = a['name'].replace('&', r'\&')
5865
aff_indices = str(a.get('affiliation', '')).split(',')
5966
marker = ",".join([idx.strip() for idx in aff_indices])
6067
if a.get('corresponding'):
6168
marker += r",*"
6269
auth_line.append(rf'{name}$^{{{marker}}}$')
6370
lines.append(r'\large ' + r', '.join(auth_line) + r'\\[0.8em]')
6471
65-
for idx, aff in aff_map.items():
72+
for idx, aff in sorted(aff_map.items()):
73+
name = aff['name'].replace('&', r'\&')
6674
ror_id = aff.get('ror', '')
67-
# Link ROR IDs for professional institutional verification
6875
ror_link = rf" \small (ROR: \href{{https://ror.org/{ror_id}}}{{{ror_id}}})" if ror_id else ""
69-
lines.append(rf'$^{{{idx}}}$\small {aff["name"]}{ror_link}\\[0.2em]')
76+
lines.append(rf'$^{{{idx}}}$\small {name}{ror_link}\\[0.2em]')
7077
71-
corres = [a['email'] for a in authors if a.get('corresponding') and a.get('email')]
78+
corres = [a for a in authors if a.get('corresponding') and a.get('email')]
7279
if corres:
73-
lines.append(rf'\small $^*$Corresponding author: \href{{mailto:{corres[0]}}}{{{corres[0]}}}\\[0.2em]')
80+
email = corres[0]['email']
81+
lines.append(rf'\small $^*$Corresponding author: \href{{mailto:{email}}}{{{email}}}\\[0.2em]')
7482
75-
# Explicit Zenodo DOI for the PICA suite
83+
# Zenodo DOI Integration
7684
lines.append(r'\small DOI: \href{https://doi.org/10.5281/zenodo.18377216}{10.5281/zenodo.18377216}\\[0.2em]')
7785
lines.append(r'\small ' + str(fm.get('date','')))
7886
lines.append(r'\end{center}')
@@ -85,33 +93,42 @@ jobs:
8593
- name: Create Professional Header
8694
run: |
8795
cat > /tmp/header.tex << 'EOF'
96+
\usepackage{hyperref}
8897
\usepackage{xurl}
8998
\usepackage{fontspec}
9099
\setmainfont{TeX Gyre Termes}
91100
\usepackage{unicode-math}
92101
\setmathfont{TeX Gyre Termes Math}
93102
\usepackage{fancyhdr}
94103
\usepackage{xcolor}
104+
105+
\hypersetup{
106+
breaklinks=true,
107+
colorlinks=true,
108+
linkcolor=blue,
109+
urlcolor=blue,
110+
citecolor=blue,
111+
pdfauthor={Deshmukh and Mukherjee},
112+
pdftitle={PICA: High-Precision Automation}
113+
}
114+
95115
\pagestyle{fancy}
96116
\fancyhf{}
97-
98-
% Clear identification as a preprint while maintaining professional style
99117
\fancyhead[L]{\small \textbf{\textcolor{gray}{PREPRINT -- NOT PEER REVIEWED}}}
100118
\fancyhead[R]{\small \textit{PICA: Advanced Transport Automation}}
101119
\fancyfoot[C]{\thepage}
102120
\renewcommand{\headrulewidth}{0.4pt}
103121
104122
\renewcommand{\maketitle}{}
105-
\hypersetup{
106-
breaklinks=true,
107-
pdfauthor={Deshmukh and Mukherjee},
108-
pdftitle={PICA: High-Precision Automation}
109-
}
110123
EOF
111124
112125
- name: Generate Publication-Ready PDF
113126
run: |
114-
cd paper
127+
# Detect directory
128+
TARGET_DIR="paper"
129+
if [ ! -d "$TARGET_DIR" ]; then TARGET_DIR="."; fi
130+
cd $TARGET_DIR
131+
115132
pandoc paper.md -o paper.pdf \
116133
--standalone \
117134
--citeproc \
@@ -125,4 +142,6 @@ jobs:
125142
uses: actions/upload-artifact@v4
126143
with:
127144
name: professional-preprint
128-
path: paper/paper.pdf
145+
path: |
146+
paper/paper.pdf
147+
paper.pdf

0 commit comments

Comments
 (0)