asciidoctor-fb2 0.5.1 → 0.7.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 191e9008da2371aa05c0f179901db6e452a1a15306cf9672243461dd60843279
4
- data.tar.gz: 2e553897787cd096962a72a448a1763ad9584a73987ddb660735e354fa38f1f8
3
+ metadata.gz: c86e38af133de5a0b984e4ba98639333a483284a205f7fd118334248e48adfd5
4
+ data.tar.gz: 6192121701d79223d0c44cb032c87b8be375b0177ce540394a1ef81ddc4a87e5
5
5
  SHA512:
6
- metadata.gz: 3ce011a8f7b12cf2a2fc1c82882fc746b8e22905606afa78d6dec730617c06abb9f9925f4d2ead4dcf9d8a96e843ae7786af66ff65cfe4d12e2fb47f5592c7ed
7
- data.tar.gz: ef5fc4eb0738e197709aefb45b4385ef7af908c9a5435092ec0119864389130364e306a3044dc50072f37602c8fd6cfbb9e72879b5445ae23241ea481518db2b
6
+ metadata.gz: 10f7f74ccaf1289f9a6cccfcf6c10938949bd959b22af0fd53a0a60b52a80f010dc0bb9b4bbbb6b3256a1a2f320f78f273e10d0a5339e47f6ddf397e2b726a88
7
+ data.tar.gz: 500756c54b05993d00fa197079a59f19a11824121bfcfae61a1e1fea64b9ba2b7603717a53c6e4bfafefe44300779d264d7a73046a0909414991e369e26899f6
@@ -5,23 +5,24 @@ jobs:
5
5
  runs-on: ubuntu-latest
6
6
  steps:
7
7
  - name: Checkout
8
- uses: actions/checkout@v2
8
+ uses: actions/checkout@v3
9
9
  - name: Set up Ruby
10
10
  uses: ruby/setup-ruby@v1
11
11
  with:
12
- ruby-version: '3.0'
12
+ ruby-version: '3.1'
13
13
  bundler-cache: true
14
14
  - name: Lint
15
15
  run: bundle exec rake lint
16
16
  test:
17
17
  strategy:
18
18
  matrix:
19
- ruby: ['jruby', '2.4', '2.5', '2.6', '2.7', '3.0']
19
+ # Test oldest and newest supported versions
20
+ ruby: ['jruby-9.2', 'jruby-9.4', '2.5', '3.1']
20
21
  os: [ubuntu-latest, macos-latest, windows-latest]
21
22
  runs-on: ${{ matrix.os }}
22
23
  steps:
23
24
  - name: Checkout
24
- uses: actions/checkout@v2
25
+ uses: actions/checkout@v3
25
26
  - name: Set up Ruby
26
27
  uses: ruby/setup-ruby@v1
27
28
  with:
@@ -7,13 +7,26 @@ jobs:
7
7
  build:
8
8
  runs-on: ubuntu-latest
9
9
  steps:
10
- - uses: actions/checkout@v2
10
+ - uses: actions/checkout@v3
11
11
  - name: Set up Ruby
12
12
  uses: ruby/setup-ruby@v1
13
13
  with:
14
- ruby-version: '3.0'
14
+ ruby-version: '3.1'
15
15
  - name: Publish to RubyGems.org
16
16
  uses: dawidd6/action-publish-gem@v1
17
17
  with:
18
18
  api_key: ${{ secrets.RUBYGEMS_API_KEY }}
19
-
19
+ - name: Set release version
20
+ run: echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV
21
+ - name: Announcement
22
+ uses: zulip/github-actions-zulip/send-message@v1
23
+ with:
24
+ email: ${{ secrets.ZULIP_USERNAME }}
25
+ api-key: ${{ secrets.ZULIP_API_KEY }}
26
+ organization-url: 'https://asciidoctor.zulipchat.com'
27
+ to: '279652'
28
+ type: 'stream'
29
+ topic: 'releases'
30
+ content: |
31
+ Asciidoctor-FB2 ${{ env.RELEASE_VERSION }} is out!
32
+ https://github.com/asciidoctor/asciidoctor-fb2/releases/tag/${{ env.RELEASE_VERSION }}
data/CHANGELOG.adoc CHANGED
@@ -7,6 +7,17 @@
7
7
  This document provides a high-level view of the changes to the {project-name} by release.
