jekyll-printing-press 1.0.0rc3 → 1.0.0rc4

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 54d4243961a802a3ad5db3245750d0f48105d4fb65f4058f3e7c680f1b864a1e
4
- data.tar.gz: 6d7db7c1e3b0596d4b59cd70ac71357ff5ebcfcdd3ba4286c2e8abe9c46c52b3
3
+ metadata.gz: ddf0c1b01ef8662f17a69e8416e8cfae8cd6e6958513b9263a6682cf6ac3c112
4
+ data.tar.gz: 8206bbf208f55c798f05015e7fd7d8d05c66328f1e260b7695f6697a1011a4d3
5
5
  SHA512:
6
- metadata.gz: b7d1d3c4c1f6ca056fb3bf724e7794189e6f1c7908885b921f8c64c913e81634f77a1f82791d8408eaeac45ffb49e6e067e6f4098cd55b962ad5be56f0b75876
7
- data.tar.gz: b043c56f39ecb001ff5e599b5c763697dc30a4017b69151adfa3987d5010921115d13cafe395969283aef4d7bf27c363c3a7660b4d167dda5dcfdcb0c3ae1861
6
+ metadata.gz: a882aeb9e3df66f6ae565ecbb74152a38ba9429bc4acc4217295e684841f6a6d9419f4c898ccc2b724b07d60efe01c25a7abbccda782823e438606137dde4117
7
+ data.tar.gz: c013c1222d8424c8c48891b04f069ffe805ee36ce9bc2bde6955ab300742930c6f353578febf55b390153cc7fc21c50352961da4006e18287eb9760565cf6889
@@ -60,9 +60,7 @@ module Jekyll
60
60
  #
61
61
  # @return [Symbol]
62
62
  def papersize
63
- @papersize ||= options.dig(:pdf, :variable).find do |v|
64
- v.start_with? 'papersize='
65
- end&.split('=', 2)&.last&.to_sym
63
+ @papersize ||= options.dig(:pdf, :variable, 'papersize')
66
64
  end
67
65
 
68
66
  # Merge all options and remove the ones disabled
@@ -105,6 +105,7 @@ module Jekyll
105
105
  end
106
106
 
107
107
  data['binary'] = binary?
108
+ data['format'] = collection.label
108
109
 
109
110
  source_document.data['formats'] ||= []
110
111
  source_document.data['formats'] << self
@@ -147,18 +148,8 @@ module Jekyll
147
148
  BINARY_FORMATS.include? type
148
149
  end
149
150
 
150
- # Generate the destination from the URL and change .html to the
151
- # output extension.
152
- #
153
- # @return [String]
154
- def destination(dest)
155
- super.sub(/\.html\z/, output_ext)
156
- end
157
-
158
151
  def url
159
- @url ||= super.tap do |u|
160
- u << data['slug'] << output_ext if u.end_with? '/'
161
- end
152
+ @url ||= "#{super.delete_suffix('/index.html').delete_suffix('.html')}#{output_ext}"
162
153
  end
163
154
 
164
155
  # We don't have layouts (yet?)
@@ -26,7 +26,6 @@ module Jekyll
26
26
  source_document.source_document.data['bound'] =
27
27
  source_document.data['bound'] = self
28
28
 
29
- source_document.source_document.data['formats'] ||= []
30
29
  source_document.source_document.data['formats'] << self
31
30
 
32
31
  nil
@@ -10,6 +10,11 @@ module Jekyll
10
10
  module Documents
11
11
  # A document composed of several documents
12
12
  class Multiple < Jekyll::Pandoc::Document
