-
Notifications
You must be signed in to change notification settings - Fork 73
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Todo for v0.3.0 #12
Comments
For the stretch goal: I'd like to have a outline/table of contents like in this picture: To make it happen we probably need |
I agree that pages are arbitrary and bookmarks would be great. FWIW, |
function getOffset( el ) {
var _x = 0;
var _y = 0;
while( el && !isNaN( el.offsetLeft ) && !isNaN( el.offsetTop ) ) {
_x += el.offsetLeft - el.scrollLeft;
_y += el.offsetTop - el.scrollTop;
el = el.offsetParent;
}
return { top: _y, left: _x };
} will compute the distance from the top (and left) of an element on a web page. Which we can then use with: for (const elem of document.getElementsByTagName("h1")) {
console.log(elem, getOffset(elem).top, elem.innerText)
} to get the positions of all the H1s on the page. Once we have this information we need to return the position and text from chromium to Python and then call |
This is the Python we need to do this: await page.evaluate("""
function getOffset( el ) {
var _x = 0;
var _y = 0;
while( el && !isNaN( el.offsetLeft ) && !isNaN( el.offsetTop ) ) {
_x += el.offsetLeft - el.scrollLeft;
_y += el.offsetTop - el.scrollTop;
el = el.offsetParent;
}
return { top: _y, left: _x };
}
""", force_expr=True)
h1s = await page.evaluate(
"""() => {
var vals = []
for (const elem of document.getElementsByTagName("h1")) {
console.log(elem, getOffset(elem).top, elem.innerText)
vals.push({ top: getOffset(elem).top, text: elem.innerText })
}
return vals
}"""
) then |
Things to do for v0.3.0
--no-sandbox
the default Failure in gitlab CI #9setup.py
to be 0.3.0 Failure in gitlab CI #9<h1>
tags in the notebookThe text was updated successfully, but these errors were encountered: