kitabu 3.0.3 → 3.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/ruby-tests.yml +6 -3
- data/.rubocop.yml +1 -1
- data/CHANGELOG.md +7 -0
- data/README.md +1 -1
- data/kitabu.gemspec +1 -2
- data/lib/kitabu/exporter/epub.rb +3 -3
- data/lib/kitabu/exporter/html.rb +1 -1
- data/lib/kitabu/extensions/rouge.rb +2 -0
- data/lib/kitabu/markdown.rb +32 -0
- data/lib/kitabu/source_list.rb +2 -2
- data/lib/kitabu/toc/epub.rb +1 -1
- data/lib/kitabu/toc/html.rb +2 -2
- data/lib/kitabu/version.rb +3 -3
- data/spec/kitabu/markdown_spec.rb +39 -0
- data/spec/spec_helper.rb +2 -2
- data/spec/support/have_tag.rb +1 -1
- data/templates/config.erb +1 -1
- data/templates/text/01_Getting_Started.md +7 -15
- metadata +5 -50
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 562752c6728b0fcaf670120941d9864612edf13375f482a0e129d61ceb487845
|
4
|
+
data.tar.gz: 42ae997787207adca50cd791df060181e5e2b37ee84647d20ac4ebbf0b105dd1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7fc4d5ecaf3f24edbd3f04e1733aab2ca67017c8a91626b78df810727cb2fc843f6c885a591238a13542b3c6391fd5b3e0b088b3e348f2a1367063e3f9ca363c
|
7
|
+
data.tar.gz: 9a5b6367c443ed3343ac8b379af171c1fc6713aea6cc5d894858f2fad8bff8185283c6e6bc8c00e82abd5d77afd3df07bab2fcf4e97a60a4a15e24784e385738
|
@@ -19,11 +19,14 @@ jobs:
|
|
19
19
|
strategy:
|
20
20
|
fail-fast: false
|
21
21
|
matrix:
|
22
|
-
ruby: ["2
|
22
|
+
ruby: ["3.2", "3.3"]
|
23
23
|
gemfile:
|
24
24
|
- Gemfile
|
25
25
|
|
26
26
|
steps:
|
27
|
+
- name: Update deps
|
28
|
+
run: sudo apt update -y
|
29
|
+
|
27
30
|
- name: Install deps
|
28
31
|
run: sudo apt install -y calibre gdebi
|
29
32
|
|
@@ -32,9 +35,9 @@ jobs:
|
|
32
35
|
wget https://www.princexml.com/download/prince_14.2-1_ubuntu20.04_amd64.deb
|
33
36
|
sudo gdebi --non-interactive prince_14.2-1_ubuntu20.04_amd64.deb
|
34
37
|
|
35
|
-
- uses: actions/checkout@
|
38
|
+
- uses: actions/checkout@v4
|
36
39
|
|
37
|
-
- uses: actions/cache@
|
40
|
+
- uses: actions/cache@v3
|
38
41
|
with:
|
39
42
|
path: vendor/bundle
|
40
43
|
key: >
|
data/.rubocop.yml
CHANGED
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,12 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
+
## v3.0.4
|
4
|
+
|
5
|
+
- Add support for
|
6
|
+
[Github's alert syntax](https://github.com/orgs/community/discussions/16925).
|
7
|
+
Kitabu's implementation supports any arbitrary name, so you can use anything
|
8
|
+
(e.g. `[!ALERT]`).
|
9
|
+
|
3
10
|
## v3.0.3
|
4
11
|
|
5
12
|
- Fix Rouge options keys; symbols are required.
|
data/README.md
CHANGED
@@ -26,7 +26,7 @@ starting at \$15/mo.
|
|
26
26
|
|
27
27
|
## Installation
|
28
28
|
|
29
|
-
To install Kitabu, you'll need a working Ruby 2
|
29
|
+
To install Kitabu, you'll need a working Ruby 3.2+ installation. If you're cool
|
30
30
|
with it, just run the following command to install it.
|
31
31
|
|
32
32
|
gem install kitabu
|
data/kitabu.gemspec
CHANGED
@@ -16,11 +16,10 @@ Gem::Specification.new do |s|
|
|
16
16
|
"supports EPUB, Mobi, Text and HTML generation."
|
17
17
|
s.description = s.summary
|
18
18
|
s.license = "MIT"
|
19
|
-
s.required_ruby_version = ">= 2
|
19
|
+
s.required_ruby_version = ">= 3.2"
|
20
20
|
s.metadata = {"rubygems_mfa_required" => "true"}
|
21
21
|
|
22
22
|
s.files = `git ls-files`.split("\n")
|
23
|
-
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
24
23
|
s.executables = `git ls-files -- bin/*`.split("\n").map do |f|
|
25
24
|
File.basename(f)
|
26
25
|
end
|
data/lib/kitabu/exporter/epub.rb
CHANGED
@@ -7,7 +7,7 @@ module Kitabu
|
|
7
7
|
@sections ||=
|
8
8
|
html.css("div.chapter").each_with_index.map do |chapter, index|
|
9
9
|
OpenStruct.new(
|
10
|
-
index
|
10
|
+
index:,
|
11
11
|
filename: "section_#{index}.html",
|
12
12
|
filepath: tmp_dir.join("section_#{index}.html").to_s,
|
13
13
|
html: Nokogiri::HTML(chapter.inner_html)
|
@@ -114,7 +114,7 @@ module Kitabu
|
|
114
114
|
end
|
115
115
|
|
116
116
|
def render_chapter(content)
|
117
|
-
locals = config.merge(content:
|
117
|
+
locals = config.merge(content:)
|
118
118
|
render_template(template_path, locals)
|
119
119
|
end
|
120
120
|
|
@@ -130,7 +130,7 @@ module Kitabu
|
|
130
130
|
path =
|
131
131
|
Dir[root_dir.join("templates/epub/cover.{jpg,png,gif}").to_s].first
|
132
132
|
|
133
|
-
|
133
|
+
path if path && File.exist?(path)
|
134
134
|
end
|
135
135
|
|
136
136
|
def navigation
|
data/lib/kitabu/exporter/html.rb
CHANGED
@@ -8,6 +8,8 @@ module Rouge
|
|
8
8
|
options = options.keys.map(&:to_sym).zip(options.values).to_h
|
9
9
|
options[:start_line] = options.fetch(:start_line, 1).to_i
|
10
10
|
|
11
|
+
options = options.keys.map(&:to_sym).zip(options.values).to_h
|
12
|
+
|
11
13
|
Formatters::HTMLLegacy.new(
|
12
14
|
{css_class: "highlight #{lexer.tag}"}.merge(options)
|
13
15
|
)
|
data/lib/kitabu/markdown.rb
CHANGED
@@ -5,6 +5,38 @@ module Kitabu
|
|
5
5
|
class Renderer < Redcarpet::Render::HTML
|
6
6
|
include Redcarpet::Render::SmartyPants
|
7
7
|
include Rouge::Plugins::Redcarpet
|
8
|
+
|
9
|
+
# Be more flexible than github and support any arbitrary name.
|
10
|
+
ALERT_MARK = /^\[!(?<type>[A-Z]+)\]$/
|
11
|
+
|
12
|
+
# Support alert boxes just like github.
|
13
|
+
# https://github.com/orgs/community/discussions/16925
|
14
|
+
def block_quote(quote)
|
15
|
+
html = Nokogiri::HTML(quote)
|
16
|
+
element = html.css("body > :first-child").first
|
17
|
+
|
18
|
+
matches = element.text.match(ALERT_MARK)
|
19
|
+
|
20
|
+
return "<blockquote>#{quote}</blockquote>" unless matches
|
21
|
+
|
22
|
+
element.remove
|
23
|
+
|
24
|
+
type = matches[:type].downcase
|
25
|
+
type = "info" if type == "note"
|
26
|
+
|
27
|
+
title = I18n.t(
|
28
|
+
type,
|
29
|
+
scope: :notes,
|
30
|
+
default: type.titleize
|
31
|
+
)
|
32
|
+
|
33
|
+
<<~HTML.strip_heredoc
|
34
|
+
<div class="note #{type}">
|
35
|
+
<p class="note--title">#{title}</p>
|
36
|
+
#{html.css('body').inner_html}
|
37
|
+
</div>
|
38
|
+
HTML
|
39
|
+
end
|
8
40
|
end
|
9
41
|
|
10
42
|
class << self
|
data/lib/kitabu/source_list.rb
CHANGED
@@ -8,7 +8,7 @@ module Kitabu
|
|
8
8
|
|
9
9
|
# Files that should be skipped.
|
10
10
|
#
|
11
|
-
IGNORE_FILES = /^(CHANGELOG|TOC)
|
11
|
+
IGNORE_FILES = /^(CHANGELOG|TOC)\..*?$/
|
12
12
|
|
13
13
|
# List of recognized extensions.
|
14
14
|
#
|
@@ -37,7 +37,7 @@ module Kitabu
|
|
37
37
|
if File.file?(entry)
|
38
38
|
[entry]
|
39
39
|
else
|
40
|
-
Dir["#{entry}/**/*.{#{EXTENSIONS.join(',')}}"]
|
40
|
+
Dir["#{entry}/**/*.{#{EXTENSIONS.join(',')}}"]
|
41
41
|
end
|
42
42
|
end
|
43
43
|
|
data/lib/kitabu/toc/epub.rb
CHANGED
data/lib/kitabu/toc/html.rb
CHANGED
data/lib/kitabu/version.rb
CHANGED
@@ -44,4 +44,43 @@ describe Kitabu::Markdown do
|
|
44
44
|
TEXT
|
45
45
|
end.not_to raise_error
|
46
46
|
end
|
47
|
+
|
48
|
+
it "renders alert boxes using block quotes" do
|
49
|
+
html = Kitabu::Markdown.render <<-TEXT.strip_heredoc
|
50
|
+
> [!NOTE]
|
51
|
+
>
|
52
|
+
> This is just a note
|
53
|
+
TEXT
|
54
|
+
|
55
|
+
html = Nokogiri::HTML(html)
|
56
|
+
selector = "div.note.info > .note--title"
|
57
|
+
|
58
|
+
expect(html.css(selector).text).to eql("Info")
|
59
|
+
expect(html.css("#{selector} + p").text).to eql("This is just a note")
|
60
|
+
end
|
61
|
+
|
62
|
+
it "renders arbitrary alert boxes using block quotes" do
|
63
|
+
html = Kitabu::Markdown.render <<-TEXT.strip_heredoc
|
64
|
+
> [!ALERT]
|
65
|
+
>
|
66
|
+
> This is just an alert
|
67
|
+
TEXT
|
68
|
+
|
69
|
+
html = Nokogiri::HTML(html)
|
70
|
+
selector = "div.note.alert > .note--title"
|
71
|
+
|
72
|
+
expect(html.css(selector).text).to eql("Alert")
|
73
|
+
expect(html.css("#{selector} + p").text).to eql("This is just an alert")
|
74
|
+
end
|
75
|
+
|
76
|
+
it "renders regular block quotes" do
|
77
|
+
html = Kitabu::Markdown.render <<-TEXT.strip_heredoc
|
78
|
+
> This is just a quote
|
79
|
+
TEXT
|
80
|
+
|
81
|
+
html = Nokogiri::HTML(html)
|
82
|
+
|
83
|
+
expect(html.css(".note").count).to eql(0)
|
84
|
+
expect(html.css("blockquote").text.chomp).to eql("This is just a quote")
|
85
|
+
end
|
47
86
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -13,7 +13,7 @@ require "pathname"
|
|
13
13
|
SPECDIR = Pathname.new(File.dirname(__FILE__))
|
14
14
|
TMPDIR = SPECDIR.join("tmp")
|
15
15
|
|
16
|
-
Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].
|
16
|
+
Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|r| require r }
|
17
17
|
|
18
18
|
p [
|
19
19
|
:filter_env,
|
@@ -47,7 +47,7 @@ RSpec.configure do |config|
|
|
47
47
|
|
48
48
|
cleaner = proc do
|
49
49
|
[TMPDIR, SPECDIR.join("support/mybook/output")].each do |i|
|
50
|
-
FileUtils.rm_rf(i)
|
50
|
+
FileUtils.rm_rf(i)
|
51
51
|
end
|
52
52
|
|
53
53
|
Dir.chdir File.expand_path("..", __dir__)
|
data/spec/support/have_tag.rb
CHANGED
data/templates/config.erb
CHANGED
@@ -25,7 +25,7 @@ published_at: "<%= Date.today %>"
|
|
25
25
|
subject: "This guide will help you understand how all of the pieces fit together on Kitabu."
|
26
26
|
|
27
27
|
# Some keywords that identify this book.
|
28
|
-
keywords: "kitabu, e-book,
|
28
|
+
keywords: "kitabu, e-book, calibre, epub, mobi, pdf, prince"
|
29
29
|
|
30
30
|
# Some unique identification. Works great with your domain
|
31
31
|
# like `http://yourbook.example.com`.
|
@@ -4,10 +4,8 @@ This guide is designed for beginners who want to get started with Kitabu from
|
|
4
4
|
scratch. However, to get the most out of it, you need to have some prerequisites
|
5
5
|
installed:
|
6
6
|
|
7
|
-
- The [Ruby](http://ruby-lang.org) interpreter version 2
|
8
|
-
- The [PrinceXML](http://princexml.com) converter version
|
9
|
-
- The [KindleGen](http://www.amazon.com/gp/feature.html?docId=1000765211)
|
10
|
-
converter.
|
7
|
+
- The [Ruby](http://ruby-lang.org) interpreter version 3.2 or newer.
|
8
|
+
- The [PrinceXML](http://princexml.com) converter version 14.0 or newer.
|
11
9
|
|
12
10
|
### Installing Ruby
|
13
11
|
|
@@ -29,16 +27,10 @@ user costs 495USD. If you don't like the price tag, consider using
|
|
29
27
|
To install PrinceXML, go to the website and download the correct version for
|
30
28
|
your platform; you can choose from Mac OSX, to Linux and Windows.
|
31
29
|
|
32
|
-
### Installing
|
30
|
+
### Installing Calibre
|
33
31
|
|
34
|
-
|
35
|
-
|
36
|
-
consider using [Calibre](http://calibre-ebook.com/) for this task.[^2]
|
32
|
+
[Calibre](http://calibre-ebook.com/) is a e-book manager that, among other
|
33
|
+
features, allows converting ePub files into .mobi files.
|
37
34
|
|
38
|
-
|
39
|
-
|
40
|
-
[KindleGen's website](http://www.amazon.com/gp/feature.html?docId=1000765211)
|
41
|
-
and download the appropriate installer otherwise.
|
42
|
-
|
43
|
-
[^1]: You can, but that would be a violation of Amazon's terms of use.
|
44
|
-
[^2]: Calibre is not perfect, but does a good job.
|
35
|
+
To install Calibre, go to the website and download the correct version for your
|
36
|
+
platform; you can choose from Mac OSX, to Linux and Windows.
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: kitabu
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.0
|
4
|
+
version: 3.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nando Vieira
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2024-01-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -368,62 +368,17 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
368
368
|
requirements:
|
369
369
|
- - ">="
|
370
370
|
- !ruby/object:Gem::Version
|
371
|
-
version: '2
|
371
|
+
version: '3.2'
|
372
372
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
373
373
|
requirements:
|
374
374
|
- - ">="
|
375
375
|
- !ruby/object:Gem::Version
|
376
376
|
version: '0'
|
377
377
|
requirements: []
|
378
|
-
rubygems_version: 3.3
|
378
|
+
rubygems_version: 3.5.3
|
379
379
|
signing_key:
|
380
380
|
specification_version: 4
|
381
381
|
summary: A framework for creating e-books from Markdown using Ruby. Using the Prince
|
382
382
|
PDF generator, you'll be able to get high quality PDFs. Also supports EPUB, Mobi,
|
383
383
|
Text and HTML generation.
|
384
|
-
test_files:
|
385
|
-
- spec/kitabu/cli/export_spec.rb
|
386
|
-
- spec/kitabu/cli/new_spec.rb
|
387
|
-
- spec/kitabu/cli/permalinks_spec.rb
|
388
|
-
- spec/kitabu/cli/stats_spec.rb
|
389
|
-
- spec/kitabu/cli/version_spec.rb
|
390
|
-
- spec/kitabu/exporter/css_spec.rb
|
391
|
-
- spec/kitabu/exporter/epub_spec.rb
|
392
|
-
- spec/kitabu/exporter/html_spec.rb
|
393
|
-
- spec/kitabu/exporter/mobi_spec.rb
|
394
|
-
- spec/kitabu/exporter/pdf_spec.rb
|
395
|
-
- spec/kitabu/extensions/string_spec.rb
|
396
|
-
- spec/kitabu/footnotes/html_spec.rb
|
397
|
-
- spec/kitabu/generator_spec.rb
|
398
|
-
- spec/kitabu/markdown_spec.rb
|
399
|
-
- spec/kitabu/source_list_spec.rb
|
400
|
-
- spec/kitabu/stats_spec.rb
|
401
|
-
- spec/kitabu/toc/html_spec.rb
|
402
|
-
- spec/spec_helper.rb
|
403
|
-
- spec/support/exit_with_code.rb
|
404
|
-
- spec/support/have_tag.rb
|
405
|
-
- spec/support/helper.rb
|
406
|
-
- spec/support/mybook/.gitignore
|
407
|
-
- spec/support/mybook/code/.gitkeep
|
408
|
-
- spec/support/mybook/code/code.rb
|
409
|
-
- spec/support/mybook/config/helper.rb
|
410
|
-
- spec/support/mybook/config/kitabu.yml
|
411
|
-
- spec/support/mybook/fonts/OpenSans-CondBold.ttf
|
412
|
-
- spec/support/mybook/images/.gitkeep
|
413
|
-
- spec/support/mybook/images/logo.gif
|
414
|
-
- spec/support/mybook/templates/epub/cover.erb
|
415
|
-
- spec/support/mybook/templates/epub/cover.png
|
416
|
-
- spec/support/mybook/templates/epub/page.erb
|
417
|
-
- spec/support/mybook/templates/html/layout.erb
|
418
|
-
- spec/support/mybook/templates/styles/epub.css
|
419
|
-
- spec/support/mybook/templates/styles/html.css
|
420
|
-
- spec/support/mybook/templates/styles/pdf.css
|
421
|
-
- spec/support/mybook/templates/styles/print.css
|
422
|
-
- spec/support/mybook/text/.gitkeep
|
423
|
-
- spec/support/mybook/text/01_Markdown_Chapter.md
|
424
|
-
- spec/support/mybook/text/02_ERB_Chapter.md.erb
|
425
|
-
- spec/support/mybook/text/03_With_Directory/Some_Chapter.md
|
426
|
-
- spec/support/mybook/text/CHANGELOG.md
|
427
|
-
- spec/support/mybook/text/TOC.md
|
428
|
-
- spec/support/mybook/text/_00_Introduction.md
|
429
|
-
- spec/support/shared.rb
|
384
|
+
test_files: []
|