File tree Expand file tree Collapse file tree 1 file changed +5
-2
lines changed Expand file tree Collapse file tree 1 file changed +5
-2
lines changed Original file line number Diff line number Diff line change 6
6
7
7
echo " Adding notebook download links to HTML pages..."
8
8
9
+ # Link text variable
10
+ LINK_TEXT=" Download notebook"
11
+
9
12
# Find all HTML files that have corresponding .ipynb files
10
13
find _site/tutorials _site/usage _site/developers -name " index.html" 2> /dev/null | while read html_file; do
11
14
dir=$( dirname " $html_file " )
@@ -14,11 +17,11 @@ find _site/tutorials _site/usage _site/developers -name "index.html" 2>/dev/null
14
17
# Check if the corresponding .ipynb file exists
15
18
if [ -f " $ipynb_file " ]; then
16
19
# Check if link is already present
17
- if ! grep -q ' Download notebook ' " $html_file " ; then
20
+ if ! grep -q " $LINK_TEXT " " $html_file " ; then
18
21
# Insert the notebook link AFTER the "Report an issue" link
19
22
# This ensures it goes in the right place in the sidebar toc-actions
20
23
# The download="index.ipynb" attribute forces browser to download instead of navigate
21
- perl -i -pe ' s/(<a href="[^"]*issues\/new"[^>]*><i class="bi[^"]*"><\/i>Report an issue<\/a><\/li>)/$1<li><a href="index.ipynb" class="toc-action" download="index.ipynb"><i class="bi bi-journal-code"><\/i>Download notebook <\/a><\/li>/g' " $html_file "
24
+ perl -i -pe " s/(<a href=\ " [^\ " ]*issues\/new\ " [^>]*><i class=\ " bi[^\ " ]*\ " ><\/i>Report an issue<\/a><\/li>)/\ $ 1<li><a href=\ " index.ipynb\ " class=\ " toc-action\ " download=\ " index.ipynb\ " ><i class=\ " bi bi-journal-code\ " ><\/i>$LINK_TEXT <\/a><\/li>/g" " $html_file "
22
25
echo " ✓ Added notebook link to $html_file "
23
26
fi
24
27
fi
You can’t perform that action at this time.
0 commit comments