Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Nov 14, 2025

Addresses code review feedback requesting documentation for the ISBN conversion logic in books.html.

Changes

Added inline comments explaining:

  • ISBN-10 to ISBN-13 conversion: Why we prepend '978' (bookland EAN prefix) and the EAN-13 check digit algorithm (alternating weights 1/3, modulo 10)
  • ISBN-13 to ISBN-10 conversion: Modulo 11 algorithm with descending position weights (10→2), special handling for 'X' (represents 10) and remainder edge cases
  • Context on standards: ISBN-13 is the modern replacement for ISBN-10; '979' prefix ISBNs have no ISBN-10 equivalent

Example

// Calculate EAN-13 check digit using the standard algorithm:
// Sum all digits, alternating between weight 1 (even positions) and weight 3 (odd positions)
// The check digit is the number needed to make the total sum a multiple of 10
let sum = 0;
for (let i = 0; i < 12; i++) {
    const d = parseInt(core[i], 10);
    sum += (i % 2 === 0) ? d : d * 3;  // Even index = weight 1, odd index = weight 3
}
const check = (10 - (sum % 10)) % 10;

Documented ISBN conversion functions


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Co-authored-by: arjun7965 <15646612+arjun7965@users.noreply.github.com>
Copilot AI changed the title [WIP] Update to address feedback on enhancements for dark mode and books page Add inline documentation to ISBN conversion algorithms Nov 14, 2025
Copilot AI requested a review from arjun7965 November 14, 2025 06:16
@arjun7965 arjun7965 marked this pull request as ready for review November 14, 2025 06:16
@arjun7965 arjun7965 merged commit bd78d65 into basic_html Nov 14, 2025
@arjun7965 arjun7965 deleted the copilot/sub-pr-1 branch November 14, 2025 06:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants