asciidoctor-html5s 0.1.0.beta.5 → 0.1.0.beta.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: 6edb5fed9a549c826fe6cee650e693100626d9e1ad1fe464c1c35e458f7ee7b0
4
- data.tar.gz: 80d81e62638bca8e8df3025dac8f6fe8be758941fa8887368acc12b7d8adae95
3
+ metadata.gz: ed1c08fd98586b0e12dcb8ccdfde03a6006ced31e6ba71535c681b039d580218
4
+ data.tar.gz: 697a89107371a410e9d240d08e55a8901bff9e458ac8a5b06ef481eca326c3d4
5
5
  SHA512:
6
- metadata.gz: 7aac1db96dd77420ff7e42deefdf378a0f965cc85b61db850cc37e24bbd81ab037371521049cac9315166a581ba2d9bc5aabda6574eb088b50ecac921209f038
7
- data.tar.gz: 4a9a897ac7ca4fdba8ca69452a8e5c8b1138f69d6f6fa096cd859022609f1955fa40788c79f328c34575c388feb034fcc28a58cf7cd91745fda8f424f8287ff1
6
+ metadata.gz: bc1b4d6df407f6d34eef7ba932ca4881749141bec6ba6dd93f7368245915690adf4ca04115fb3033907ab1e64fdd20feb60e1ebac2d1ae462770f8028de41d7a
7
+ data.tar.gz: 90fca83f5e268fd9b2ee21e2b3910a677aee549d3d98145ba063289b7112d7d07b77f53938b3f351020b04491ad7bebad9233bd895894a46d82809a15cf98b2e
data/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  The MIT License
2
2
 
3
- Copyright 2014-2017 Jakub Jirutka <jakub@jirutka.cz> and the Asciidoctor Project.
3
+ Copyright 2014-2018 Jakub Jirutka <jakub@jirutka.cz>.
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
data/README.adoc CHANGED
@@ -83,6 +83,15 @@ console.log(html)
83
83
  ----
84
84
 
85
85
 
86
+ === Attributes
87
+
88
+ Extra attributes accepted by the {gem-name}:
89
+
90
+ html5s-force-stem-type::
91
+ Ignore declared (e.g. `:stem: asciimath`, `asciimath:[]`, ...) and default type of the stem macro/block and always use the one specified by this attribute. +
92
+ Asciidoctor hard-codes the default stem type to “asciimath”, which is not supported by KaTeX.
93
+
94
+
86
95
  == License
87
96
 
88
97
  This project is licensed under http://opensource.org/licenses/MIT/[MIT License].
@@ -18,7 +18,6 @@ with common typographic CSS styles.
18
18
  EOF
19
19
 
20
20
  s.files = Dir['data/**/*', 'lib/**/*', '*.gemspec', 'LICENSE*', 'README*']
21
- s.has_rdoc = false
22
21
 
23
22
  s.required_ruby_version = '>= 2.0'
24
23
 
@@ -26,7 +25,7 @@ EOF
26
25
  s.add_runtime_dependency 'thread_safe', '~> 0.3.4'
27
26
 
28
27
  s.add_development_dependency 'asciidoctor-doctest', '= 2.0.0.beta.4'
29
- s.add_development_dependency 'asciidoctor-templates-compiler', '~> 0.3.0'
28
+ s.add_development_dependency 'asciidoctor-templates-compiler', '~> 0.4.1'
30
29
  s.add_development_dependency 'bundler', '~> 1.6'
31
30
  s.add_development_dependency 'coderay', '~> 1.1'
32
31
  s.add_development_dependency 'rake', '~> 10.0'
@@ -1,4 +1,5 @@
1
1
  require 'asciidoctor/html5s'
2
+ require 'asciidoctor/html5s/logger'
2
3
  require 'date' unless RUBY_PLATFORM == 'opal'
3
4
 
4
5
  # Add custom functions to this module that you want to use in your Slim
@@ -37,6 +38,11 @@ module Slim::Helpers
37
38
  meta param source track wbr)
38
39
 
39
40
 
41
+ # @return [Logger]
42
+ def log
43
+ @_html5s_logger ||= ::Asciidoctor::Html5s::Logging.default_logger
44
+ end
45
+
40
46
  ##
41
47
  # Captures the given block for later yield.
42
48
  #
@@ -224,6 +230,10 @@ module Slim::Helpers
224
230
  # @return [String] the delimited equation.
225
231
  #
226
232
  def delimit_stem(equation, type)
