fyodor 0.2.5 → 0.2.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +26 -7
- data/bin/fyodor +55 -11
- data/lib/fyodor/config_getter.rb +2 -2
- data/lib/fyodor/entry_parser.rb +12 -2
- data/lib/fyodor/version.rb +1 -1
- metadata +19 -3
- data/lib/fyodor/cli.rb +0 -42
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7caa2b3d167d90c4c640b4069520a102ef82a2745dd133a9c83a24e6c1578eac
|
4
|
+
data.tar.gz: 57f2e8c8353cfd6bae7849bfb031c9a2a1fc24ffae0e4f4aed594c6284c4b8b0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 656d7f91ef1091443bd11ad054c0bd638cbc9369205852e9beedf981c836284dd9089898cc738cdd7680cc5c62b7943444252457bac687f43dbc38a1bb3c7026
|
7
|
+
data.tar.gz: 42014ee99f11b258b81987419e7c7529c7514f270c36e76a739997451df3cf0209a0fd2e4746d668b083ff3c8b206228c893db5e93850f7ea53c853fa17a5c3a
|
data/README.md
CHANGED
@@ -6,9 +6,9 @@ Convert your Amazon Kindle highlights, notes and bookmarks into markdown files.
|
|
6
6
|
|
7
7
|
This application parses `My Clippings.txt` from your Kindle and generates a markdown file for each book/document, in the format `#{Author} - #{Title}.md`. This way, your annotations are conveniently stored and easily managed.
|
8
8
|
|
9
|
-
[For samples of the output, click here.](
|
9
|
+
[For samples of the output, click here.](docs/output_demo)
|
10
10
|
|
11
|
-
To read more about the motivation and what problem it tries to solve, [check this blog post](
|
11
|
+
To read more about the motivation and what problem it tries to solve, [check this blog post](https://rafaelc.org/tech/p/export-all-your-kindle-highlights-and-notes/).
|
12
12
|
|
13
13
|
## Features
|
14
14
|
|
@@ -22,6 +22,13 @@ To read more about the motivation and what problem it tries to solve, [check thi
|
|
22
22
|
|
23
23
|
This program is based on the clippings file generated by Kindle 2019, but should work with other models.
|
24
24
|
|
25
|
+
## Limitations
|
26
|
+
|
27
|
+
We are limited by the data Kindle makes available through `My Clippings.txt`. This means:
|
28
|
+
|
29
|
+
- We don't have chapter information.
|
30
|
+
- We can’t guess all entries that were deleted.
|
31
|
+
|
25
32
|
## Installation
|
26
33
|
|
27
34
|
Install Ruby and run:
|
@@ -40,16 +47,16 @@ $ gem update fyodor
|
|
40
47
|
|
41
48
|
## Configuration
|
42
49
|
|
43
|
-
Fyodor has an optional configuration file, which is used for the following
|
50
|
+
Fyodor has an optional configuration file, which is used for the following.
|
44
51
|
|
45
52
|
### Languages
|
46
53
|
|
47
|
-
If your Kindle is not in English, you should tell Fyodor how some things are called by your `My Clippings.txt` (e.g. highlights, pages, etc).
|
54
|
+
If your Kindle is not in English, you should tell Fyodor how some things are called by your `My Clippings.txt` (e.g. highlights, pages, etc). _Fyodor should still work without configuration, but you won't take advantage of many features, resulting in a dirtier output._
|
48
55
|
|
49
|
-
1. Download the sample config to `~/.config/fyodor.toml` or `$XDG_CONFIG_HOME/fyodor.toml`:
|
56
|
+
1. Download the sample config to `~/.config/fyodor/fyodor.toml` or `$XDG_CONFIG_HOME/fyodor/fyodor.toml`:
|
50
57
|
|
51
|
-
```
|
52
|
-
$
|
58
|
+
```sh
|
59
|
+
$ curl https://raw.githubusercontent.com/rccavalcanti/fyodor/master/docs/fyodor.toml.sample --create-dirs -o ~/.config/fyodor/fyodor.toml
|
53
60
|
```
|
54
61
|
|
55
62
|
2. Open both the configuration and your `My Clippings.txt` in your preferred editor. Change the values in the `[parser]` section to mirror what you get in `My Clippings.txt`.
|
@@ -82,6 +89,18 @@ Where:
|
|
82
89
|
- `CLIPPINGS_FILE` is the path for `My Clippings.txt`.
|
83
90
|
- `OUTPUT_DIR` is the directory to write the markdown files. If none is supplied, this will be `fyodor_output` under the current directory.
|
84
91
|
|
92
|
+
## PSA: HTML to markdown
|
93
|
+
|
94
|
+
Did you export your annotations to HTML using the Kindle mobile app?
|
95
|
+
|
96
|
+
You can convert it to markdown with [a script I wrote specifically for it](https://rafaelc.org/k/kindle2md).
|
97
|
+
|
98
|
+
## Buy me a coffee
|
99
|
+
|
100
|
+
If you like Fyodor, you can show your support here:
|
101
|
+
|
102
|
+
<a href="https://rafaelc.org/coffee" target="_blank"><img src="https://cdn.buymeacoffee.com/buttons/default-orange.png" alt="Buy Me A Coffee" width="200" ></a>
|
103
|
+
|
85
104
|
## License
|
86
105
|
|
87
106
|
Licensed under [GPLv3](LICENSE)
|
data/bin/fyodor
CHANGED
@@ -1,15 +1,59 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
|
3
|
-
require "fyodor
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
3
|
+
require "fyodor"
|
4
|
+
require "fyodor/config_getter"
|
5
|
+
require "fyodor/stats_printer"
|
6
|
+
require "fyodor/version"
|
7
|
+
require "optimist"
|
8
|
+
require "pathname"
|
9
|
+
|
10
|
+
module Fyodor
|
11
|
+
class CLI
|
12
|
+
def main
|
13
|
+
parse_args
|
14
|
+
@config = ConfigGetter.new.config
|
15
|
+
|
16
|
+
if @cli_opts.trace
|
17
|
+
run
|
18
|
+
else
|
19
|
+
begin
|
20
|
+
run
|
21
|
+
rescue StandardError => e
|
22
|
+
abort(e.message)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
private
|
28
|
+
|
29
|
+
def get_path(path)
|
30
|
+
Pathname.new(path).expand_path
|
31
|
+
end
|
32
|
+
|
33
|
+
def default_output_dir
|
34
|
+
Pathname.new(Dir.pwd) + "fyodor_output"
|
35
|
+
end
|
36
|
+
|
37
|
+
def run
|
38
|
+
library = Library.new
|
39
|
+
ClippingsParser.new(@clippings_path, @config["parser"]).parse(library)
|
40
|
+
StatsPrinter.new(library).print
|
41
|
+
OutputWriter.new(library, @output_dir, @config["output"]).write_all
|
42
|
+
end
|
43
|
+
|
44
|
+
def parse_args
|
45
|
+
@cli_opts = Optimist::options do
|
46
|
+
version "Fyodor v#{Fyodor::VERSION}"
|
47
|
+
synopsis "Usage: fyodor [options] my_clippings_path [output_dir]"
|
48
|
+
|
49
|
+
opt :trace, "Show backtrace", :default => false
|
50
|
+
end
|
51
|
+
|
52
|
+
Optimist::die "Wrong number of arguments." if ARGV.count != 1 && ARGV.count != 2
|
53
|
+
@clippings_path = get_path(ARGV[0])
|
54
|
+
@output_dir = ARGV[1].nil? ? default_output_dir : get_path(ARGV[1])
|
55
|
+
end
|
14
56
|
end
|
15
57
|
end
|
58
|
+
|
59
|
+
Fyodor::CLI.new.main
|
data/lib/fyodor/config_getter.rb
CHANGED
@@ -42,8 +42,8 @@ module Fyodor
|
|
42
42
|
return @paths unless @paths.nil?
|
43
43
|
|
44
44
|
@paths = []
|
45
|
-
@paths << Pathname.new(ENV["XDG_CONFIG_HOME"]) + "fyodor.toml" unless ENV["XDG_CONFIG_HOME"].nil?
|
46
|
-
@paths << Pathname.new("~/.config/fyodor.toml").expand_path
|
45
|
+
@paths << Pathname.new(ENV["XDG_CONFIG_HOME"]) + "fyodor/fyodor.toml" unless ENV["XDG_CONFIG_HOME"].nil?
|
46
|
+
@paths << Pathname.new("~/.config/fyodor/fyodor.toml").expand_path
|
47
47
|
end
|
48
48
|
|
49
49
|
def print_path
|
data/lib/fyodor/entry_parser.rb
CHANGED
@@ -31,9 +31,15 @@ module Fyodor
|
|
31
31
|
|
32
32
|
title, author = @lines[0].scan(regex).first
|
33
33
|
# If book has no author, regex fails.
|
34
|
-
|
34
|
+
if title.nil?
|
35
|
+
title = @lines[0]
|
36
|
+
author = ""
|
37
|
+
end
|
38
|
+
|
39
|
+
title = rm_zero_width_chars(title).strip
|
40
|
+
author = rm_zero_width_chars(author).strip
|
35
41
|
|
36
|
-
{title: title
|
42
|
+
{title: title, author: author}
|
37
43
|
end
|
38
44
|
|
39
45
|
def desc
|
@@ -93,5 +99,9 @@ module Fyodor
|
|
93
99
|
raise "Entry is badly formatted" if @lines[1].strip.empty?
|
94
100
|
raise "Entry is badly formatted" unless @lines[2].strip.empty?
|
95
101
|
end
|
102
|
+
|
103
|
+
def rm_zero_width_chars(str)
|
104
|
+
str.gsub(/[\u200B-\u200D\uFEFF]/, '')
|
105
|
+
end
|
96
106
|
end
|
97
107
|
end
|
data/lib/fyodor/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fyodor
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Rafael Cavalcanti
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-10-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: toml
|
@@ -24,6 +24,20 @@ dependencies:
|
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '0.1'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: optimist
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '3.0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '3.0'
|
27
41
|
description: Parse Kindle clippings into markdown files
|
28
42
|
email: code@rafaelc.org
|
29
43
|
executables:
|
@@ -36,7 +50,6 @@ files:
|
|
36
50
|
- bin/fyodor
|
37
51
|
- lib/fyodor.rb
|
38
52
|
- lib/fyodor/book.rb
|
39
|
-
- lib/fyodor/cli.rb
|
40
53
|
- lib/fyodor/clippings_parser.rb
|
41
54
|
- lib/fyodor/config_getter.rb
|
42
55
|
- lib/fyodor/core_extensions/hash/merging.rb
|
@@ -62,6 +75,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
62
75
|
- - ">="
|
63
76
|
- !ruby/object:Gem::Version
|
64
77
|
version: '2.5'
|
78
|
+
- - "<"
|
79
|
+
- !ruby/object:Gem::Version
|
80
|
+
version: '3'
|
65
81
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
66
82
|
requirements:
|
67
83
|
- - ">="
|
data/lib/fyodor/cli.rb
DELETED
@@ -1,42 +0,0 @@
|
|
1
|
-
require "fyodor/config_getter"
|
2
|
-
require "fyodor/stats_printer"
|
3
|
-
require "fyodor/library"
|
4
|
-
require "fyodor/clippings_parser"
|
5
|
-
require "fyodor/output_writer"
|
6
|
-
require "pathname"
|
7
|
-
|
8
|
-
module Fyodor
|
9
|
-
class CLI
|
10
|
-
USAGE = "Usage: #{File.basename($0)} my_clippings_path [output_dir]"
|
11
|
-
|
12
|
-
def initialize
|
13
|
-
get_args
|
14
|
-
@config = ConfigGetter.new.config
|
15
|
-
end
|
16
|
-
|
17
|
-
def main
|
18
|
-
library = Library.new
|
19
|
-
ClippingsParser.new(@clippings_path, @config["parser"]).parse(library)
|
20
|
-
StatsPrinter.new(library).print
|
21
|
-
OutputWriter.new(library, @output_dir, @config["output"]).write_all
|
22
|
-
end
|
23
|
-
|
24
|
-
|
25
|
-
private
|
26
|
-
|
27
|
-
def get_args
|
28
|
-
abort(USAGE) if ARGV.count != 1 && ARGV.count != 2
|
29
|
-
|
30
|
-
@clippings_path = get_path(ARGV[0])
|
31
|
-
@output_dir = ARGV[1].nil? ? default_output_dir : get_path(ARGV[1])
|
32
|
-
end
|
33
|
-
|
34
|
-
def get_path(path)
|
35
|
-
Pathname.new(path).expand_path
|
36
|
-
end
|
37
|
-
|
38
|
-
def default_output_dir
|
39
|
-
Pathname.new(Dir.pwd) + "fyodor_output"
|
40
|
-
end
|
41
|
-
end
|
42
|
-
end
|