asciidoctor 1.5.8 → 2.0.0.rc.1

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.
Files changed (158) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.adoc +162 -17
  3. data/LICENSE +1 -1
  4. data/README-de.adoc +12 -13
  5. data/README-fr.adoc +11 -12
  6. data/README-jp.adoc +11 -12
  7. data/README-zh_CN.adoc +12 -13
  8. data/README.adoc +6 -7
  9. data/asciidoctor.gemspec +19 -24
  10. data/bin/asciidoctor +5 -4
  11. data/data/reference/syntax.adoc +283 -0
  12. data/data/stylesheets/asciidoctor-default.css +56 -52
  13. data/data/stylesheets/coderay-asciidoctor.css +7 -9
  14. data/lib/asciidoctor.rb +171 -232
  15. data/lib/asciidoctor/abstract_block.rb +96 -105
  16. data/lib/asciidoctor/abstract_node.rb +118 -139
  17. data/lib/asciidoctor/attribute_list.rb +10 -14
  18. data/lib/asciidoctor/block.rb +20 -19
  19. data/lib/asciidoctor/callouts.rb +4 -2
  20. data/lib/asciidoctor/cli.rb +3 -2
  21. data/lib/asciidoctor/cli/invoker.rb +14 -21
  22. data/lib/asciidoctor/cli/options.rb +64 -54
  23. data/lib/asciidoctor/converter.rb +357 -185
  24. data/lib/asciidoctor/converter/composite.rb +40 -48
  25. data/lib/asciidoctor/converter/docbook5.rb +604 -640
  26. data/lib/asciidoctor/converter/html5.rb +949 -963
  27. data/lib/asciidoctor/converter/manpage.rb +569 -548
  28. data/lib/asciidoctor/converter/template.rb +231 -272
  29. data/lib/asciidoctor/core_ext.rb +5 -18
  30. data/lib/asciidoctor/core_ext/float/truncate.rb +19 -0
  31. data/lib/asciidoctor/core_ext/match_data/names.rb +7 -0
  32. data/lib/asciidoctor/core_ext/nil_or_empty.rb +1 -0
  33. data/lib/asciidoctor/core_ext/regexp/is_match.rb +4 -2
  34. data/lib/asciidoctor/document.rb +399 -377
  35. data/lib/asciidoctor/extensions.rb +72 -140
  36. data/lib/asciidoctor/helpers.rb +122 -83
  37. data/lib/asciidoctor/inline.rb +5 -1
  38. data/lib/asciidoctor/list.rb +13 -11
  39. data/lib/asciidoctor/logging.rb +17 -16
  40. data/lib/asciidoctor/parser.rb +390 -423
  41. data/lib/asciidoctor/path_resolver.rb +10 -5
  42. data/lib/asciidoctor/reader.rb +286 -263
  43. data/lib/asciidoctor/rouge_ext.rb +39 -0
  44. data/lib/asciidoctor/section.rb +9 -8
  45. data/lib/asciidoctor/stylesheets.rb +19 -37
  46. data/lib/asciidoctor/substitutors.rb +364 -509
  47. data/lib/asciidoctor/syntax_highlighter.rb +238 -0
  48. data/lib/asciidoctor/syntax_highlighter/coderay.rb +87 -0
  49. data/lib/asciidoctor/syntax_highlighter/highlightjs.rb +26 -0
  50. data/lib/asciidoctor/syntax_highlighter/html_pipeline.rb +10 -0
  51. data/lib/asciidoctor/syntax_highlighter/prettify.rb +27 -0
  52. data/lib/asciidoctor/syntax_highlighter/pygments.rb +149 -0
  53. data/lib/asciidoctor/syntax_highlighter/rouge.rb +129 -0
  54. data/lib/asciidoctor/table.rb +73 -66
  55. data/lib/asciidoctor/timings.rb +4 -2
  56. data/lib/asciidoctor/version.rb +2 -1
  57. data/lib/asciidoctor/writer.rb +30 -0
  58. data/man/asciidoctor.1 +19 -15
  59. data/man/asciidoctor.adoc +14 -12
  60. metadata +69 -216
  61. data/CONTRIBUTING.adoc +0 -185
  62. data/Gemfile +0 -60
  63. data/Rakefile +0 -129
  64. data/bin/asciidoctor-safe +0 -15
  65. data/features/open_block.feature +0 -92
  66. data/features/pass_block.feature +0 -66
  67. data/features/step_definitions.rb +0 -49
  68. data/features/text_formatting.feature +0 -57
  69. data/features/xref.feature +0 -1039
  70. data/lib/asciidoctor/converter/base.rb +0 -59
  71. data/lib/asciidoctor/converter/docbook45.rb +0 -93
  72. data/lib/asciidoctor/converter/factory.rb +0 -226
  73. data/lib/asciidoctor/core_ext/1.8.7/base64/strict_encode64.rb +0 -6
  74. data/lib/asciidoctor/core_ext/1.8.7/concurrent/hash.rb +0 -5
  75. data/lib/asciidoctor/core_ext/1.8.7/hash/key.rb +0 -4
  76. data/lib/asciidoctor/core_ext/1.8.7/io/binread.rb +0 -6
  77. data/lib/asciidoctor/core_ext/1.8.7/io/write.rb +0 -5
  78. data/lib/asciidoctor/core_ext/1.8.7/string/chr.rb +0 -6
  79. data/lib/asciidoctor/core_ext/1.8.7/string/limit_bytesize.rb +0 -29
  80. data/lib/asciidoctor/core_ext/1.8.7/symbol/empty.rb +0 -6
  81. data/lib/asciidoctor/core_ext/1.8.7/symbol/length.rb +0 -6
  82. data/lib/asciidoctor/core_ext/string/limit_bytesize.rb +0 -10
  83. data/test/api_test.rb +0 -1240
  84. data/test/attribute_list_test.rb +0 -242
  85. data/test/attributes_test.rb +0 -1623
  86. data/test/blocks_test.rb +0 -3870
  87. data/test/converter_test.rb +0 -470
  88. data/test/document_test.rb +0 -1853
  89. data/test/extensions_test.rb +0 -1560
  90. data/test/fixtures/asciidoc_index.txt +0 -521
  91. data/test/fixtures/basic-docinfo-footer.html +0 -6
  92. data/test/fixtures/basic-docinfo-footer.xml +0 -8
  93. data/test/fixtures/basic-docinfo.html +0 -1
  94. data/test/fixtures/basic-docinfo.xml +0 -4
  95. data/test/fixtures/basic.asciidoc +0 -5
  96. data/test/fixtures/chapter-a.adoc +0 -3
  97. data/test/fixtures/child-include.adoc +0 -5
  98. data/test/fixtures/circle.svg +0 -9
  99. data/test/fixtures/custom-backends/erb/html5/block_paragraph.html.erb +0 -6
  100. data/test/fixtures/custom-backends/haml/docbook45/block_paragraph.xml.haml +0 -6
  101. data/test/fixtures/custom-backends/haml/html5-tweaks/block_paragraph.html.haml +0 -1
  102. data/test/fixtures/custom-backends/haml/html5/block_paragraph.html.haml +0 -3
  103. data/test/fixtures/custom-backends/haml/html5/block_sidebar.html.haml +0 -5
  104. data/test/fixtures/custom-backends/slim/docbook45/block_paragraph.xml.slim +0 -6
  105. data/test/fixtures/custom-backends/slim/html5/block_paragraph.html.slim +0 -3
  106. data/test/fixtures/custom-backends/slim/html5/block_sidebar.html.slim +0 -5
  107. data/test/fixtures/custom-docinfodir/basic-docinfo.html +0 -1
  108. data/test/fixtures/custom-docinfodir/docinfo.html +0 -1
  109. data/test/fixtures/docinfo-footer.html +0 -1
  110. data/test/fixtures/docinfo-footer.xml +0 -9
  111. data/test/fixtures/docinfo.html +0 -1
  112. data/test/fixtures/docinfo.xml +0 -3
  113. data/test/fixtures/doctime-localtime.adoc +0 -2
  114. data/test/fixtures/dot.gif +0 -0
  115. data/test/fixtures/encoding.asciidoc +0 -13
  116. data/test/fixtures/file-with-missing-include.adoc +0 -1
  117. data/test/fixtures/grandchild-include.adoc +0 -3
  118. data/test/fixtures/hello-asciidoctor.pdf +0 -69
  119. data/test/fixtures/include-file.asciidoc +0 -24
  120. data/test/fixtures/include-file.jsx +0 -8
  121. data/test/fixtures/include-file.ml +0 -3
  122. data/test/fixtures/include-file.xml +0 -5
  123. data/test/fixtures/lists.adoc +0 -96
  124. data/test/fixtures/master.adoc +0 -5
  125. data/test/fixtures/mismatched-end-tag.adoc +0 -7
  126. data/test/fixtures/other-chapters.adoc +0 -11
  127. data/test/fixtures/outer-include.adoc +0 -5
  128. data/test/fixtures/parent-include-restricted.adoc +0 -5
  129. data/test/fixtures/parent-include.adoc +0 -5
  130. data/test/fixtures/sample.asciidoc +0 -30
  131. data/test/fixtures/section-a.adoc +0 -4
  132. data/test/fixtures/stylesheets/custom.css +0 -3
  133. data/test/fixtures/subdir/index.adoc +0 -3
  134. data/test/fixtures/subdir/inner-include.adoc +0 -3
  135. data/test/fixtures/subdir/middle-include.adoc +0 -5
  136. data/test/fixtures/subs-docinfo.html +0 -2
  137. data/test/fixtures/subs.adoc +0 -6
  138. data/test/fixtures/tagged-class-enclosed.rb +0 -25
  139. data/test/fixtures/tagged-class.rb +0 -23
  140. data/test/fixtures/tip.gif +0 -0
  141. data/test/fixtures/unclosed-tag.adoc +0 -3
  142. data/test/fixtures/unexpected-end-tag.adoc +0 -4
  143. data/test/invoker_test.rb +0 -745
  144. data/test/links_test.rb +0 -855
  145. data/test/lists_test.rb +0 -5151
  146. data/test/logger_test.rb +0 -211
  147. data/test/manpage_test.rb +0 -660
  148. data/test/options_test.rb +0 -262
  149. data/test/paragraphs_test.rb +0 -562
  150. data/test/parser_test.rb +0 -742
  151. data/test/paths_test.rb +0 -395
  152. data/test/preamble_test.rb +0 -173
  153. data/test/reader_test.rb +0 -2161
  154. data/test/sections_test.rb +0 -3575
  155. data/test/substitutions_test.rb +0 -2066
  156. data/test/tables_test.rb +0 -2036
  157. data/test/test_helper.rb +0 -447
  158. data/test/text_test.rb +0 -309