233
+ if (@_html5s_stem_type ||= document.attr('html5s-force-stem-type'))
234
+ type = @_html5s_stem_type
235
+ end
236
+
227
237
  if is_a? ::Asciidoctor::Block
228
238
  open, close = ::Asciidoctor::BLOCK_MATH_DELIMITERS[type.to_sym]
229
239
  else
@@ -439,7 +449,7 @@ module Slim::Helpers
439
449
  # otherwise prints warning and returns +false+.
440
450
  def abstract_allowed?
441
451
  if result = (parent == document && document.doctype == 'book')
442
- puts 'asciidoctor: WARNING: abstract block cannot be used in a document
452
+ log.warn 'asciidoctor: WARNING: abstract block cannot be used in a document
443
453
  without a title when doctype is book. Excluding block content.'
444
454
  end
445
455
  !result
@@ -450,7 +460,7 @@ without a title when doctype is book. Excluding block content.'
450
460
  # prints warning and returns +false+.
451
461
  def partintro_allowed?
452
462
  if result = (level != 0 || parent.context != :section || document.doctype != 'book')
453
- puts "asciidoctor: ERROR: partintro block can only be used when doctype
463
+ log.warn "asciidoctor: ERROR: partintro block can only be used when doctype
454
464
  is book and it's a child of a book part. Excluding block content."
455
465
  end
456
466
  !result
@@ -9,16 +9,20 @@ module Asciidoctor::Html5s
9
9
  class AttachedColistTreeprocessor < ::Asciidoctor::Extensions::Treeprocessor
10
10
 
11
11
  def process(document)
12
- document.find_by(context: :colist) do |colist|
12
+ # XXX: We have to defer deletion of the original colist nodes after
13
+ # the #find_by iteration is done to make it work under Opal.
14
+ # See <https://github.com/jirutka/asciidoctor-html5s/issues/7>.
15
+ document.find_by(context: :colist).reduce([]) { |memo, colist|
13
16
  blocks = colist.parent.blocks
14
17
  colist_idx = blocks.find_index(colist)
15
18
  prev_block = blocks[colist_idx - 1] if colist_idx
16
19
 
17
20
  if prev_block && prev_block.node_name == 'listing'
18
- blocks.delete_at(colist_idx) # mutates node's blocks list!
19
21
  prev_block.instance_variable_set(:@html5s_colist, colist)
22
+ memo << ->() { blocks.delete_at(colist_idx) } # mutates node's blocks list!
20
23
  end
21
- end
24
+ memo
25
+ }.each(&:call)
22
26
  end
23
27
  end
24
28
  end
@@ -6,6 +6,7 @@ class Asciidoctor::Html5s::Converter < ::Asciidoctor::Converter::Base
6
6
  #------------------------------ Begin of Helpers ------------------------------#
7
7
 
8
8
  require 'asciidoctor/html5s'
9
+ require 'asciidoctor/html5s/logger'
9
10
  require 'date' unless RUBY_PLATFORM == 'opal'
10
11
 
11
12
  # Add custom functions to this module that you want to use in your Slim
@@ -44,6 +45,11 @@ class Asciidoctor::Html5s::Converter < ::Asciidoctor::Converter::Base
44
45
  meta param source track wbr)
45
46
 
46
47
 
48
+ # @return [Logger]
49
+ def log
50
+ @_html5s_logger ||= ::Asciidoctor::Html5s::Logging.default_logger
51
+ end
52
+
47
53
  ##
48
54
  # Captures the given block for later yield.
49
55
  #
@@ -231,6 +237,10 @@ class Asciidoctor::Html5s::Converter < ::Asciidoctor::Converter::Base
231
237
  # @return [String] the delimited equation.
232
238
  #
233
239
  def delimit_stem(equation, type)
240
+ if (@_html5s_stem_type ||= document.attr('html5s-force-stem-type'))
241
+ type = @_html5s_stem_type
242
+ end
243
+
234
244
  if is_a? ::Asciidoctor::Block
235
245
  open, close = ::Asciidoctor::BLOCK_MATH_DELIMITERS[type.to_sym]
236
246
  else
@@ -446,7 +456,7 @@ class Asciidoctor::Html5s::Converter < ::Asciidoctor::Converter::Base
446
456
  # otherwise prints warning and returns +false+.
447
457
  def abstract_allowed?
448
458
  if result = (parent == document && document.doctype == 'book')
