Add complete Kobo highlight sync system with NickelMenu integration
- Add text cleaning to remove page reference numbers (e.g., "10After" -> "After") - Implement cleanHighlightText() function with boundary detection - Add NickelMenu configuration for UI integration - Create sync wrapper scripts (with and without FBInk notifications) - Add installation guides for Kobo deployment - Include pointer/slice explanation examples for learning Features: - Extracts highlights from Kobo SQLite database - Cleans page references from academic texts - Computes SHA-256 hashes for deduplication - POSTs JSON to Flask API endpoint - Supports ARM static linking for Kobo hardware - Optional FBInk notifications for user feedback 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
const std = @import("std");
|
||||
|
||||
pub fn main() !void {
|
||||
// Example showing the conversion steps
|
||||
|
||||
// Step 1: SQLite gives us this type (simplified)
|
||||
const sqlite_ptr: ?*const u8 = "hello";
|
||||
|
||||
// Step 2: Check if it's not null
|
||||
if (sqlite_ptr != null) {
|
||||
// Step 3: Cast to sentinel-terminated pointer
|
||||
// @as(TargetType, value) - explicit type conversion
|
||||
// [*:0]const u8 - pointer to many u8s, terminated by 0
|
||||
const sentinel_ptr = @as([*:0]const u8, @ptrCast(sqlite_ptr));
|
||||
|
||||
// Step 4: Convert sentinel pointer to slice
|
||||
// std.mem.span finds the 0 terminator and creates a slice
|
||||
const slice: []const u8 = std.mem.span(sentinel_ptr);
|
||||
|
||||
std.debug.print("Slice: {s}, Length: {}\n", .{slice, slice.len});
|
||||
}
|
||||
|
||||
// The one-liner version from our code:
|
||||
const text = if (sqlite_ptr != null)
|
||||
std.mem.span(@as([*:0]const u8, @ptrCast(sqlite_ptr)))
|
||||
else
|
||||
"";
|
||||
}
|
||||
Reference in New Issue
Block a user