@@ -1,59 +0,0 @@
1
- # encoding: UTF-8
2
- module Asciidoctor
3
- module Converter; end # required for Opal
4
-
5
- # An abstract base class for defining converters that can be used to convert
6
- # {AbstractNode} objects in a parsed AsciiDoc document to a backend format
7
- # such as HTML or DocBook.
8
- #
9
- # Concrete subclasses must implement the {#convert} method and, optionally,
10
- # the {#convert_with_options} method.
11
- class Converter::Base
12
- include Logging
13
- include Converter
14
- end
15
-
16
- # An abstract base class for built-in {Converter} classes.
17
- # Does not inherit from Converter.
18
- class Converter::BuiltIn
19
- include Logging
20
-
21
- def initialize backend, opts = {}
22
- end
23
-
24
- # Public: Converts the specified {AbstractNode} using the specified
25
- # transform and optionally additional options (when not empty).
26
- #
27
- # CAUTION: Method that handles the specified transform *may not* accept the
28
- # second argument with additional options, in which case an {ArgumentError}
29
- # is raised if the given +opts+ Hash is not nil. The additional options are
30
- # used in template-based backends to access convert helper methods such as
31
- # outline.
32
- #
33
- # See {Converter#convert} for more details.
34
- #
35
- # Returns the [String] result of conversion
36
- def convert node, transform = nil, opts = {}
37
- transform ||= node.node_name
38
- opts.empty? ? (send transform, node) : (send transform, node, opts)
39
- end
40
-
41
- alias handles? respond_to?
42
-
43
- # Public: Returns the converted content of the {AbstractNode}.
44
- #
45
- # Returns the converted [String] content of the {AbstractNode}.
46
- def content node
47
- node.content
48
- end
49
-
50
- alias pass content
51
-
52
- # Public: Skips conversion of the {AbstractNode}.
53
- #
54
- # Returns [NilClass]
55
- def skip node
56
- nil
57
- end
58
- end
59
- end
@@ -1,93 +0,0 @@
1
- # encoding: UTF-8
2
- require 'asciidoctor/converter/docbook5'
3
-
4
- module Asciidoctor
5
- # A built-in {Converter} implementation that generates DocBook 4.5 output
6
- # consistent with the docbook45 backend from AsciiDoc Python.
7
- class Converter::DocBook45Converter < Converter::DocBook5Converter
8
- def admonition node
9
- # address a bug in the DocBook 4.5 DTD
10
- if node.parent.context == :example
11
- %(<para>
12
- #{super}
13
- </para>)
14
- else
15
- super
16
- end
17
- end
18
-
19
- def olist node
20
- result = []
21
- num_attribute = node.style ? %( numeration="#{node.style}") : ''
22
- start_attribute = (node.attr? 'start') ? %( override="#{node.attr 'start'}") : ''
23
- result << %(<orderedlist#{common_attributes node.id, node.role, node.reftext}#{num_attribute}>)
24
- result << %(<title>#{node.title}</title>) if node.title?
25
- node.items.each_with_index do |item, idx|
26
- result << (idx == 0 ? %(<listitem#{start_attribute}>) : '<listitem>')
27
- result << %(<simpara>#{item.text}</simpara>)
28
- result << item.content if item.blocks?
29
- result << '</listitem>'
30
- end
31
- result << %(</orderedlist>)
32
- result.join LF
33
- end
34
-
35
- def inline_anchor node
36
- case node.type
37
- when :ref
38
- %(<anchor#{common_attributes node.target, nil, node.text}/>)
39
- when :xref
40
- if (path = node.attributes['path'])
41
- # QUESTION should we use refid as fallback text instead? (like the html5 backend?)
42
- %(<ulink url="#{node.target}">#{node.text || path}</ulink>)
43
- else
44
- linkend = node.attributes['fragment'] || node.target
45
- (text = node.text) ? %(<link linkend="#{linkend}">#{text}</link>) : %(<xref linkend="#{linkend}"/>)
46
- end
47
- when :link
48
- %(<ulink url="#{node.target}">#{node.text}</ulink>)
49
- when :bibref
50
- target = node.target
51
- %(<anchor#{common_attributes target, nil, "[#{target}]"}/>[#{target}])
52
- end
53
- end
54
-
55
- def author_tag author
56
- result = []
57
- result << '<author>'
58
- result << %(<firstname>#{author.firstname}</firstname>) if author.firstname
59
- result << %(<othername>#{author.middlename}</othername>) if author.middlename
60
- result << %(<surname>#{author.lastname}</surname>) if author.lastname
61
- result << %(<email>#{author.email}</email>) if author.email
62
- result << '</author>'
63
- result.join LF
64
- end
65
-
66
- def common_attributes id, role = nil, reftext = nil
67
- res = id ? %( id="#{id}") : ''
68
- res = %(#{res} role="#{role}") if role
69
- res = %(#{res} xreflabel="#{reftext}") if reftext
70
- res
71
- end
72
-
73
- def doctype_declaration root_tag_name
74
- %(<!DOCTYPE #{root_tag_name} PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN" "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd">)
75
- end
76
-
77
- def document_info_tag doc, info_tag_prefix
78
- super doc, info_tag_prefix, true
79
- end
80
-
81
- def lang_attribute_name
82
- 'lang'
83
- end
84
-
85
- def document_ns_attributes doc
86
- if (ns = doc.attr 'xmlns')
87
- ns.empty? ? ' xmlns="http://docbook.org/ns/docbook"' : %( xmlns="#{ns}")
88
- else
89
- ''
90
- end
91
- end
92
- end
93
- end
@@ -1,226 +0,0 @@
1
- # encoding: UTF-8
2
- module Asciidoctor
3
- module Converter
4
- # A factory for instantiating converters that are used to convert a
5
- # {Document} (i.e., a parsed AsciiDoc tree structure) or {AbstractNode} to
6
- # a backend format such as HTML or DocBook. {Factory Converter::Factory} is
7
- # the primary entry point for creating, registering and accessing
8
- # converters.
9
- #
10
- # {Converter} objects are instantiated by passing a String backend name
11
- # and, optionally, an options Hash to the {Factory#create} method. The
12
- # backend can be thought of as an intent to convert a document to a
13
- # specified format. For example:
14
- #
15
- # converter = Asciidoctor::Converter::Factory.create 'html5', :htmlsyntax => 'xml'
16
- #
17
- # Converter objects are thread safe. They only survive the lifetime of a single conversion.
18
- #
19
- # A singleton instance of {Factory Converter::Factory} can be accessed
20
- # using the {Factory.default} method. This instance maintains the global
21
- # registry of statically registered converters. The registery includes
22
- # built-in converters for {Html5Converter HTML 5}, {DocBook5Converter
23
- # DocBook 5} and {DocBook45Converter DocBook 4.5}, as well as any custom
24
- # converters that have been discovered or explicitly registered.
25
- #
26
- # If the {https://rubygems.org/gems/concurrent-ruby concurrent-ruby} gem is
27
- # installed, access to the default factory is guaranteed to be thread safe.
28
- # Otherwise, a warning is issued to the user.
29
- class Factory
30
- @__default__ = nil
31
- class << self
32
-
33
- # Public: Retrieves a singleton instance of {Factory Converter::Factory}.
34
- #
35
- # If the concurrent-ruby gem is installed, the registry of converters is
36
- # initialized as a Concurrent::Hash. Otherwise, a warning is issued and
37
- # the registry of converters is initialized using a normal Hash.
38
- #
39
- # initialize_singleton - A Boolean to indicate whether the singleton should
40
- # be initialized if it has not already been created.
41
- # If false, and a singleton has not been previously
42
- # initialized, a fresh instance is returned.
43
- #
44
- # Returns the default [Factory] singleton instance
45
- def default initialize_singleton = true
46
- return @__default__ || new unless initialize_singleton
47
- # FIXME this assignment itself may not be thread safe; may need to use a helper here
48
- @__default__ ||= begin
49
- unless defined? ::Concurrent::Hash
50
- # NOTE dynamic require is ignored by Opal
51
- require ::RUBY_MIN_VERSION_1_9 ? 'concurrent/hash' : 'asciidoctor/core_ext/1.8.7/concurrent/hash'
52
- end
53
- new ::Concurrent::Hash.new
54
- rescue ::LoadError
55
- include Logging unless include? Logging
56
- logger.warn 'gem \'concurrent-ruby\' is not installed. This gem is recommended when registering custom converters.'
57
- new
58
- end
59
- end
60
-
61
- # Public: Register a custom converter in the global converter factory to
62
- # handle conversion to the specified backends. If the backend value is an
63
- # asterisk, the converter is used to handle any backend that does not have
64
- # an explicit converter.
65
- #
66
- # converter - The Converter class to register
67
- # backends - A String Array of backend names that this converter should
68
- # be registered to handle (optional, default: ['*'])
69
- #
70
- # Returns nothing
71
- def register converter, backends = ['*']
72
- default.register converter, backends
73
- end
74
-
75
- # Public: Lookup the custom converter for the specified backend in the
76
- # global factory.
77
- #
78
- # This method does not resolve the built-in converters.
79
- #
80
- # backend - The String backend name
81
- #
82
- # Returns the [Converter] class registered to convert the specified backend
83
- # or nil if no match is found
84
- def resolve backend
85
- default.resolve backend
86
- end
87
-
88
- # Public: Lookup the converter for the specified backend in the global
89
- # factory and instantiate it, forwarding the Hash of options to the
90
- # constructor of the converter class.
91
- #
92
- # If the custom converter is not found, an attempt will be made to find
93
- # and instantiate a built-in converter.
94
- #
95
- # backend - The String backend name
96
- # opts - A Hash of options to pass to the converter
97
- #
98
- # Returns an instance of [Converter] for converting the specified backend or
99
- # nil if no match is found.
100
- def create backend, opts = {}
101
- default.create backend, opts
102
- end
103
-
104
- # Public: Retrieve the global Hash of custom Converter classes keyed by backend.
105
- #
106
- # Returns the the global [Hash] of custom Converter classes
107
- def converters
108
- default.converters
109
- end
110
-
111
- # Public: Unregister all Converter classes in the global factory.
112
- #
113
- # Returns nothing
114
- def unregister_all
115
- default.unregister_all
116
- end
117
- end
118
-
119
- # Public: Get the Hash of Converter classes keyed by backend name
120
- attr_reader :converters
121
-
122
- def initialize converters = nil
123
- @converters = converters || {}
124
- @star_converter = nil
125
- end
126
-
127
- # Public: Register a custom converter with this factory to handle conversion
128
- # to the specified backends. If the backend value is an asterisk, the
129
- # converter is used to handle any backend that does not have an explicit
130
- # converter.
131
- #
132
- # converter - The Converter class to register
133
- # backends - A String Array of backend names that this converter should
134
- # be registered to handle (optional, default: ['*'])
135
- #
136
- # Returns nothing
137
- def register converter, backends = ['*']
138
- backends.each do |backend|
139
- @converters[backend] = converter
140
- if backend == '*'
141
- @star_converter = converter
142
- end
143
- end
144
- nil
145
- end
146
-
147
- # Public: Lookup the custom converter registered with this factory to handle
148
- # the specified backend.
149
- #
150
- # backend - The String backend name
151
- #
152
- # Returns the [Converter] class registered to convert the specified backend
153
- # or nil if no match is found
154
- def resolve backend
155
- @converters && (@converters[backend] || @star_converter)
156
- end
157
-
158
- # Public: Unregister all Converter classes that are registered with this
159
- # factory.
160
- #
161
- # Returns nothing
162
- def unregister_all
163
- @converters.clear
164
- @star_converter = nil
165
- end
166
-
167
- # Public: Create a new Converter object that can be used to convert the
168
- # {AbstractNode} (typically a {Document}) to the specified String backend.
169
- # This method accepts an optional Hash of options that are passed to the
170
- # converter's constructor.
171
- #
172
- # If a custom Converter is found to convert the specified backend, it is
173
- # instantiated (if necessary) and returned immediately. If a custom
174
- # Converter is not found, an attempt is made to resolve a built-in
175
- # converter. If the `:template_dirs` key is found in the Hash passed as the
176
- # second argument, a {CompositeConverter} is created that delegates to a
177
- # {TemplateConverter} and, if resolved, the built-in converter. If the
178
- # `:template_dirs` key is not found, the built-in converter is returned
179
- # or nil if no converter is resolved.
180
- #
181
- # backend - the String backend name
182
- # opts - an optional Hash of options that get passed on to the converter's
183
- # constructor. If the :template_dirs key is found in the options
184
- # Hash, this method returns a {CompositeConverter} that delegates
185
- # to a {TemplateConverter}. (optional, default: {})
186
- #
187
- # Returns the [Converter] object
188
- def create backend, opts = {}
189
- if (converter = resolve backend)
190
- base_converter = ::Class === converter ? (converter.new backend, opts) : converter
191
- return base_converter unless Converter::BackendInfo === base_converter && base_converter.supports_templates?
192
- else
193
- case backend
194
- when 'html5'
195
- # NOTE .to_s hides require from Opal
196
- require 'asciidoctor/converter/html5'.to_s unless defined? ::Asciidoctor::Converter::Html5Converter
197
- base_converter = Html5Converter.new backend, opts
198
- when 'docbook5'
199
- # NOTE .to_s hides require from Opal
200
- require 'asciidoctor/converter/docbook5'.to_s unless defined? ::Asciidoctor::Converter::DocBook5Converter
201
- base_converter = DocBook5Converter.new backend, opts
202
- when 'docbook45'
203
- # NOTE .to_s hides require from Opal
204
- require 'asciidoctor/converter/docbook45'.to_s unless defined? ::Asciidoctor::Converter::DocBook45Converter
205
- base_converter = DocBook45Converter.new backend, opts
206
- when 'manpage'
207
- # NOTE .to_s hides require from Opal
208
- require 'asciidoctor/converter/manpage'.to_s unless defined? ::Asciidoctor::Converter::ManPageConverter
209
- base_converter = ManPageConverter.new backend, opts
210
- end
211
- end
212
-
213
- return base_converter unless opts.key? :template_dirs
214
-
215
- # NOTE .to_s hides require from Opal
216
- require 'asciidoctor/converter/template'.to_s unless defined? ::Asciidoctor::Converter::TemplateConverter
217
- template_converter = TemplateConverter.new backend, opts[:template_dirs], opts
218
-
219
- # NOTE .to_s hides require from Opal
220
- require 'asciidoctor/converter/composite'.to_s unless defined? ::Asciidoctor::Converter::CompositeConverter
221
- # QUESTION should we omit the composite converter if built_in_converter is nil?
222
- CompositeConverter.new backend, template_converter, base_converter
223
- end
224
- end
225
- end
226
- end
@@ -1,6 +0,0 @@
1
- # Educate Ruby 1.8.7 about the Base64#strict_encode64 method.
2
- module Base64
3
- def strict_encode64 bin
4
- (self.encode64 bin).delete %(\n)
5
- end
6
- end
@@ -1,5 +0,0 @@
1
- require 'thread_safe'
2
-
3
- module Concurrent
4
- Hash = ::ThreadSafe::Cache
5
- end
@@ -1,4 +0,0 @@
1
- # Educate Ruby 1.8.7 about the Hash#key method.
2
- class Hash
3
- alias key index
4
- end
@@ -1,6 +0,0 @@
1
- def IO.binread name, length = nil, offset = 0
2
- File.open name, 'rb' do |f|
3
- f.seek offset unless offset == 0
4
- length ? (f.read length) : f.read
5
- end
6
- end unless IO.respond_to? :binread
@@ -1,5 +0,0 @@
1
- def IO.write name, string, offset = 0, opts = nil
2
- File.open name, 'w' do |f|
3
- f.write string
4
- end
5
- end unless IO.respond_to? :write
@@ -1,6 +0,0 @@
1
- # Educate Ruby 1.8.7 about the String#chr method.
2
- class String
3
- def chr
4
- slice 0, 1
5
- end unless method_defined? :chr
6
- end
@@ -1,29 +0,0 @@
1
- if RUBY_ENGINE_JRUBY
2
- class String
3
- # Safely truncate the string to the specified number of bytes.
4
- # If a multibyte char gets split, the dangling fragment is removed.
5
- def limit_bytesize size
6
- return self unless size < bytesize
7
- result = (unpack %(a#{size}))[0]
8
- begin
9
- result.unpack 'U*'
10
- rescue ::ArgumentError
11
- result.chop!
12
- retry
13
- end
14
- result
15
- end unless method_defined? :limit_bytesize
16
- end
17
- else
18
- class String
19
- ValidTrailingCharRx = /.$/u
20
- # Safely truncate the string to the specified number of bytes.
21
- # If a multibyte char gets split, the dangling fragment is removed.
22
- def limit_bytesize size
23
- return self unless size < bytesize
24
- result = (unpack %(a#{size}))[0]
25
- result.chop! until result.empty? || (ValidTrailingCharRx.match? result)
26
- result
27
- end unless method_defined? :limit_bytesize
28
- end
29
- end