openlibrary icon indicating copy to clipboard operation
openlibrary copied to clipboard

TOC cannot handle archive.org page URL parameters

Open JeffKaplan opened this issue 7 years ago • 2 comments

trying to create links in OL TOC it seems that it cannot handle the URL parameter on archive.org. e.g. chapter one is at but using n11 in OL does not create a link.

JeffKaplan avatar May 22 '19 16:05 JeffKaplan

@JeffKaplan Do you mean that editing the the table of contents at archive.org is the problem. Or are you referring to Open Library's edit form?

xayhewalo avatar Nov 12 '19 21:11 xayhewalo

Hi, can I take this one?

It's still a problem. A TOC entry only becomes a link when the page number is all digits (chapter.pagenum.isdigit() in openlibrary/macros/TableOfContents.html, and the same check in SearchResultsWork.html). Archive.org uses page numbers like n11 in its URLs (/page/n11), so those never get a link.

Plan:

  • add a small helper that accepts a plain number or n + number
  • use it in both macros
  • add tests for the helper

One question: should I also allow roman numerals like xii, or keep it to numbers and n numbers for now? @cdrini

Animesh-Jantwal avatar Oct 29 '26 09:10 Animesh-Jantwal