asciidoctor 2.0.5 → 2.0.6

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: ec7900aac00c81a12784dcbb8b50fe83084e3d520c2c680779b259dbf9a6f8f1
4
- data.tar.gz: 3b54226a56beb58044ce34b008affde322631ec524f865595c5a1be2ed02b16b
3
+ metadata.gz: 9066105e2eb3a4a1eef1b7e03730a3daa81e6b0abcfebef789e5c02e4a070db8
4
+ data.tar.gz: 902d0e58872adbafcd81a6faa7373b4e207ad5596ec37f3d1a01a6e83fabfac2
5
5
  SHA512:
6
- metadata.gz: 96e57a742f978398f3152a057a865211441dcfad9daff9b1666f8360d663069d6b45e683e20873eafe3cde527c3cdde1a6cfe929aba0e1fb45db71a88064c8be
7
- data.tar.gz: 8e798546816dc70277be8cd1a8766b124cddd931fd09a6c28e83d4737d248651e510fd81de5c516f303faf9a979d71bb41dd62c30b34916a9612449b6646d35c
6
+ metadata.gz: a77b68c94c63ba1f783cc1e2af7ead46415a8f49f85195f7367f94506b12d1ad19310b142249d534cc61513633ba4ba8e931e744922f4a3bfe92e9b0e9e4d97d
7
+ data.tar.gz: d0a13bb0dfe883cb0a8e6ae949e3f6178de75f57d6d6a35f90ee5954f8b85faa6c76b0c3244a07aca43478daab789a33b3f780faa1e083b27bba5a1eb9f5cf74
@@ -13,6 +13,19 @@ endif::[]
13
13
  This document provides a high-level view of the changes introduced in Asciidoctor by release.
14
14
  For a detailed view of what has changed, refer to the {uri-repo}/commits/master[commit history] on GitHub.
15
15
 
