mirror of
https://github.com/Juicysteak117/pghrt.git
synced 2025-12-21 15:35:25 +00:00
adding chain permalinks
This commit is contained in:
2
.gitignore
vendored
2
.gitignore
vendored
@@ -8,3 +8,5 @@
|
||||
*.toc
|
||||
LaTeXML.css
|
||||
ltx-article.css
|
||||
test.py
|
||||
test.html
|
||||
File diff suppressed because it is too large
Load Diff
2585
export/pghrt.pdf
2585
export/pghrt.pdf
File diff suppressed because it is too large
Load Diff
@@ -20,8 +20,9 @@
|
||||
|
||||
body {
|
||||
font-family: 'crm';
|
||||
padding: 0 0px 0 0; margin: 0;
|
||||
font-size: 17px;
|
||||
padding: 0 0px 0 0;
|
||||
margin: 0;
|
||||
font-size: 17px;
|
||||
}
|
||||
|
||||
.ltx_TOC a:link, .ltx_TOC a:visited, .ltx_p a:link, .ltx_p a:visited { color: blue !important; }
|
||||
@@ -71,6 +72,12 @@ font-size: 17px;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.chain {
|
||||
text-decoration:none;
|
||||
font-size: 80%;
|
||||
margin-left: 0.5em;
|
||||
}
|
||||
|
||||
/*side bar*/
|
||||
ol[class="ltx_toclist ltx_toclist_section"]{
|
||||
max-height: 0;
|
||||
@@ -112,6 +119,50 @@ font-family: serif;
|
||||
content: "" !important;
|
||||
}
|
||||
|
||||
/* i'm just copying this shit from w3schools ngl */
|
||||
|
||||
#snackbar {
|
||||
visibility: hidden;
|
||||
min-width: 250px;
|
||||
margin-left: -125px;
|
||||
background-color: #333;
|
||||
color: #fff;
|
||||
text-align: center;
|
||||
border-radius: 2px;
|
||||
padding: 16px;
|
||||
position: fixed;
|
||||
z-index: 1;
|
||||
left: 50%;
|
||||
bottom: 30px;
|
||||
font-size: 17px;
|
||||
}
|
||||
|
||||
#snackbar.show {
|
||||
visibility: visible;
|
||||
-webkit-animation: fadein 0.5s, fadeout 0.5s 2.5s;
|
||||
animation: fadein 0.5s, fadeout 0.5s 2.5s;
|
||||
}
|
||||
|
||||
@-webkit-keyframes fadein {
|
||||
from {bottom: 0; opacity: 0;}
|
||||
to {bottom: 30px; opacity: 1;}
|
||||
}
|
||||
|
||||
@keyframes fadein {
|
||||
from {bottom: 0; opacity: 0;}
|
||||
to {bottom: 30px; opacity: 1;}
|
||||
}
|
||||
|
||||
@-webkit-keyframes fadeout {
|
||||
from {bottom: 30px; opacity: 1;}
|
||||
to {bottom: 0; opacity: 0;}
|
||||
}
|
||||
|
||||
@keyframes fadeout {
|
||||
from {bottom: 30px; opacity: 1;}
|
||||
to {bottom: 0; opacity: 0;}
|
||||
}
|
||||
|
||||
@media screen AND (max-width:1000px) {
|
||||
.ltx_TOC { width: 0; visibility: hidden; top: 5vh; }
|
||||
#menu { display: block; width: 100%; padding: 0; border-radius: 0; border-top: none; border-left: none; border-right: none;}
|
||||
|
||||
@@ -17,3 +17,17 @@ for (i = 0; i < coll.length; i++) {
|
||||
coll[i].classList.add("del");
|
||||
}
|
||||
}
|
||||
|
||||
function copyURI(evt) {
|
||||
evt.preventDefault();
|
||||
/* ensures url is without hash, then add on correct hash */
|
||||
navigator.clipboard.writeText(window.location.href.replace(window.location.hash,'') + evt.target.getAttribute('href')).then(() => {
|
||||
/* clipboard successfully set */
|
||||
}, () => {
|
||||
/* clipboard write failed */
|
||||
});
|
||||
/* silly little toast */
|
||||
var x = document.getElementById("snackbar");
|
||||
x.className = "show";
|
||||
setTimeout(function(){ x.className = x.className.replace("show", ""); }, 2000);
|
||||
}
|
||||
@@ -1329,4 +1329,6 @@ Shout out to my IB Chemistry HL teacher many years ago who quite reasonably doub
|
||||
|
||||
\noindent 2025-10-10: Added Gretchen's Version (.txt) and fixed formatting. 19.5k words.
|
||||
|
||||
\noindent 2025-10-11: Added
|
||||
|
||||
\end{document}
|
||||
33
soup.py
33
soup.py
@@ -1,5 +1,4 @@
|
||||
#!/usr/bin/env python3
|
||||
#source: @jonesetc.com ty king
|
||||
#source: @jonesetc.com ty king you're an icon
|
||||
from bs4 import BeautifulSoup
|
||||
|
||||
# Parse the file into soup
|
||||
@@ -19,10 +18,17 @@ header.append(menu)
|
||||
# Extract nav
|
||||
toc = soup.body.find('div', class_='ltx_page_main').nav.extract()
|
||||
|
||||
# Prepend header and toc into body
|
||||
soup.body.insert(0, header, toc)
|
||||
# adding a toast
|
||||
toast = soup.new_tag (
|
||||
"div",
|
||||
id="snackbar",
|
||||
string="Link Copied!"
|
||||
)
|
||||
|
||||
# Add header info
|
||||
# Prepend header and toc into body
|
||||
soup.body.insert(0, toast, header, toc)
|
||||
|
||||
# Add header info tags
|
||||
|
||||
head_meta = soup.new_tag(
|
||||
'meta',
|
||||
@@ -91,6 +97,23 @@ head_meta = soup.new_tag(
|
||||
soup.head.append(head_meta)
|
||||
soup.head.append("\n")
|
||||
|
||||
# find all the section and question headers then add a click to copy
|
||||
for element in soup.find_all(["h2", "h3"]):
|
||||
#find the id of its section
|
||||
hash = element.parent['id']
|
||||
|
||||
new_chain = soup.new_tag(
|
||||
'a',
|
||||
**{'class':'ltx_ref chain'},
|
||||
href="#" + hash,
|
||||
title="Click to copy a link here",
|
||||
onclick="copyURI(event)",
|
||||
string='🔗',
|
||||
)
|
||||
|
||||
element.append(new_chain)
|
||||
|
||||
|
||||
print("soup")
|
||||
|
||||
# Write the updated soup back out to the file
|
||||
|
||||
Reference in New Issue
Block a user