xantora 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +10 -0
- data/.gitlab-ci.yml +13 -0
- data/.rubocop.yml +14 -0
- data/Gemfile +12 -0
- data/Gemfile.lock +96 -0
- data/LICENSE.txt +21 -0
- data/README.md +63 -0
- data/Rakefile +16 -0
- data/asciidoctor-pdf/fonts/DroidSansFallback.ttf +0 -0
- data/asciidoctor-pdf/fonts/Roboto-Bold.ttf +0 -0
- data/asciidoctor-pdf/fonts/Roboto-BoldItalic.ttf +0 -0
- data/asciidoctor-pdf/fonts/Roboto-Italic.ttf +0 -0
- data/asciidoctor-pdf/fonts/Roboto-Regular.ttf +0 -0
- data/asciidoctor-pdf/themes/puzzle-logo.png +0 -0
- data/asciidoctor-pdf/themes/puzzle-theme.yml +70 -0
- data/bin/console +15 -0
- data/bin/setup +8 -0
- data/exe/xantora +6 -0
- data/lib/xantora.rb +9 -0
- data/lib/xantora/cli.rb +82 -0
- data/lib/xantora/document.rb +100 -0
- data/lib/xantora/version.rb +5 -0
- data/xantora.gemspec +30 -0
- metadata +112 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: e62bb76f892c8c6d8ae8f6ec720e1ddeb5f8d7fe51ff40d932cfcaa3c320fc7b
|
4
|
+
data.tar.gz: 725c922eed0d2c2e6aad23c86617a9d682174930b17e185f5a8e368887fe60ea
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 5b69af38b6f177fd99e88553c76b6e5fd3ae5e35dc59933eeecea533814fe27630f764378b2822573540565ce276d34a7791a70b9d76f4f0b3828a90ee4a7431
|
7
|
+
data.tar.gz: 3b2e555986bb077b8846105b7fbfa236a01761c1fc4ae83f0729c9b3ce86cace840541f9700fbb0f6ce87c80fef33b503af66ded41100e5ac3fb1c6fe0efa315
|
data/.gitignore
ADDED
data/.gitlab-ci.yml
ADDED
data/.rubocop.yml
ADDED
data/Gemfile
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
source "https://rubygems.org"
|
4
|
+
|
5
|
+
# Specify your gem's dependencies in xantora.gemspec
|
6
|
+
gemspec
|
7
|
+
|
8
|
+
gem "minitest", "~> 5.0"
|
9
|
+
gem "rake", "~> 13.0"
|
10
|
+
gem "rubocop", "~> 1.7"
|
11
|
+
|
12
|
+
# gem "prawn-table", github: "prawnpdf/prawn-table", branch: "HEAD"
|
data/Gemfile.lock
ADDED
@@ -0,0 +1,96 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
xantora (0.1.0)
|
5
|
+
asciidoctor-pdf (~> 1.6.0)
|
6
|
+
thor (~> 1.1.0)
|
7
|
+
tty-spinner (~> 0.9.3)
|
8
|
+
|
9
|
+
GEM
|
10
|
+
remote: https://rubygems.org/
|
11
|
+
specs:
|
12
|
+
Ascii85 (1.1.0)
|
13
|
+
addressable (2.8.0)
|
14
|
+
public_suffix (>= 2.0.2, < 5.0)
|
15
|
+
afm (0.2.2)
|
16
|
+
asciidoctor (2.0.16)
|
17
|
+
asciidoctor-pdf (1.6.0)
|
18
|
+
asciidoctor (~> 2.0)
|
19
|
+
concurrent-ruby (~> 1.1)
|
20
|
+
prawn (~> 2.4.0)
|
21
|
+
prawn-icon (~> 3.0.0)
|
22
|
+
prawn-svg (~> 0.32.0)
|
23
|
+
prawn-table (~> 0.2.0)
|
24
|
+
prawn-templates (~> 0.1.0)
|
25
|
+
safe_yaml (~> 1.0.0)
|
26
|
+
treetop (~> 1.6.0)
|
27
|
+
ast (2.4.2)
|
28
|
+
concurrent-ruby (1.1.9)
|
29
|
+
css_parser (1.10.0)
|
30
|
+
addressable
|
31
|
+
hashery (2.1.2)
|
32
|
+
minitest (5.14.4)
|
33
|
+
parallel (1.20.1)
|
34
|
+
parser (3.0.2.0)
|
35
|
+
ast (~> 2.4.1)
|
36
|
+
pdf-core (0.9.0)
|
37
|
+
pdf-reader (2.5.0)
|
38
|
+
Ascii85 (~> 1.0)
|
39
|
+
afm (~> 0.2.1)
|
40
|
+
hashery (~> 2.0)
|
41
|
+
ruby-rc4
|
42
|
+
ttfunk
|
43
|
+
polyglot (0.3.5)
|
44
|
+
prawn (2.4.0)
|
45
|
+
pdf-core (~> 0.9.0)
|
46
|
+
ttfunk (~> 1.7)
|
47
|
+
prawn-icon (3.0.0)
|
48
|
+
prawn (>= 1.1.0, < 3.0.0)
|
49
|
+
prawn-svg (0.32.0)
|
50
|
+
css_parser (~> 1.6)
|
51
|
+
prawn (>= 0.11.1, < 3)
|
52
|
+
rexml (~> 3.2)
|
53
|
+
prawn-table (0.2.2)
|
54
|
+
prawn (>= 1.3.0, < 3.0.0)
|
55
|
+
prawn-templates (0.1.2)
|
56
|
+
pdf-reader (~> 2.0)
|
57
|
+
prawn (~> 2.2)
|
58
|
+
public_suffix (4.0.6)
|
59
|
+
rainbow (3.0.0)
|
60
|
+
rake (13.0.6)
|
61
|
+
regexp_parser (2.1.1)
|
62
|
+
rexml (3.2.5)
|
63
|
+
rubocop (1.19.0)
|
64
|
+
parallel (~> 1.10)
|
65
|
+
parser (>= 3.0.0.0)
|
66
|
+
rainbow (>= 2.2.2, < 4.0)
|
67
|
+
regexp_parser (>= 1.8, < 3.0)
|
68
|
+
rexml
|
69
|
+
rubocop-ast (>= 1.9.1, < 2.0)
|
70
|
+
ruby-progressbar (~> 1.7)
|
71
|
+
unicode-display_width (>= 1.4.0, < 3.0)
|
72
|
+
rubocop-ast (1.10.0)
|
73
|
+
parser (>= 3.0.1.1)
|
74
|
+
ruby-progressbar (1.11.0)
|
75
|
+
ruby-rc4 (0.1.5)
|
76
|
+
safe_yaml (1.0.5)
|
77
|
+
thor (1.1.0)
|
78
|
+
treetop (1.6.11)
|
79
|
+
polyglot (~> 0.3)
|
80
|
+
ttfunk (1.7.0)
|
81
|
+
tty-cursor (0.7.1)
|
82
|
+
tty-spinner (0.9.3)
|
83
|
+
tty-cursor (~> 0.7)
|
84
|
+
unicode-display_width (2.0.0)
|
85
|
+
|
86
|
+
PLATFORMS
|
87
|
+
x86_64-linux
|
88
|
+
|
89
|
+
DEPENDENCIES
|
90
|
+
minitest (~> 5.0)
|
91
|
+
rake (~> 13.0)
|
92
|
+
rubocop (~> 1.7)
|
93
|
+
xantora!
|
94
|
+
|
95
|
+
BUNDLED WITH
|
96
|
+
2.2.25
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2021 Nik Wolfgramm
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,63 @@
|
|
1
|
+
# Xantora
|
2
|
+
|
3
|
+
A PDF-converter for [Antora](https://antora.org/) (AsciiDoc) documents.
|
4
|
+
|
5
|
+
This Ruby CLI-Tool uses [asciidoctor-pdf](https://asciidoctor.org/docs/asciidoctor-pdf/) and makes it easy to export PDF's from Antora projects.
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
Install the gem:
|
10
|
+
|
11
|
+
```sh
|
12
|
+
gem install xantora
|
13
|
+
```
|
14
|
+
|
15
|
+
## Usage
|
16
|
+
|
17
|
+
Convert a single AsciiDoc document:
|
18
|
+
|
19
|
+
```bash
|
20
|
+
xantora convert -s modules/user-guide/pages/index.adoc
|
21
|
+
```
|
22
|
+
|
23
|
+
Convert a all documents within an Antora component:
|
24
|
+
|
25
|
+
```bash
|
26
|
+
xantora convert -s modules/
|
27
|
+
```
|
28
|
+
|
29
|
+
Convert all documents and store PDF's in the attachment folders (using option `--to-attachments` or `-A`):
|
30
|
+
|
31
|
+
```bash
|
32
|
+
xantora convert-modules -s modules/ --to-attachments
|
33
|
+
```
|
34
|
+
|
35
|
+
See `xantora help` for more usage instructions.
|
36
|
+
|
37
|
+
## Features
|
38
|
+
|
39
|
+
- Preconfigured [asciidoctor-pdf](https://asciidoctor.org/docs/asciidoctor-pdf/) setup wich makes it simple to convert single Antora documents or whole modules into PDF's
|
40
|
+
- Integrated PDF-theme suppport which makes your documents look good out of the box
|
41
|
+
- Uses the santisized AsciiDoc document title as PDF filename
|
42
|
+
- Sets the image-path according your Antora folder structure
|
43
|
+
- Autodetects `antora.yml` configs in order to extract metadata such as `page-component-title`, which can be used in themes (i.e. header and footer)
|
44
|
+
- Optionaly Xantora will safe PDF's in attachments folders coresponding to source documents
|
45
|
+
|
46
|
+
## Known Limitations
|
47
|
+
|
48
|
+
- Images referenced outside the documents own Antora module can't be loaded
|
49
|
+
- Same limitations as with asciidoctor-pdf do apply, see [asciidoctor-pdf known-limitations](https://github.com/asciidoctor/asciidoctor-pdf#known-limitations)
|
50
|
+
|
51
|
+
## Development
|
52
|
+
|
53
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
54
|
+
|
55
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
56
|
+
|
57
|
+
## Contributing
|
58
|
+
|
59
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/niwo/xantora. This project is intended to be a safe, welcoming space for collaboration.
|
60
|
+
|
61
|
+
## License
|
62
|
+
|
63
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
data/Rakefile
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "bundler/gem_tasks"
|
4
|
+
require "rake/testtask"
|
5
|
+
|
6
|
+
Rake::TestTask.new(:test) do |t|
|
7
|
+
t.libs << "test"
|
8
|
+
t.libs << "lib"
|
9
|
+
t.test_files = FileList["test/**/*_test.rb"]
|
10
|
+
end
|
11
|
+
|
12
|
+
require "rubocop/rake_task"
|
13
|
+
|
14
|
+
RuboCop::RakeTask.new
|
15
|
+
|
16
|
+
task default: %i[test rubocop]
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
@@ -0,0 +1,70 @@
|
|
1
|
+
extends: default
|
2
|
+
toc-title: Inhaltsverzeichnis
|
3
|
+
font:
|
4
|
+
catalog:
|
5
|
+
merge: true
|
6
|
+
Roboto:
|
7
|
+
normal: Roboto-Regular.ttf
|
8
|
+
italic: Roboto-Italic.ttf
|
9
|
+
bold: Roboto-Bold.ttf
|
10
|
+
bold_italic: Roboto-BoldItalic.ttf
|
11
|
+
DroidSansFallback: DroidSansFallback.ttf
|
12
|
+
fallbacks:
|
13
|
+
- DroidSansFallback
|
14
|
+
ulist:
|
15
|
+
marker:
|
16
|
+
circle:
|
17
|
+
content: "\u2022"
|
18
|
+
link:
|
19
|
+
font-color: #2C97A6
|
20
|
+
base:
|
21
|
+
font_family: Roboto
|
22
|
+
font_style: normal
|
23
|
+
page:
|
24
|
+
margin: [1.0in, 0.67in, 0.67in, 0.67in]
|
25
|
+
heading:
|
26
|
+
font-color: #1E5A96
|
27
|
+
header:
|
28
|
+
font_color: #999999
|
29
|
+
height: 1.0in
|
30
|
+
line_height: 1
|
31
|
+
recto:
|
32
|
+
columns: "<40% =20% >40%"
|
33
|
+
right:
|
34
|
+
content: '{localdate}'
|
35
|
+
center:
|
36
|
+
content: image:puzzle-logo.png[pdfwidth=0.8in]
|
37
|
+
left:
|
38
|
+
content: '{page-component-title}'
|
39
|
+
verso:
|
40
|
+
columns: $header_recto_columns
|
41
|
+
left:
|
42
|
+
content: $header_recto_right_content
|
43
|
+
center:
|
44
|
+
content: $header_recto_center_content
|
45
|
+
right:
|
46
|
+
content: $header_recto_left_content
|
47
|
+
footer:
|
48
|
+
font-color: $header_font_color
|
49
|
+
font_size: $base_font_size_small
|
50
|
+
# NOTE if background_color is set, background and border will span width of page
|
51
|
+
border_color: #DDDDDD
|
52
|
+
border_width: 0.25
|
53
|
+
height: $base_line_height_length * 2.5
|
54
|
+
line_height: 1
|
55
|
+
padding: [$base_line_height_length / 2, 1, 0, 1]
|
56
|
+
vertical_align: top
|
57
|
+
recto:
|
58
|
+
right:
|
59
|
+
content: 'Seite {page-number}/{page-count}'
|
60
|
+
center:
|
61
|
+
content: '(C) {localyear} -- {company}'
|
62
|
+
left:
|
63
|
+
content: '{doctitle}'
|
64
|
+
verso:
|
65
|
+
center:
|
66
|
+
content: $footer_recto_center_content
|
67
|
+
left:
|
68
|
+
content: $footer_recto_right_content
|
69
|
+
right:
|
70
|
+
content: $footer_recto_left_content
|
data/bin/console
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
require "bundler/setup"
|
5
|
+
require "xantora"
|
6
|
+
|
7
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
8
|
+
# with your gem easier. You can also use a different console, if you like.
|
9
|
+
|
10
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
11
|
+
# require "pry"
|
12
|
+
# Pry.start
|
13
|
+
|
14
|
+
require "irb"
|
15
|
+
IRB.start(__FILE__)
|
data/bin/setup
ADDED
data/exe/xantora
ADDED
data/lib/xantora.rb
ADDED
data/lib/xantora/cli.rb
ADDED
@@ -0,0 +1,82 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "thor"
|
4
|
+
require "tty-spinner"
|
5
|
+
require "stringio"
|
6
|
+
|
7
|
+
module Xantora
|
8
|
+
# Class responsible for the CLI logic based on thor
|
9
|
+
class CLI < Thor
|
10
|
+
# Error raised by this runner
|
11
|
+
Error = Class.new(StandardError)
|
12
|
+
|
13
|
+
def self.exit_on_failure?
|
14
|
+
true
|
15
|
+
end
|
16
|
+
|
17
|
+
desc "version", "Xantora version"
|
18
|
+
def version
|
19
|
+
puts "v#{Xantora::VERSION}"
|
20
|
+
end
|
21
|
+
map %w[--version -v] => :version
|
22
|
+
|
23
|
+
desc "convert", "Convert Antora document(s) to PDF"
|
24
|
+
option :source,
|
25
|
+
desc: "Antora document (.adoc) or modules path",
|
26
|
+
aliases: %w[-s],
|
27
|
+
required: true
|
28
|
+
option :output,
|
29
|
+
desc: "destination file or directory",
|
30
|
+
aliases: %w[-o],
|
31
|
+
default: Dir.pwd
|
32
|
+
option :attributes,
|
33
|
+
desc: "additional ascciidoc page attributes (attr1:value1 attr2:value2 ...)",
|
34
|
+
type: :hash,
|
35
|
+
aliases: %w[-a],
|
36
|
+
default: {}
|
37
|
+
option :to_attachments,
|
38
|
+
desc: "place output in the modules attachment-dir",
|
39
|
+
type: :boolean,
|
40
|
+
aliases: %w[-A],
|
41
|
+
default: false
|
42
|
+
def convert
|
43
|
+
if File.directory? options[:source]
|
44
|
+
puts "[.] Scanning module directory for .adoc files ..."
|
45
|
+
Dir.glob("#{options[:source]}/**/pages/*.adoc") { |file| convert_document(file, options) }
|
46
|
+
elsif options[:source].end_with? ".adoc"
|
47
|
+
convert_document(options[:source], options)
|
48
|
+
else
|
49
|
+
puts "[error] No valid source detected."
|
50
|
+
exit 1
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
no_tasks do
|
55
|
+
def convert_document(file, options)
|
56
|
+
doc = Document.new(file)
|
57
|
+
spinner = TTY::Spinner.new(
|
58
|
+
"[:spinner] Converting #{File.basename(doc.path)} to #{destination(doc, options)} ... ",
|
59
|
+
format: :bouncing_ball
|
60
|
+
)
|
61
|
+
spinner.auto_spin
|
62
|
+
capture_stderr { doc.convert_to_pdf(options) }
|
63
|
+
spinner.success "(successful)"
|
64
|
+
rescue StandardError => e
|
65
|
+
spinner.error("(error: #{e.message})")
|
66
|
+
end
|
67
|
+
|
68
|
+
def destination(doc, options)
|
69
|
+
options[:output]&.end_with?(".pdf") ? File.basename(options[:output]) : doc.pdf_name
|
70
|
+
end
|
71
|
+
|
72
|
+
def capture_stderr
|
73
|
+
real_stderr = $stderr
|
74
|
+
$stderr = StringIO.new
|
75
|
+
yield
|
76
|
+
$stderr.string
|
77
|
+
ensure
|
78
|
+
$stderr = real_stderr
|
79
|
+
end
|
80
|
+
end
|
81
|
+
end
|
82
|
+
end
|
@@ -0,0 +1,100 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "asciidoctor"
|
4
|
+
require "asciidoctor-pdf"
|
5
|
+
|
6
|
+
module Xantora
|
7
|
+
# Document represents a Antora document and holds the functionality for PDF conversion based on asciidoctor-pdf
|
8
|
+
class Document
|
9
|
+
attr_reader :path
|
10
|
+
|
11
|
+
GEM_DIR = File.expand_path("../..", __dir__)
|
12
|
+
|
13
|
+
def initialize(path, options = {})
|
14
|
+
@path = path
|
15
|
+
@to_dir = options[:to_dir]
|
16
|
+
@to_file = options[:to_file]
|
17
|
+
end
|
18
|
+
|
19
|
+
def component_dir
|
20
|
+
File.expand_path "../../../", File.dirname(@path)
|
21
|
+
end
|
22
|
+
|
23
|
+
def module_dir
|
24
|
+
File.expand_path "..", File.dirname(@path)
|
25
|
+
end
|
26
|
+
|
27
|
+
def page_component_title
|
28
|
+
YAML.load_file(
|
29
|
+
File.join(component_dir, "antora.yml")
|
30
|
+
)["title"]
|
31
|
+
rescue StandardError
|
32
|
+
""
|
33
|
+
end
|
34
|
+
|
35
|
+
def pdf_name
|
36
|
+
name = File.basename(@path, ".adoc")
|
37
|
+
if name == "index"
|
38
|
+
doc = Asciidoctor.load_file @path, safe: :safe
|
39
|
+
name = doc.doctitle ? doc.doctitle.gsub(/[^0-9A-Za-z.\-]/, "_") : "index"
|
40
|
+
end
|
41
|
+
"#{name}.pdf"
|
42
|
+
end
|
43
|
+
|
44
|
+
def pdf_path(options)
|
45
|
+
if options[:to_attachments]
|
46
|
+
File.join(attachments_path, pdf_name)
|
47
|
+
elsif !options[:output]
|
48
|
+
pdf_name
|
49
|
+
elsif options[:output].end_with? ".pdf"
|
50
|
+
options[:output]
|
51
|
+
else
|
52
|
+
File.join options[:output], pdf_name
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
def attachments_path
|
57
|
+
if Dir.exist? File.join(module_dir, "attachments")
|
58
|
+
File.join(module_dir, "attachments")
|
59
|
+
else
|
60
|
+
File.join(module_dir, "assets/attachments")
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
def images_dir
|
65
|
+
if Dir.exist? File.join(module_dir, "images")
|
66
|
+
"../images"
|
67
|
+
elsif Dir.exist? File.join(module_dir, "assets/images")
|
68
|
+
"../assets/images"
|
69
|
+
else
|
70
|
+
""
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
def asciidoctor_options(options)
|
75
|
+
a_opts = {}
|
76
|
+
a_opts[:to_file] = pdf_path(options)
|
77
|
+
a_opts[:backend] = "pdf"
|
78
|
+
a_opts[:safe] = :unsafe
|
79
|
+
a_opts[:attributes] = asciidoc_attributes(options[:attributes])
|
80
|
+
a_opts
|
81
|
+
end
|
82
|
+
|
83
|
+
def asciidoc_attributes(optional_attributes = {})
|
84
|
+
attributes = {
|
85
|
+
"toc" => "auto",
|
86
|
+
"toclevels" => "1",
|
87
|
+
"pdf-theme" => "puzzle",
|
88
|
+
"pdf-themesdir" => File.join(GEM_DIR, "asciidoctor-pdf/themes"),
|
89
|
+
"pdf-fontsdir" => "#{File.join(GEM_DIR, "asciidoctor-pdf/fonts")};GEM_FONTS_DIR",
|
90
|
+
"imagesdir" => images_dir
|
91
|
+
}
|
92
|
+
attributes.merge!({ "page-component-title" => page_component_title })
|
93
|
+
attributes.merge(optional_attributes)
|
94
|
+
end
|
95
|
+
|
96
|
+
def convert_to_pdf(options = {})
|
97
|
+
Asciidoctor.convert_file @path, asciidoctor_options(options)
|
98
|
+
end
|
99
|
+
end
|
100
|
+
end
|
data/xantora.gemspec
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative "lib/xantora/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |spec|
|
6
|
+
spec.name = "xantora"
|
7
|
+
spec.version = Xantora::VERSION
|
8
|
+
spec.authors = ["Nik Wolfgramm"]
|
9
|
+
spec.email = ["wolfgramm@puzzle.ch"]
|
10
|
+
|
11
|
+
spec.summary = "A PDF-converter for Antora AsciiDoc documents"
|
12
|
+
spec.description = "A Ruby CLI-Tool which makes it easy to export PDF's from your Antora AsciiDoc-Files"
|
13
|
+
spec.homepage = "https://github.com/niwo/xantora"
|
14
|
+
spec.license = "MIT"
|
15
|
+
spec.required_ruby_version = ">= 2.7.0"
|
16
|
+
|
17
|
+
spec.metadata["homepage_uri"] = spec.homepage
|
18
|
+
spec.metadata["source_code_uri"] = spec.homepage
|
19
|
+
|
20
|
+
spec.files = Dir.chdir(File.expand_path(__dir__)) do
|
21
|
+
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{\A(?:test|spec|features)/}) }
|
22
|
+
end
|
23
|
+
spec.bindir = "exe"
|
24
|
+
spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
|
25
|
+
spec.require_paths = ["lib"]
|
26
|
+
|
27
|
+
spec.add_dependency "asciidoctor-pdf", "~> 1.6.0"
|
28
|
+
spec.add_dependency "thor", "~> 1.1.0"
|
29
|
+
spec.add_dependency "tty-spinner", "~> 0.9.3"
|
30
|
+
end
|
metadata
ADDED
@@ -0,0 +1,112 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: xantora
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Nik Wolfgramm
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2021-08-16 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: asciidoctor-pdf
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 1.6.0
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 1.6.0
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: thor
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 1.1.0
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: 1.1.0
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: tty-spinner
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: 0.9.3
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: 0.9.3
|
55
|
+
description: A Ruby CLI-Tool which makes it easy to export PDF's from your Antora
|
56
|
+
AsciiDoc-Files
|
57
|
+
email:
|
58
|
+
- wolfgramm@puzzle.ch
|
59
|
+
executables:
|
60
|
+
- xantora
|
61
|
+
extensions: []
|
62
|
+
extra_rdoc_files: []
|
63
|
+
files:
|
64
|
+
- ".gitignore"
|
65
|
+
- ".gitlab-ci.yml"
|
66
|
+
- ".rubocop.yml"
|
67
|
+
- Gemfile
|
68
|
+
- Gemfile.lock
|
69
|
+
- LICENSE.txt
|
70
|
+
- README.md
|
71
|
+
- Rakefile
|
72
|
+
- asciidoctor-pdf/fonts/DroidSansFallback.ttf
|
73
|
+
- asciidoctor-pdf/fonts/Roboto-Bold.ttf
|
74
|
+
- asciidoctor-pdf/fonts/Roboto-BoldItalic.ttf
|
75
|
+
- asciidoctor-pdf/fonts/Roboto-Italic.ttf
|
76
|
+
- asciidoctor-pdf/fonts/Roboto-Regular.ttf
|
77
|
+
- asciidoctor-pdf/themes/puzzle-logo.png
|
78
|
+
- asciidoctor-pdf/themes/puzzle-theme.yml
|
79
|
+
- bin/console
|
80
|
+
- bin/setup
|
81
|
+
- exe/xantora
|
82
|
+
- lib/xantora.rb
|
83
|
+
- lib/xantora/cli.rb
|
84
|
+
- lib/xantora/document.rb
|
85
|
+
- lib/xantora/version.rb
|
86
|
+
- xantora.gemspec
|
87
|
+
homepage: https://github.com/niwo/xantora
|
88
|
+
licenses:
|
89
|
+
- MIT
|
90
|
+
metadata:
|
91
|
+
homepage_uri: https://github.com/niwo/xantora
|
92
|
+
source_code_uri: https://github.com/niwo/xantora
|
93
|
+
post_install_message:
|
94
|
+
rdoc_options: []
|
95
|
+
require_paths:
|
96
|
+
- lib
|
97
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
98
|
+
requirements:
|
99
|
+
- - ">="
|
100
|
+
- !ruby/object:Gem::Version
|
101
|
+
version: 2.7.0
|
102
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
103
|
+
requirements:
|
104
|
+
- - ">="
|
105
|
+
- !ruby/object:Gem::Version
|
106
|
+
version: '0'
|
107
|
+
requirements: []
|
108
|
+
rubygems_version: 3.1.2
|
109
|
+
signing_key:
|
110
|
+
specification_version: 4
|
111
|
+
summary: A PDF-converter for Antora AsciiDoc documents
|
112
|
+
test_files: []
|