Skip to content

Commit bc3e21b

Browse files
committed
Fix: correctly identify section for RST books
1 parent a50d6be commit bc3e21b

1 file changed

Lines changed: 12 additions & 5 deletions

File tree

bases/rsptx/interactives/runestone/common/js/bookfuncs.js

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -716,12 +716,19 @@ function createStudyCluesWidget() {
716716
if (!query) {
717717
return;
718718
}
719-
719+
var sectionInfo = "this page";
720720
// find the section title on the page to include in the initial query
721-
let section = document.querySelector('section.section');
722-
let sectionTitle = section.querySelector('span.title').innerText;
723-
let sectionNumber = section.querySelector('span.codenumber').innerText;
724-
let sectionInfo = `${sectionNumber} ${sectionTitle}`;
721+
if (document.querySelector("body.pretext")) {
722+
let section = document.querySelector('section.section');
723+
let sectionTitle = section.querySelector('span.title').innerText;
724+
let sectionNumber = section.querySelector('span.codenumber').innerText;
725+
sectionInfo = `${sectionNumber} ${sectionTitle}`;
726+
} else {
727+
let sectionSpan = document.querySelector("span.section-number");
728+
if (sectionSpan) {
729+
sectionInfo = sectionSpan.parentElement.innerText.trim();
730+
}
731+
}
725732
if (studyCluesConversationId === -1) {
726733
query = `Regarding section "${sectionInfo}": ${query}`;
727734
}

0 commit comments

Comments
 (0)