8
8
  For a detailed view of what has changed, refer to the {uri-project}/commits/master[commit history] on GitHub.
9
9
 
10
+ == 0.7.0 (2022-12-18) - @slonopotamus
11
+
12
+ * fix handling of image paths with path separators
13
+ * add support for image alignment. https://github.com/asciidoctor/asciidoctor-fb2/issues/16[#16]
14
+ * add support for floating images
15
+ * add naive admonition icons support. https://github.com/asciidoctor/asciidoctor-fb2/issues/18[#18]
16
+
17
+ == 0.6.0 (2022-10-30) - @slonopotamus
18
+
19
+ * bump fb2rb to 0.7.0
20
+
10
21
  == 0.5.1 (2021-04-01) - @slonopotamus
11
22
 
12
23
  * add basic support for stem blocks
data/README.adoc CHANGED
@@ -3,13 +3,14 @@ Marat Radchenko <marat@slonopotamus.org>
3
3
  :project-name: Asciidoctor FB2
4
4
  :project-handle: asciidoctor-fb2
5
5
  :slug: asciidoctor/{project-handle}
6
+ :source-highlighter: rouge
6
7
  :uri-project: https://github.com/{slug}
7
8
  :uri-ci: {uri-project}/actions?query=branch%3Amaster
8
9
  :uri-gem: https://rubygems.org/gems/{project-handle}
9
10
 
10
11
  image:https://img.shields.io/badge/zulip-join_chat-brightgreen.svg[project chat,link=https://asciidoctor.zulipchat.com/]
11
12
  image:https://img.shields.io/gem/v/{project-handle}.svg[Latest Release,link={uri-gem}]
12
- image:{uri-project}/workflows/CI/badge.svg?branch=master[Build Status,link={uri-ci}]
13
+ image:{uri-project}/workflows/CI/badge.svg?branch=main[Build Status,link={uri-ci}]
13
14
 
14
15
  {project-name} is an Asciidoctor extension for converting AsciiDoc documents directly to the FB2 e-book format.
15
16
 
