On 11/28/22 13:28, Gavin Smith wrote:
The indices go to the right place and they update the entries, but the
index text is wrong now: for example, in the Texinfo manual, type in
"author" and there is nothing, but type in "@title" and
"@title @subtitle @author" is suggested, because there is an
index entry with that node as its target.
Could you try the attached patch?
I also implemented sub-entry handling while I was in that area.
Optionally, I suggest a wider width for the text-entr box - see the info.css
part of the patch.
--
--Per Bothner
p...@bothner.com http://per.bothner.com/
diff --git a/js/info.css b/js/info.css
index 72f46a3948..ac0e596484 100644
--- a/js/info.css
+++ b/js/info.css
@@ -230,6 +230,10 @@ table#keyboard-shortcuts th {
right: 0;
}
+.text-input input {
+ width: 25em;
+}
+
.error {
background-color: orange;
padding: 5px;
diff --git a/js/info.js b/js/info.js
index bf555bcf9d..7ff7ced161 100644
--- a/js/info.js
+++ b/js/info.js
@@ -146,10 +146,30 @@
/** @arg {NodeListOf<Element>} links */
cache_index_links: function (links) {
var dict = {};
+ var text0 = "", text1 = ""; // for subentries
for (var i = 0; i < links.length; i += 1)
{
var link = links[i];
- dict[link.textContent] = href_hash (link_href (link));
+ var link_cl = link.classList;
+ var text = link.textContent;
+ if (link_cl.contains("index-entry-level-2"))
+ {
+ text = text0 + ", " + text1 + ", " + text;
+ }
+ else if (link_cl.contains("index-entry-level-1"))
+ {
+ text1 = text;
+ text = text0 + ", " + text;
+ }
+ else
+ {
+ text0 = text;
+ }
+ var sec_link = link.nextSibling
+ && link.nextSibling.classList.contains("printindex-index-section")
+ && link.nextSibling.firstChild;
+ if (sec_link)
+ dict[text] = href_hash (link_href (sec_link));
}
return { type: "cache-index-links", links: dict };
},
@@ -1457,9 +1477,9 @@
if (linkid_contains_index (linkid))
{
/* Scan links that should be added to the index. */
- var index_links = document.querySelectorAll
- ("td.printindex-index-section a");
- store.dispatch (actions.cache_index_links (index_links));
+ var index_entries = document.querySelectorAll
+ ("td.printindex-index-entry");
+ store.dispatch (actions.cache_index_links (index_entries));
}
add_icons ();