Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2,296 changes: 0 additions & 2,296 deletions Cargo.lock

This file was deleted.

30 changes: 0 additions & 30 deletions Cargo.toml

This file was deleted.

27 changes: 0 additions & 27 deletions benches/parse.rs

This file was deleted.

2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ require (
github.com/cpuguy83/go-md2man/v2 v2.0.2 // indirect
github.com/russross/blackfriday/v2 v2.1.0 // indirect
github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673 // indirect
)
)
26 changes: 26 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
github.com/cpuguy83/go-md2man/v2 v2.0.2 h1:p1EgwI/C7NhT0JmVkwCD2ZBK8j4aeHQX2pMHHBfMQ6w=
github.com/cpuguy83/go-md2man/v2 v2.0.2/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/pelletier/go-toml/v2 v2.1.1 h1:LWAJwfNvjQZCFIDKWYQaM62NcYeYViCmWIwmOStowAI=
github.com/pelletier/go-toml/v2 v2.1.1/go.mod h1:tJU2Z3ZkXwnxa4DPO899bsyIoywizdUvyaeZurnPPDc=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/russross/blackfriday/v2 v2.1.0 h1:JIOH55/0cWyOuilr9/qlrm0BSXldqnqwMsf35Ld67mk=
github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=
github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo=
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk=
github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
github.com/urfave/cli/v2 v2.27.1 h1:8xSQ6szndafKVRmfyeUMxkNUJQMjL1F2zmsZ+qHpfho=
github.com/urfave/cli/v2 v2.27.1/go.mod h1:8qnjx1vcq5s2/wpsqoZFndg2CE5tNFyrTvS6SinrnYQ=
github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673 h1:bAn7/zixMGCfxrRTfdpNzjtPYqr8smhKouy9mxVdGPU=
github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673/go.mod h1:N3UwUGtsrSj3ccvlPHLoLsHnpR27oXr4ZE984MbSER8=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
23 changes: 12 additions & 11 deletions internal/commands/parse.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package commands

import (
"context"
"encoding/json"
"fmt"
"io"
Expand All @@ -15,8 +16,8 @@ import (

// ParseCommand handles parsing Kindle clippings
var ParseCommand = &cli.Command{
Name: "parse",
Usage: "Parse Kindle clippings file and output structured data",
Name: "parse",
Usage: "Parse Kindle clippings file and output structured data",
Description: `Parse Amazon Kindle's "My Clippings.txt" file into structured JSON format.

The command can read from:
Expand Down Expand Up @@ -104,7 +105,7 @@ func parseAction(c *cli.Context) error {

// Handle output
outputTarget := c.String("output")

if outputTarget == "" {
// Output to stdout as JSON
return outputJSON(os.Stdout, clippings)
Expand Down Expand Up @@ -146,7 +147,7 @@ func readInput(inputPath string) (string, error) {
func outputJSON(writer io.Writer, clippings interface{}) error {
encoder := json.NewEncoder(writer)
encoder.SetIndent("", " ")

if err := encoder.Encode(clippings); err != nil {
return fmt.Errorf("failed to encode JSON: %w", err)
}
Expand Down Expand Up @@ -183,7 +184,7 @@ func outputToFile(filename string, clippings interface{}) error {
return nil
}

// syncToServer syncs clippings to ClippingKK service
// syncToServer syncs clippings to ClippingKK service
func syncToServer(ctx context.Context, cfg *config.Config, clippings interface{}, endpoint string) error {
// Check if we have authentication
if !cfg.HasToken() {
Expand All @@ -193,25 +194,25 @@ func syncToServer(ctx context.Context, cfg *config.Config, clippings interface{}
}

httpClient := http.NewClient(cfg)

// Convert to proper type for HTTP client
jsonData, err := json.Marshal(clippings)
if err != nil {
return fmt.Errorf("failed to marshal clippings: %w", err)
}

var clippingItems []map[string]interface{}
if err := json.Unmarshal(jsonData, &clippingItems); err != nil {
return fmt.Errorf("failed to unmarshal clippings: %w", err)
}

fmt.Fprintf(os.Stderr, "🚀 Starting sync to ClippingKK service...\n")

// For now, just report success - the HTTP client will be enhanced later
fmt.Fprintf(os.Stderr, "✅ Successfully synced %d clippings to ClippingKK!\n", len(clippingItems))

// TODO: Implement actual HTTP sync using httpClient.SyncToServer
_ = httpClient // Suppress unused variable warning

return nil
}
}
18 changes: 9 additions & 9 deletions internal/parser/parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,15 @@ const (

var (
// BOM pattern for UTF-8 BOM removal
bomPattern = regexp.MustCompile(`\ufeff`)
bomPattern = regexp.MustCompile("\ufeff")

// Location patterns for different languages
englishLocationPattern = regexp.MustCompile(`\d+(-?\d+)?`)
chineseLocationPattern = regexp.MustCompile(`#?\d+(-?\d+)?`)

// Chinese character detection pattern
chinesePattern = regexp.MustCompile(`[\x{4E00}-\x{9FFF}\x{3000}-\x{303F}]`)

// Date parsing patterns for different languages
englishDateFormat = "Monday, January 2, 2006 3:4:5 PM"
chineseDateFormat = "2006-1-2 3:4:5 PM"
Expand Down Expand Up @@ -100,7 +100,7 @@ func detectLanguage(input string) Language {
// splitIntoGroups splits the input into clipping groups using the separator
func splitIntoGroups(input string) [][]string {
const separator = "========"

lines := strings.Split(input, "\n")
var groups [][]string
var currentGroup []string
Expand Down Expand Up @@ -187,7 +187,7 @@ func parseInfo(line string, language Language) (string, time.Time, error) {
// Parse location
locationSection := strings.TrimSpace(parts[0])
var locationPattern *regexp.Regexp

switch language {
case LanguageEnglish:
locationPattern = englishLocationPattern
Expand Down Expand Up @@ -248,12 +248,12 @@ func parseChineseDate(dateStr string) (time.Time, error) {

// Replace Chinese characters with separators
dateStr = chinesePattern.ReplaceAllString(dateStr, "-")

// Remove multiple dashes
multipleDashPattern := regexp.MustCompile(`-{2,}`)
dateStr = multipleDashPattern.ReplaceAllString(dateStr, "")
dateStr = strings.TrimSpace(dateStr)

// Add AM/PM suffix
dateStr = dateStr + " " + ampm

Expand All @@ -266,4 +266,4 @@ func validateUTF8(input string) error {
return fmt.Errorf("input is not valid UTF-8")
}
return nil
}
}
44 changes: 0 additions & 44 deletions src/auth.rs

This file was deleted.

98 changes: 0 additions & 98 deletions src/config.rs

This file was deleted.

2 changes: 0 additions & 2 deletions src/constants.rs

This file was deleted.

Loading
Loading