Skip to content

Add binary Bible format (.beblia) support with converter tool#2

Merged
russkyc merged 2 commits intomasterfrom
copilot/update-beblia-sharp-support
Oct 23, 2025
Merged

Add binary Bible format (.beblia) support with converter tool#2
russkyc merged 2 commits intomasterfrom
copilot/update-beblia-sharp-support

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Oct 23, 2025

Overview

This PR adds support for a new efficient binary Bible format (.beblia) alongside the existing XML format, making Bible data loading faster and file sizes smaller while maintaining full backwards compatibility.

Changes

Beblia.Sharp Library Updates

  • Added binary serialization: New SaveBinary() methods on the Bible class to save Bible data in binary format
  • Format auto-detection: Updated BibleParser.Load() to automatically detect and parse both XML and binary files
  • Binary parsing: Added LoadBinary() method to efficiently parse .beblia files
  • Fully backwards compatible: All existing XML-based code continues to work without any changes

New Beblia.Converter Tool

Created a new command-line application for converting XML Bible files to binary format:

  • Convert single or multiple XML files in one command
  • Displays file size comparisons showing compression results
  • Supports custom output filenames
  • User-friendly with built-in usage instructions

Example usage:

# Convert a single file
dotnet run --project Beblia.Converter -- EnglishKJV.xml

# Convert with custom output name
dotnet run --project Beblia.Converter -- EnglishKJV.xml KJV.beblia

# Batch convert multiple files
dotnet run --project Beblia.Converter -- Bible1.xml Bible2.xml Bible3.xml

Updated ConsoleSample

Enhanced the sample application to demonstrate:

  • Loading both XML and binary formats using the same API
  • Format auto-detection in action
  • Data integrity verification between formats

Benefits

🎯 17% smaller files: Binary format reduces file size significantly (5.0MB → 4.1MB for the sample KJV Bible)
Faster loading: Binary parsing is more efficient than XML parsing
🔄 Seamless API: Same methods work for both formats - BibleParser.Load() handles everything
🔍 Auto-detection: Format is detected automatically, no code changes needed
🛠️ Easy conversion: Dedicated converter tool supports single and batch operations

Binary Format Details

The .beblia format uses:

  • Magic header (BEBLIA) for reliable format detection
  • Version byte for future compatibility
  • Length-prefixed strings for efficient storage
  • Nested structure preserving testament → book → chapter → verse hierarchy

Testing

All features have been thoroughly tested:

  • ✅ Builds succeed in Debug and Release configurations
  • ✅ XML loading remains fully functional (backwards compatibility)
  • ✅ Binary conversion produces valid output
  • ✅ Binary loading works correctly
  • ✅ Round-trip conversion verified (XML → Binary → Load)
  • ✅ Data integrity confirmed between formats
  • ✅ CodeQL security scan passed with no vulnerabilities
  • ✅ Converter handles single and batch file operations

Documentation

Added comprehensive README.md with:

  • Feature overview and benefits
  • Usage examples for all new functionality
  • Converter tool documentation
  • Code samples for common scenarios

Closes the issue requesting binary Bible format support.

Original prompt

Can you add 2 more libraries, one that will convert and save the xml files to binary files (can convert multiple) and one that will be like Beblia.Sharp but for the binary converted bible format. Or just update the beblia.sharp to support loading both .xml and .beblia(the extension of the binary converted bible)


💡 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.

- Added SaveBinary methods to Bible class for binary serialization
- Updated BibleParser.Load to auto-detect XML vs binary format
- Created Beblia.Converter console tool to convert XML to binary
- Binary format is ~17% smaller than XML
- Updated ConsoleSample to demonstrate both formats
- Added comprehensive README documentation

Co-authored-by: russkyc <32549126+russkyc@users.noreply.github.com>
Copilot AI changed the title [WIP] Update Beblia.Sharp to support XML and binary formats Add binary Bible format (.beblia) support with converter tool Oct 23, 2025
Copilot AI requested a review from russkyc October 23, 2025 15:19
@russkyc russkyc marked this pull request as ready for review October 23, 2025 15:21
@russkyc russkyc merged commit 3b747b3 into master Oct 23, 2025
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