13
+ # TODO: Usar Paru para parsear correctamente en lugar de usar
14
+ # expresiones regulares
15
+ FIND_H6 = /^\#{6}\s+(.*)$/
16
+ FIND_HEADINGS = /^(\#{1,5}\s)/
17
+
13
18
  # Documents group
14
19
  #
15
20
  # @return [Array]
@@ -29,7 +34,7 @@ module Jekyll
29
34
  #
30
35
  # @return [Hash]
31
36
  def data
32
- @data ||= { 'multiple' => true }
37
+ @data ||= { 'multiple' => true, 'formats' => [] }
33
38
  end
34
39
 
35
40
  # The content is a concatenated string of source_documents
@@ -41,7 +46,7 @@ module Jekyll
41
46
  # @return [nil]
42
47
  def read_content(**)
43
48
  self.content = source_documents.map do |doc|
44
- ["\n\n# #{doc['title']} {##{extract_id(doc)} data-chapter-title=true}", doc.content]
49
+ ["\n\n# #{doc['title']} {##{extract_id(doc)} data-chapter-title=true}", move_headings(replace_h6(doc.content))]
45
50
  end.flatten.join("\n\n")
46
51
 
47
52
  nil
@@ -68,7 +73,23 @@ module Jekyll
68
73
  #
69
74
  # @return [String]
70
75
  def extract_id(document)
71
- document['uuid'] || document.id.tr('/', '-').sub(/\A-/, '')
76
+ document['uuid'] || document.id.tr('/', '-').delete_prefix('-')
77
+ end
78
+
79
+ # Replaces H6 headers
80
+ #
81
+ # @param content [String]
82
+ # @return [String]
83
+ def replace_h6(content)
84
+ content.gsub(FIND_H6, "**\\1**")
85
+ end
86
+
87
+ # Moves headings one level to the right
88
+ #
89
+ # @param content [String]
90
+ # @return [String]
91
+ def move_headings(content)
92
+ content.gsub(FIND_HEADINGS, "#\\1")
72
93
  end
73
94
  end
74
95
  end
@@ -23,13 +23,15 @@ module Jekyll
23
23
  #
24
24
  # @return [Array]
25
25
  def source_documents
26
- @source_documents ||= site.collections['pdf'].docs
26
+ @source_documents ||= site.collections['pdf']&.docs || []
27
27
  end
28
28
 
29
29
  # Generate a {Jekyll::Pandoc::Documents::Bound} per document
30
30
  #
31
31
  # @return [nil]
32
32
  def generate_documents!
33
+ return if source_documents.empty?
34
+
33
35
  source_documents.each do |document|
34
36
  collection_for('bound').tap do |col|
35
37
  col.docs << Jekyll::Pandoc::Documents::Bound.new(document.path, site: site, collection: col,
@@ -23,13 +23,15 @@ module Jekyll
23
23
  #
24
24
  # @return [Array]
25
25
  def source_documents
26
- @source_documents ||= site.collections['pdf'].docs
26
+ @source_documents ||= site.collections['pdf']&.docs || []
27
27
  end
28
28
 
29
29
  # Generate a {Jekyll::Pandoc::Documents::Imposed} per document
30
30
  #
31
31
  # @return [nil]
32
32
  def generate_documents!
33
+ return if source_documents.empty?
34
+
33
35
  source_documents.each do |document|
34
36
  collection_for('imposed').tap do |col|
35
37
  col.docs << Jekyll::Pandoc::Documents::Imposed.new(document.path, site: site, collection: col,
@@ -15,7 +15,23 @@ module Jekyll
15
15
  def from(options)
16
16
  Paru::Pandoc.new.tap do |paru|
17
17
  options.each do |option, value|
18
- paru.send option, value
18
+ case value
19
+ when Hash
20
+ value.each_pair do |key, v|
21
+ case v
22
+ when TrueClass, FalseClass
23
+ paru.send option, key
24
+ when String
25
+ paru.send option, "#{key}=#{v}"
26
+ when Array
27
+ paru.send option, "#{key}=#{v.join(',')}"
28
+ end
29
+ end
30
+ else
31
+ paru.send option, value
32
+ end
33
+ rescue NoMethodError => e
34
+ Jekyll.logger.warn 'Printing Press:', "Option #{option} not supported by Paru, skipping"
19
35
  end
20
36
  end
21
37
  end
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'pdf/info'
3
+ require 'pdf/reader'
4
4
  require_relative 'utils'
5
5
 
6
6
  module Jekyll
@@ -61,7 +61,7 @@ module Jekyll
61
61
  #
62
62
  # @return [Symbol]
63
63
  def sheetsize
64
- @sheetsize ||= site.config.dig('pandoc', 'printing', 'sheetsize').to_sym.tap do |x|
64
+ @sheetsize ||= site.config.dig('pandoc', 'printing', 'sheetsize')&.to_sym.tap do |x|
65
65
  raise NoMethodError unless SHEET_SIZES.key? x
66
66
  end
67
67
  rescue NoMethodError
@@ -73,11 +73,11 @@ module Jekyll
73
73
  #
74
74
  # @return [Symbol]
75
75
  def pagesize
76
- @pagesize ||= site.config['pandoc'].papersize.tap do |x|
76
+ @pagesize ||= site.config['pandoc'].papersize&.to_sym.tap do |x|
77
77
  raise NoMethodError unless SHEET_SIZES.key? x
78
78
  end
79
79
  rescue NoMethodError
80
- Jekyll.logger.warn 'Printing Press', "Papersize is missing or incorrect, please add one of #{SHEET_SIZES.keys.join(', ')} to PDF format in _config.yml"
80
+ Jekyll.logger.warn 'Printing Press:', "Papersize is missing or incorrect, please add one of #{SHEET_SIZES.keys.join(', ')} to PDF format in _config.yml"
81
81
  raise ArgumentError, 'Please configure the jekyll-pandoc-multiple-formats plugin'
82
82
  end
83
83
 
@@ -90,16 +90,9 @@ module Jekyll
90
90
 
91
91
  # Page count in the source PDF
92
92
  #
93
- # PDFInfo requires `pdfinfo` from Poppler installed.
94
- #
95
- # XXX: It may be possible to extract the metadata just by
96
- # `#binread`ing the file, but apparently PDF has many ways to
97
- # inform the page count, so we're adding this dependency for
98
- # simplicity.
99
- #
100
93
  # @return [Integer]
101
94
  def page_count
102
- @page_count ||= PDF::Info.new(document.source_document.tempfile.path).metadata[:page_count]
95
+ @page_count ||= PDF::Reader.new(document.source_document.tempfile.path).page_count
103
96
  end
104
97
 
105
98
  # Pages per sheet
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jekyll-printing-press
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0rc3
4
+ version: 1.0.0rc4
5
5
  platform: ruby
6
6
  authors:
7
7
  - fauno
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2025-12-28 00:00:00.000000000 Z
11
+ date: 2026-01-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: jekyll
@@ -31,19 +31,19 @@ dependencies:
31
31
  - !ruby/object:Gem::Version
32
32
  version: '5'
33
33
  - !ruby/object:Gem::Dependency
34
- name: pdf_info
34
+ name: pdf-reader
35
35
  requirement: !ruby/object:Gem::Requirement
36
36
  requirements:
37
37
  - - "~>"
38
38
  - !ruby/object:Gem::Version
39
- version: 0.5.0
39
+ version: '12'
40
40
  type: :runtime
41
41
  prerelease: false
42
42
  version_requirements: !ruby/object:Gem::Requirement
43
43
  requirements:
44
44
  - - "~>"
45
45
  - !ruby/object:Gem::Version
46
- version: 0.5.0
46
+ version: '12'
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: paru
49
49
  requirement: !ruby/object:Gem::Requirement