File tree Expand file tree Collapse file tree 1 file changed +3
-6
lines changed Expand file tree Collapse file tree 1 file changed +3
-6
lines changed Original file line number Diff line number Diff line change @@ -14,12 +14,9 @@ find _site/tutorials _site/usage _site/developers -name "index.html" 2>/dev/null
1414 # Check if the corresponding .ipynb file exists
1515 if [ -f " $ipynb_file " ]; then
1616 # Check if link is already present
17- if ! grep -q ' format-links.*ipynb' " $html_file " ; then
18- # Add download link near the top of the content
19- # This uses sed to insert a link after the main article/content div opens
20- sed -i ' ' ' /<main class="content"/a\
21- <div class="quarto-alternate-formats"><h2>Other Formats</h2><ul><li><a href="index.ipynb"><i class="bi bi-journal-code"></i>Jupyter</a></li></ul></div>
22- ' " $html_file "
17+ if ! grep -q ' quarto-alternate-formats' " $html_file " ; then
18+ # Use perl for portable in-place editing (works on both Linux and macOS)
19+ perl -i -pe ' BEGIN{undef $/;} s/(<main class="content"[^>]*>)/$1\n<div class="quarto-alternate-formats"><h2>Other Formats<\/h2><ul><li><a href="index.ipynb"><i class="bi bi-journal-code"><\/i>Jupyter<\/a><\/li><\/ul><\/div>\n/sm' " $html_file "
2320 echo " ✓ Added notebook link to $html_file "
2421 fi
2522 fi
You can’t perform that action at this time.
0 commit comments