16
+ == 2.0.6 (2019-04-04) - @mojavelinux
17
+
18
+ Bug Fixes::
19
+
20
+ * assume implicit AsciiDoc extension on interdoc xref macro target with no extension (e.g., `document#`); restores 1.5.x behavior (#3231)
21
+ * don't fail to load application if call to Dir.home fails; use a rescue with fallback values (#3238)
22
+ * Helpers.rootname should only consider final path segment when dropping file extension
23
+
24
+ Improvements::
25
+
26
+ * implement Helpers.extname as a more efficient and flexible File.extname method
27
+ * check for AsciiDoc file extension using end_with? instead of resolving the extname and using a lookup
28
+
16
29
  == 2.0.5 (2019-04-01) - @mojavelinux
17
30
 
18
31
  Bug Fixes::
@@ -1,6 +1,6 @@
1
1
  = Asciidoctor
2
2
  Dan Allen <https://github.com/mojavelinux[@mojavelinux]>; Sarah White <https://github.com/graphitefriction[@graphitefriction]>; Ryan Waldron <https://github.com/erebor[@erebor]>
3
- v2.0.5, 2019-04-01
3
+ v2.0.6, 2019-04-04
4
4
  // settings:
5
5
  :idprefix:
6
6
  :idseparator: -
@@ -17,7 +17,7 @@ ifdef::env-github[]
17
17
  :warning-caption: :warning:
18
18
  endif::[]
19
19
  // Variables:
20
- :release-version: 2.0.5
20
+ :release-version: 2.0.6
21
21
  // URIs:
22
22
  :uri-org: https://github.com/asciidoctor
23
23
  :uri-repo: {uri-org}/asciidoctor
@@ -1,6 +1,6 @@
1
1
  = Asciidoctor
2
2
  Dan Allen <https://github.com/mojavelinux[@mojavelinux]>; Sarah White <https://github.com/graphitefriction[@graphitefriction]>; Ryan Waldron <https://github.com/erebor[@erebor]>
3
- v2.0.5, 2019-04-01
3
+ v2.0.6, 2019-04-04
4
4
  // settings:
5
5
  :idprefix:
6
6
  :idseparator: -
@@ -17,7 +17,7 @@ ifdef::env-github[]
17
17
  :warning-caption: :warning:
18
18
  endif::[]
19
19
  // Variables:
20
- :release-version: 2.0.5
20
+ :release-version: 2.0.6
21
21
  // URIs:
22
22
  :uri-org: https://github.com/asciidoctor
23
23
  :uri-repo: {uri-org}/asciidoctor
@@ -1,6 +1,6 @@
1
1
  = Asciidoctor
2
2
  Dan Allen <https://github.com/mojavelinux[@mojavelinux]>; Sarah White <https://github.com/graphitefriction[@graphitefriction]>; Ryan Waldron <https://github.com/erebor[@erebor]>
3
- v2.0.5, 2019-04-01
3
+ v2.0.6, 2019-04-04
4
4
  // settings:
5
5
  :page-layout: base
6
6
  :idprefix:
@@ -18,7 +18,7 @@ ifdef::env-github[]
18
18
  :warning-caption: :warning:
19
19
  endif::[]
20
20
  // Variables:
21
- :release-version: 2.0.5
21
+ :release-version: 2.0.6
22
22
  // URIs:
23
23
  :uri-org: https://github.com/asciidoctor
24
24
  :uri-repo: {uri-org}/asciidoctor
@@ -1,6 +1,6 @@
1
1
  = Asciidoctor
2
2
  Dan Allen <https://github.com/mojavelinux[@mojavelinux]>; Sarah White <https://github.com/graphitefriction[@graphitefriction]>; Ryan Waldron <https://github.com/erebor[@erebor]>
3
- v2.0.5, 2019-04-01
3
+ v2.0.6, 2019-04-04
4
4
  // settings:
5
5
  :page-layout: base
6
6
  :idprefix:
@@ -18,7 +18,7 @@ ifdef::env-github[]
18
18
  :warning-caption: :warning:
19
19
  endif::[]
20
20
  // Variables:
21
- :release-version: 2.0.5
21
+ :release-version: 2.0.6
22
22
  // URIs:
23
23
  :uri-org: https://github.com/asciidoctor
24
24
  :uri-repo: {uri-org}/asciidoctor
@@ -1,6 +1,6 @@
1
1
  = Asciidoctor
2
2
  Dan Allen <https://github.com/mojavelinux[@mojavelinux]>; Sarah White <https://github.com/graphitefriction[@graphitefriction]>; Ryan Waldron <https://github.com/erebor[@erebor]>
3
- v2.0.5, 2019-04-01
3
+ v2.0.6, 2019-04-04
4
4
  // settings:
5
5
  :idprefix:
6
6
  :idseparator: -
@@ -17,7 +17,7 @@ ifdef::env-github[]
17
17
  :warning-caption: :warning:
18
18
  endif::[]
19
19
  // Variables:
20
- :release-version: 2.0.5
20
+ :release-version: 2.0.6
21
21
  // URIs:
22
22
  :uri-org: https://github.com/asciidoctor
23
23
  :uri-repo: {uri-org}/asciidoctor
@@ -185,7 +185,8 @@ module Asciidoctor
185
185
  DATA_DIR = ::File.join ROOT_DIR, 'data'
186
186
 
187
187
  # The user's home directory, as best we can determine it
188
- USER_HOME = ::Dir.home
188
+ # IMPORTANT this rescue is required for running Asciidoctor on GitHub.com
189
+ USER_HOME = ::Dir.home rescue (::ENV['HOME'] || ::Dir.pwd)
189
190
 
190
191
  # The newline character used for output; stored in constant table as an optimization
191
192
  LF = ?\n
@@ -248,7 +249,8 @@ module Asciidoctor
248
249
  'asciidoc' => '.adoc'
249
250
  }
250
251
 