449
- puts 'asciidoctor: WARNING: abstract block cannot be used in a document
459
+ log.warn 'asciidoctor: WARNING: abstract block cannot be used in a document
450
460
  without a title when doctype is book. Excluding block content.'
451
461
  end
452
462
  !result
@@ -457,7 +467,7 @@ class Asciidoctor::Html5s::Converter < ::Asciidoctor::Converter::Base
457
467
  # prints warning and returns +false+.
458
468
  def partintro_allowed?
459
469
  if result = (level != 0 || parent.context != :section || document.doctype != 'book')
460
- puts "asciidoctor: ERROR: partintro block can only be used when doctype
470
+ log.warn "asciidoctor: ERROR: partintro block can only be used when doctype
461
471
  is book and it's a child of a book part. Excluding block content."
462
472
  end
463
473
  !result
@@ -681,9 +691,10 @@ class Asciidoctor::Html5s::Converter < ::Asciidoctor::Converter::Base
681
691
 
682
692
  def initialize(backend, opts = {})
683
693
  super
684
- basebackend "html"
685
- outfilesuffix ".html"
686
- filetype "html"
694
+ basebackend "html" if respond_to? :basebackend
695
+ outfilesuffix ".html" if respond_to? :outfilesuffix
696
+ filetype "html" if respond_to? :filetype
697
+ supports_templates if respond_to? :supports_templates
687
698
  end
688
699
 
689
700
  def convert(node, transform = nil, opts = {})
@@ -0,0 +1,30 @@
1
+ # frozen_string_literal: true
2
+ require 'logger' unless RUBY_PLATFORM == 'opal'
3
+ require 'asciidoctor' unless RUBY_PLATFORM == 'opal'
4
+ require 'asciidoctor/html5s/version'
5
+
6
+ module Asciidoctor::Html5s
7
+ # Helper module for getting default Logger based on the Asciidoctor version.
8
+ module Logging
9
+ module_function
10
+
11
+ # @return [Logger] the default `Asciidoctor::Logger` if using Asciidoctor
12
+ # 1.5.7 or later, or Ruby's `Logger` that outputs to `STDERR`.
13
+ def default_logger
14
+ if defined? ::Asciidoctor::LoggerManager
15
+ ::Asciidoctor::LoggerManager.logger
16
+ elsif defined? ::Logger
17
+ ::Logger.new(STDERR)
18
+ else
19
+ # Fake logger for Opal.
20
+ # TODO: Remove after update to Asciidoctor 1.5.7 or Opal with Logger.
21
+ Object.new.tap do |o|
22
+ # rubocop: disable MethodMissing
23
+ def o.method_missing(_, *args)
24
+ STDERR.puts(*args)
25
+ end
26
+ end
27
+ end
28
+ end
29
+ end
30
+ end
@@ -1,5 +1,5 @@
1
1
  module Asciidoctor
2
2
  module Html5s
3
- VERSION = '0.1.0.beta.5'.freeze
3
+ VERSION = '0.1.0.beta.6'.freeze
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: asciidoctor-html5s
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0.beta.5
4
+ version: 0.1.0.beta.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jakub Jirutka
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-03-02 00:00:00.000000000 Z
11
+ date: 2018-08-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: asciidoctor
@@ -58,14 +58,14 @@ dependencies:
58
58
  requirements:
59
59
  - - "~>"
60
60
  - !ruby/object:Gem::Version
61
- version: 0.3.0
61
+ version: 0.4.1
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
66
  - - "~>"
67
67
  - !ruby/object:Gem::Version
68
- version: 0.3.0
68
+ version: 0.4.1
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: bundler
71
71
  requirement: !ruby/object:Gem::Requirement
@@ -199,6 +199,7 @@ files:
199
199
  - lib/asciidoctor/html5s.rb
200
200
  - lib/asciidoctor/html5s/attached_colist_treeprocessor.rb
201
201
  - lib/asciidoctor/html5s/converter.rb
202
+ - lib/asciidoctor/html5s/logger.rb
202
203
  - lib/asciidoctor/html5s/version.rb
203
204
  homepage: https://github.com/jirutka/asciidoctor-html5s
204
205
  licenses:
@@ -220,7 +221,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
220
221
  version: 1.3.1
221
222
  requirements: []
222
223
  rubyforge_project:
223
- rubygems_version: 2.7.6
224
+ rubygems_version: 2.7.7
224
225
  signing_key:
225
226
  specification_version: 4
226
227
  summary: Semantic HTML5 backend (converter) for Asciidoctor