@@ -39,7 +40,7 @@ This command should be available on your PATH if you installed the `{project-han
39
40
  Otherwise, you can find the command in the [path]_bin_ folder of the project.
40
41
  We also recommend specifying an output directory using the `-D` option flag.
41
42
 
42
- [source,shell script]
43
+ [source,shell]
43
44
  ----
44
45
  $ asciidoctor-fb2 -D output path/to/book.adoc
45
46
  ----
@@ -10,7 +10,7 @@ Gem::Specification.new do |s|
10
10
  s.summary = 'Converts AsciiDoc documents to FB2 e-book formats'
11
11
  s.homepage = 'https://github.com/asciidoctor/asciidoctor-fb2'
12
12
  s.license = 'MIT'
13
- s.required_ruby_version = '>= 2.4.0'
13
+ s.required_ruby_version = '>= 2.5.0'
14
14
 
15
15
  s.files = `git ls-files`.split("\n").reject { |f| f.match(%r{^spec/}) }
16
16
  s.executables = `git ls-files -- bin/*`.split("\n").map do |f|
@@ -19,13 +19,13 @@ Gem::Specification.new do |s|
19
19
  s.require_paths = ['lib']
20
20
 
21
21
  s.add_runtime_dependency 'asciidoctor', '~> 2.0'
22
- s.add_runtime_dependency 'fb2rb', '~> 0.6.0'
22
+ s.add_runtime_dependency 'fb2rb', '>= 0.6', '< 0.8'
23
23
  s.add_runtime_dependency 'mime-types', '~> 3.0'
24
24
 
25
25
  s.add_development_dependency 'asciidoctor-diagram', '~> 2.0'
26
26
  s.add_development_dependency 'rake', '~> 13.0'
27
- s.add_development_dependency 'rspec', '~> 3.10.0'
28
- s.add_development_dependency 'rubocop', '~> 1.12.0'
29
- s.add_development_dependency 'rubocop-rake', '~> 0.5.0'
30
- s.add_development_dependency 'rubocop-rspec', '~> 2.2.0'
27
+ s.add_development_dependency 'rspec', '~> 3.12.0'
28
+ s.add_development_dependency 'rubocop', '~> 1.28.2'
29
+ s.add_development_dependency 'rubocop-rake', '~> 0.6.0'
30
+ s.add_development_dependency 'rubocop-rspec', '~> 2.10.0'
31
31
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Asciidoctor
4
4
  module FB2
5
- VERSION = '0.5.1'
5
+ VERSION = '0.7.0'
6
6
  end
7
7
  end
@@ -282,7 +282,7 @@ module Asciidoctor
282
282
  # @param node [Asciidoctor::Inline]
283
283
  def convert_inline_image(node)
284
284
  image_attrs = register_binary(node, node.image_uri(node.target), 'image')
285
- %(<image #{image_attrs * ' '}/>)
285
+ %(<image #{image_attrs.sort! * ' '}/>)
286
286
  end
287
287
 
288
288
  # @param node [Asciidoctor::Inline]
@@ -301,11 +301,18 @@ module Asciidoctor
301
301
  end
302
302
 
303
303
  # @param node [Asciidoctor::Block]
304
- def convert_image(node)
304
+ def convert_image(node) # rubocop:disable Metrics/AbcSize
305
305
  image_attrs = register_binary(node, node.image_uri(node.attr('target')), 'image')
306
306
  image_attrs << %(title="#{node.captioned_title}") if node.title?
307
307
  image_attrs << %(id="#{node.id}") if node.id
308
- %(<p><image #{image_attrs * ' '}/></p>)
308
+
309
+ p_style = []
310
+ p_style << %(float: #{node.attr 'float'}) if node.attr? 'float'
311
+ p_style << %(text-align: #{node.attr 'align'}) if node.attr? 'align'
312
+
313
+ p_attrs = []
314
+ p_attrs << %(style="#{p_style.sort! * '; '}") unless p_style.empty?
315
+ %(<p #{p_attrs.sort! * ' '}><image #{image_attrs.sort! * ' '}/></p>)
309
316
  end
310
317
 
311
318
  # @param node [Asciidoctor::Block]
@@ -339,8 +346,8 @@ module Asciidoctor
339
346
 
340
347
  if File.readable?(fs_path)
341
348
  # Calibre fails to load images if they contain path separators
342
- target.sub!('/', '_')
343
- target.sub!('\\', '_')
349
+ target.gsub!('/', '_')
350
+ target.gsub!('\\', '_')
344
351
 
345
352
  mime_type = determine_mime_type(target, media_type)
346
353
  @book.add_binary(target, fs_path, mime_type)
@@ -352,11 +359,26 @@ module Asciidoctor
352
359
  image_attrs << %(alt="#{node.attr('alt')}") if node.attr? 'alt'
353
360
  end
354
361
 
362
+ ADMONITION_ICONS = {
363
+ 'caution' => '🔥',
364
+ 'important' => '❗',
365
+ 'note' => 'ℹ️',
366
+ 'tip' => '💡',
367
+ 'warning' => '⚠️'
368
+ }.freeze
369
+
355
370
  # @param node [Asciidoctor::Block]
356
371
  def convert_admonition(node)
357
- lines = [%(<p><strong>#{node.title || node.caption}:</strong>
358
- #{node.content}
359
- </p>)]
372
+ lines = ['<p>']
373
+
374
+ lines << if node.document.attr?('icons', 'font') && (icon = ADMONITION_ICONS[node.attr 'name'])
375
+ %(#{icon} )
376
+ else
377
+ %(<strong>#{node.title || node.caption}:</strong>)
378
+ end
379
+
380
+ lines << node.content
381
+ lines << '</p>'
360
382
  lines << '<empty-line/>' unless node.has_role?('last')
361
383
  lines * "\n"
362
384
  end
@@ -465,7 +487,7 @@ module Asciidoctor
465
487
  ]
466
488
  cell_attrs << %(colspan="#{cell.colspan}") if cell.colspan
467
489
  cell_attrs << %(rowspan="#{cell.rowspan}") if cell.rowspan
468
- lines << %(<#{cell_tag_name} #{cell_attrs * ' '}>#{cell_content}</#{cell_tag_name}>)
490
+ lines << %(<#{cell_tag_name} #{cell_attrs.sort! * ' '}>#{cell_content}</#{cell_tag_name}>)
469
491
  end
470
492
  lines << '</tr>'
471
493
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: asciidoctor-fb2
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.1
4
+ version: 0.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Marat Radchenko
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-04-01 00:00:00.000000000 Z
11
+ date: 2022-12-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: asciidoctor
@@ -28,16 +28,22 @@ dependencies:
28
28
  name: fb2rb
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - "~>"
31
+ - - ">="
32
32
  - !ruby/object:Gem::Version
33
- version: 0.6.0
33
+ version: '0.6'
34
+ - - "<"
35
+ - !ruby/object:Gem::Version
36
+ version: '0.8'
34
37
  type: :runtime
35
38
  prerelease: false
36
39
  version_requirements: !ruby/object:Gem::Requirement
37
40
  requirements:
38
- - - "~>"
41
+ - - ">="
39
42
  - !ruby/object:Gem::Version
40
- version: 0.6.0
43
+ version: '0.6'
44
+ - - "<"
45
+ - !ruby/object:Gem::Version
46
+ version: '0.8'
41
47
  - !ruby/object:Gem::Dependency
42
48
  name: mime-types
43
49
  requirement: !ruby/object:Gem::Requirement
@@ -86,56 +92,56 @@ dependencies:
86
92
  requirements:
87
93
  - - "~>"
88
94
  - !ruby/object:Gem::Version
89
- version: 3.10.0
95
+ version: 3.12.0
90
96
  type: :development
91
97
  prerelease: false
92
98
  version_requirements: !ruby/object:Gem::Requirement
93
99
  requirements:
94
100
  - - "~>"
95
101
  - !ruby/object:Gem::Version
96
- version: 3.10.0
102
+ version: 3.12.0
97
103
  - !ruby/object:Gem::Dependency
98
104
  name: rubocop
99
105
  requirement: !ruby/object:Gem::Requirement
100
106
  requirements:
101
107
  - - "~>"
102
108
  - !ruby/object:Gem::Version
103
- version: 1.12.0
109
+ version: 1.28.2
104
110
  type: :development
105
111
  prerelease: false
106
112
  version_requirements: !ruby/object:Gem::Requirement
107
113
  requirements:
108
114
  - - "~>"
109
115
  - !ruby/object:Gem::Version
110
- version: 1.12.0
116
+ version: 1.28.2
111
117
  - !ruby/object:Gem::Dependency
112
118
  name: rubocop-rake
113
119
  requirement: !ruby/object:Gem::Requirement
114
120
  requirements:
115
121
  - - "~>"
116
122
  - !ruby/object:Gem::Version
117
- version: 0.5.0
123
+ version: 0.6.0
118
124
  type: :development
119
125
  prerelease: false
120
126
  version_requirements: !ruby/object:Gem::Requirement
121
127
  requirements:
122
128
  - - "~>"
123
129
  - !ruby/object:Gem::Version
124
- version: 0.5.0
130
+ version: 0.6.0
125
131
  - !ruby/object:Gem::Dependency
126
132
  name: rubocop-rspec
127
133
  requirement: !ruby/object:Gem::Requirement
128
134
  requirements:
129
135
  - - "~>"
130
136
  - !ruby/object:Gem::Version
131
- version: 2.2.0
137
+ version: 2.10.0
132
138
  type: :development
133
139
  prerelease: false
134
140
  version_requirements: !ruby/object:Gem::Requirement
135
141
  requirements:
136
142
  - - "~>"
137
143
  - !ruby/object:Gem::Version
138
- version: 2.2.0
144
+ version: 2.10.0
139
145
  description:
140
146
  email:
141
147
  - marat@slonopotamus.org
@@ -177,14 +183,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
177
183
  requirements:
178
184
  - - ">="
179
185
  - !ruby/object:Gem::Version
180
- version: 2.4.0
186
+ version: 2.5.0
181
187
  required_rubygems_version: !ruby/object:Gem::Requirement
182
188
  requirements:
183
189
  - - ">="
184
190
  - !ruby/object:Gem::Version
185
191
  version: '0'
186
192
  requirements: []
187
- rubygems_version: 3.2.3
193
+ rubygems_version: 3.3.26
188
194
  signing_key:
189
195
  specification_version: 4
190
196
  summary: Converts AsciiDoc documents to FB2 e-book formats