251
- # Set of file extensions recognized as AsciiDoc documents (stored as a truth hash)
252
+ # A map of file extensions that are recognized as AsciiDoc documents
253
+ # TODO .txt should be deprecated
252
254
  ASCIIDOC_EXTENSIONS = {
253
255
  '.adoc' => true,
254
256
  '.asciidoc' => true,
@@ -1278,7 +1280,7 @@ module Asciidoctor
1278
1280
  # TODO cli checks if input path can be read and is file, but might want to add check to API too
1279
1281
  attrs['docfile'] = input_path = ::File.absolute_path input.path
1280
1282
  attrs['docdir'] = ::File.dirname input_path
1281
- attrs['docname'] = Helpers.basename input_path, (attrs['docfilesuffix'] = ::File.extname input_path)
1283
+ attrs['docname'] = Helpers.basename input_path, (attrs['docfilesuffix'] = Helpers.extname input_path)
1282
1284
  source = input.read
1283
1285
  elsif input.respond_to? :read
1284
1286
  # NOTE tty, pipes & sockets can't be rewound, but can't be sniffed easily either
@@ -280,11 +280,9 @@ class AbstractNode
280
280
  # Returns A String reference or data URI for an icon image
281
281
  def icon_uri name
282
282
  if attr? 'icon'
283
- # Ruby 2.3 requires the extra brackets around the attr method call
284
- if (::File.extname (icon = (attr 'icon'))).empty?
285
- # QUESTION should we be adding the extension if the icon is an absolute URI?
286
- icon = %(#{icon}.#{@document.attr 'icontype', 'png'})
287
- end
283
+ icon = attr 'icon'
284
+ # QUESTION should we be adding the extension if the icon is an absolute URI?
285
+ icon = %(#{icon}.#{@document.attr 'icontype', 'png'}) unless Helpers.extname? icon
288
286
  else
289
287
  icon = %(#{name}.#{@document.attr 'icontype', 'png'})
290
288
  end
@@ -359,9 +357,12 @@ class AbstractNode
359
357
  #
360
358
  # Returns A String data URI containing the content of the target image
361
359
  def generate_data_uri(target_image, asset_dir_key = nil)
362
- ext = ::File.extname target_image
363
- # QUESTION what if ext is empty?
364
- mimetype = (ext == '.svg' ? 'image/svg+xml' : %(image/#{ext.slice 1, ext.length}))
360
+ if (ext = Helpers.extname target_image, nil)
361
+ mimetype = ext == '.svg' ? 'image/svg+xml' : %(image/#{ext.slice 1, ext.length})
362
+ else
363
+ mimetype = 'application/octet-stream'
364
+ end
365
+
365
366
  if asset_dir_key
366
367
  image_path = normalize_system_path(target_image, @document.attr(asset_dir_key), nil, target_name: 'image')
367
368
  else
@@ -105,9 +105,12 @@ class Converter::Html5Converter < Converter::Base
105
105
  result << %(<meta name="copyright" content="#{node.attr 'copyright'}"#{slash}>) if node.attr? 'copyright'
106
106
  if node.attr? 'favicon'
107
107
  if (icon_href = node.attr 'favicon').empty?
108
- icon_href, icon_type = 'favicon.ico', 'image/x-icon'
108
+ icon_href = 'favicon.ico'
109
+ icon_type = 'image/x-icon'
110
+ elsif (icon_ext = Helpers.extname icon_href, nil)
111
+ icon_type = icon_ext == '.ico' ? 'image/x-icon' : %(image/#{icon_ext.slice 1, icon_ext.length})
109
112
  else
110
- icon_type = (icon_ext = ::File.extname icon_href) == '.ico' ? 'image/x-icon' : %(image/#{icon_ext.slice 1, icon_ext.length})
113
+ icon_type = 'image/x-icon'
111
114
  end
112
115
  result << %(<link rel="icon" type="#{icon_type}" href="#{icon_href}"#{slash}>)
113
116
  end
@@ -310,7 +310,7 @@ class Document < AbstractBlock
310
310
  attr_overrides[key.downcase] = val
311
311
  end
312
312
  if (to_file = options[:to_file])
313
- attr_overrides['outfilesuffix'] = ::File.extname to_file
313
+ attr_overrides['outfilesuffix'] = Helpers.extname to_file
314
314
  end
315
315
  # safely resolve the safe mode from const, int or string
316
316
  if !(safe_mode = options[:safe])
@@ -159,7 +159,7 @@ module Helpers
159
159
 
160
160
  # Public: Removes the file extension from filename and returns the result
161
161
  #
162
- # filename - The String file name to process
162
+ # filename - The String file name to process; expected to be a posix path
163
163
  #
164
164
  # Examples
165
165
  #
@@ -168,7 +168,11 @@ module Helpers
168
168
  #
169
169
  # Returns the String filename with the file extension removed
170
170
  def self.rootname filename
171
- filename.slice 0, ((filename.rindex '.') || filename.length)
171
+ if (last_dot_idx = filename.rindex '.')
172
+ (filename.index '/', last_dot_idx) ? filename : (filename.slice 0, last_dot_idx)
173
+ else
174
+ filename
175
+ end
172
176
  end
173
177
 
174
178
  # Public: Retrieves the basename of the filename, optionally removing the extension, if present
@@ -188,12 +192,48 @@ module Helpers
188
192
  # Returns the String filename with leading directories removed and, if specified, the extension removed
189
193
  def self.basename filename, drop_ext = nil
190
194
  if drop_ext
191
- ::File.basename filename, (drop_ext == true ? (::File.extname filename) : drop_ext)
195
+ ::File.basename filename, (drop_ext == true ? (extname filename) : drop_ext)
192
196
  else
193
197
  ::File.basename filename
194
198
  end
195
199
  end
196
200
 
201
+ # Public: Returns whether this path has a file extension.
202
+ #
203
+ # path - The path String to check; expects a posix path
204
+ #
205
+ # Returns true if the path has a file extension, false otherwise
206
+ def self.extname? path
207
+ (last_dot_idx = path.rindex '.') && !(path.index '/', last_dot_idx)
208
+ end
209
+
210
+ # Public: Retrieves the file extension of the specified path. The file extension is the portion of the path in the
211
+ # last path segment starting from the last period.
212
+ #
213
+ # This method differs from File.extname in that it gives us control over the fallback value and is more efficient.
214
+ #
215
+ # path - The path String in which to look for a file extension
216
+ # fallback - The fallback String to return if no file extension is present (optional, default: '')
217
+ #
218
+ # Returns the String file extension (with the leading dot included) or the fallback value if the path has no file extension.
219
+ if ::File::ALT_SEPARATOR
220
+ def self.extname path, fallback = ''
221
+ if (last_dot_idx = path.rindex '.')
222
+ (path.index '/', last_dot_idx) || (path.index ::File::ALT_SEPARATOR, last_dot_idx) ? fallback : (path.slice last_dot_idx, path.length)
223
+ else
224
+ fallback
225
+ end
226
+ end
227
+ else
228
+ def self.extname path, fallback = ''
229
+ if (last_dot_idx = path.rindex '.')
230
+ (path.index '/', last_dot_idx) ? fallback : (path.slice last_dot_idx, path.length)
231
+ else
232
+ fallback
233
+ end
234
+ end
235
+ end
236
+
197
237
  # Internal: Make a directory, ensuring all parent directories exist.
198
238
  def self.mkdir_p dir
199
239
  unless ::File.directory? dir
@@ -686,20 +686,20 @@ class PreprocessorReader < Reader
686
686
  (@dir = file.dup).path = (dir = ::File.dirname file.path) == '/' ? '' : dir
687
687
  file = file.to_s
688
688
  end
689
- path ||= ::File.basename file
689
+ @path = (path ||= ::File.basename file)
690
690
  # only process lines in AsciiDoc files
691
- @process_lines = ASCIIDOC_EXTENSIONS[::File.extname file]
691
+ if (@process_lines = file.end_with?(*ASCIIDOC_EXTENSIONS.keys))
692
+ @includes[path.slice 0, (path.rindex '.')] = attributes['partial-option'] ? nil : true
693
+ end
692
694
  else
693
695
  @dir = '.'
694
696
  # we don't know what file type we have, so assume AsciiDoc
695
697
  @process_lines = true
696
- end
697
-
698
- if path
699
- @path = path
700
- @includes[Helpers.rootname path] = attributes['partial-option'] ? nil : true if @process_lines
701
- else
702
- @path = '<stdin>'
698
+ if (@path = path)
699
+ @includes[Helpers.rootname path] = attributes['partial-option'] ? nil : true
700
+ else
701
+ @path = '<stdin>'
702
+ end
703
703
  end
704
704
 
705
705
  @lineno = lineno
@@ -751,20 +751,26 @@ module Substitutors
751
751
  path = refid.chop
752
752
  end
753
753
  if macro
754
- src2src = (path = path.slice 0, path.length - 5) if path.end_with? '.adoc'
755
- elsif (last_dot_idx = path.rindex '.') && ASCIIDOC_EXTENSIONS[path.slice last_dot_idx, path.length]
756
- src2src = (path = path.slice 0, last_dot_idx)
754
+ if path.end_with? '.adoc'
755
+ src2src = path = path.slice 0, path.length - 5
756
+ elsif !(Helpers.extname? path)
757
+ src2src = path
758
+ end
759
+ elsif path.end_with?(*ASCIIDOC_EXTENSIONS.keys)
760
+ src2src = path = path.slice 0, (path.rindex '.')
757
761
  else
758
762
  src2src = path
759
763
  end
760
764
  else
761
765
  target, fragment = refid, (refid.slice 1, refid.length)
762
766
  end
763
- elsif macro && (refid.include? '.')
767
+ elsif macro
764
768
  if refid.end_with? '.adoc'
765
- src2src = (path = refid.slice 0, refid.length - 5)
766
- else
769
+ src2src = path = refid.slice 0, refid.length - 5
770
+ elsif Helpers.extname? refid
767
771
  path = refid
772
+ else
773
+ fragment = refid
768
774
  end
769
775
  else
770
776
  fragment = refid
@@ -1,4 +1,4 @@
1
1
  # frozen_string_literal: true
2
2
  module Asciidoctor
3
- VERSION = '2.0.5'
3
+ VERSION = '2.0.6'
4
4
  end
@@ -1,13 +1,13 @@
1
1
  '\" t
2
2
  .\" Title: asciidoctor
3
3
  .\" Author: Dan Allen, Sarah White, Ryan Waldron
4
- .\" Generator: Asciidoctor 2.0.5
5
- .\" Date: 2019-04-01
4
+ .\" Generator: Asciidoctor 2.0.6
5
+ .\" Date: 2019-04-04
6
6
  .\" Manual: Asciidoctor Manual
7
- .\" Source: Asciidoctor 2.0.5
7
+ .\" Source: Asciidoctor 2.0.6
8
8
  .\" Language: English
9
9
  .\"
10
- .TH "ASCIIDOCTOR" "1" "2019-04-01" "Asciidoctor 2.0.5" "Asciidoctor Manual"
10
+ .TH "ASCIIDOCTOR" "1" "2019-04-04" "Asciidoctor 2.0.6" "Asciidoctor Manual"
11
11
  .ie \n(.g .ds Aq \(aq
12
12
  .el .ds Aq '
13
13
  .ss \n[.ss] 0
@@ -2,7 +2,7 @@
2
2
  Dan Allen; Sarah White; Ryan Waldron
3
3
  :doctype: manpage
4
4
  :man manual: Asciidoctor Manual
5
- :man source: Asciidoctor 2.0.5
5
+ :man source: Asciidoctor 2.0.6
6
6
  :page-layout: base
7
7
 
8
8
  == NAME
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: asciidoctor
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.5
4
+ version: 2.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dan Allen
@@ -13,7 +13,7 @@ authors:
13
13
  autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
- date: 2019-04-01 00:00:00.000000000 Z
16
+ date: 2019-04-04 00:00:00.000000000 Z
17
17
  dependencies:
18
18
  - !ruby/object:Gem::Dependency
19
19
  name: asciimath