asciidoctor 1.5.8 → 2.0.17
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.yardopts +11 -0
- data/CHANGELOG.adoc +628 -45
- data/LICENSE +2 -1
- data/README-de.adoc +28 -38
- data/README-fr.adoc +30 -43
- data/README-jp.adoc +255 -201
- data/README-zh_CN.adoc +40 -44
- data/README.adoc +170 -143
- data/asciidoctor.gemspec +22 -34
- data/bin/asciidoctor +5 -4
- data/data/locale/attributes-ar.adoc +4 -3
- data/data/locale/attributes-be.adoc +23 -0
- data/data/locale/attributes-bg.adoc +4 -3
- data/data/locale/attributes-ca.adoc +6 -5
- data/data/locale/attributes-cs.adoc +4 -3
- data/data/locale/attributes-da.adoc +6 -5
- data/data/locale/attributes-de.adoc +6 -5
- data/data/locale/attributes-en.adoc +4 -4
- data/data/locale/attributes-es.adoc +6 -5
- data/data/locale/attributes-fa.adoc +4 -3
- data/data/locale/attributes-fi.adoc +4 -3
- data/data/locale/attributes-fr.adoc +8 -7
- data/data/locale/attributes-hu.adoc +4 -3
- data/data/locale/attributes-id.adoc +4 -3
- data/data/locale/attributes-it.adoc +6 -5
- data/data/locale/attributes-ja.adoc +4 -3
- data/data/locale/{attributes-kr.adoc → attributes-ko.adoc} +4 -3
- data/data/locale/attributes-nb.adoc +4 -3
- data/data/locale/attributes-nl.adoc +6 -5
- data/data/locale/attributes-nn.adoc +4 -3
- data/data/locale/attributes-pl.adoc +8 -7
- data/data/locale/attributes-pt.adoc +6 -5
- data/data/locale/attributes-pt_BR.adoc +6 -5
- data/data/locale/attributes-ro.adoc +4 -3
- data/data/locale/attributes-ru.adoc +6 -5
- data/data/locale/attributes-sr.adoc +4 -4
- data/data/locale/attributes-sr_Latn.adoc +4 -4
- data/data/locale/attributes-sv.adoc +4 -4
- data/data/locale/attributes-th.adoc +23 -0
- data/data/locale/attributes-tr.adoc +4 -3
- data/data/locale/attributes-uk.adoc +6 -5
- data/data/locale/attributes-vi.adoc +23 -0
- data/data/locale/attributes-zh_CN.adoc +4 -3
- data/data/locale/attributes-zh_TW.adoc +4 -3
- data/data/reference/syntax.adoc +296 -0
- data/data/stylesheets/asciidoctor-default.css +120 -114
- data/data/stylesheets/coderay-asciidoctor.css +15 -17
- data/lib/asciidoctor/abstract_block.rb +146 -140
- data/lib/asciidoctor/abstract_node.rb +152 -170
- data/lib/asciidoctor/attribute_list.rb +77 -89
- data/lib/asciidoctor/block.rb +29 -28
- data/lib/asciidoctor/callouts.rb +4 -2
- data/lib/asciidoctor/cli/invoker.rb +20 -24
- data/lib/asciidoctor/cli/options.rb +107 -96
- data/lib/asciidoctor/cli.rb +3 -2
- data/lib/asciidoctor/convert.rb +199 -0
- data/lib/asciidoctor/converter/composite.rb +40 -48
- data/lib/asciidoctor/converter/docbook5.rb +627 -644
- data/lib/asciidoctor/converter/html5.rb +1053 -951
- data/lib/asciidoctor/converter/manpage.rb +581 -532
- data/lib/asciidoctor/converter/template.rb +232 -271
- data/lib/asciidoctor/converter.rb +370 -185
- data/lib/asciidoctor/core_ext/float/truncate.rb +20 -0
- data/lib/asciidoctor/core_ext/hash/merge.rb +8 -0
- data/lib/asciidoctor/core_ext/match_data/names.rb +7 -0
- data/lib/asciidoctor/core_ext/nil_or_empty.rb +1 -0
- data/lib/asciidoctor/core_ext/regexp/is_match.rb +4 -2
- data/lib/asciidoctor/core_ext.rb +8 -17
- data/lib/asciidoctor/document.rb +503 -461
- data/lib/asciidoctor/extensions.rb +127 -174
- data/lib/asciidoctor/helpers.rb +184 -107
- data/lib/asciidoctor/inline.rb +9 -12
- data/lib/asciidoctor/list.rb +11 -29
- data/lib/asciidoctor/load.rb +119 -0
- data/lib/asciidoctor/logging.rb +22 -17
- data/lib/asciidoctor/parser.rb +673 -719
- data/lib/asciidoctor/path_resolver.rb +48 -33
- data/lib/asciidoctor/reader.rb +383 -338
- data/lib/asciidoctor/rouge_ext.rb +39 -0
- data/lib/asciidoctor/rx.rb +723 -0
- data/lib/asciidoctor/section.rb +17 -16
- data/lib/asciidoctor/stylesheets.rb +19 -37
- data/lib/asciidoctor/substitutors.rb +926 -1022
- data/lib/asciidoctor/syntax_highlighter/coderay.rb +88 -0
- data/lib/asciidoctor/syntax_highlighter/highlightjs.rb +34 -0
- data/lib/asciidoctor/syntax_highlighter/html_pipeline.rb +10 -0
- data/lib/asciidoctor/syntax_highlighter/prettify.rb +30 -0
- data/lib/asciidoctor/syntax_highlighter/pygments.rb +157 -0
- data/lib/asciidoctor/syntax_highlighter/rouge.rb +143 -0
- data/lib/asciidoctor/syntax_highlighter.rb +253 -0
- data/lib/asciidoctor/table.rb +152 -114
- data/lib/asciidoctor/timings.rb +7 -5
- data/lib/asciidoctor/version.rb +2 -1
- data/lib/asciidoctor/writer.rb +30 -0
- data/lib/asciidoctor.rb +266 -1340
- data/man/asciidoctor.1 +49 -47
- data/man/asciidoctor.adoc +54 -45
- metadata +50 -245
- data/CONTRIBUTING.adoc +0 -185
- data/Gemfile +0 -60
- data/Rakefile +0 -129
- data/bin/asciidoctor-safe +0 -15
- data/features/open_block.feature +0 -92
- data/features/pass_block.feature +0 -66
- data/features/step_definitions.rb +0 -49
- data/features/text_formatting.feature +0 -57
- data/features/xref.feature +0 -1039
- data/lib/asciidoctor/converter/base.rb +0 -59
- data/lib/asciidoctor/converter/docbook45.rb +0 -93
- data/lib/asciidoctor/converter/factory.rb +0 -226
- data/lib/asciidoctor/core_ext/1.8.7/base64/strict_encode64.rb +0 -6
- data/lib/asciidoctor/core_ext/1.8.7/concurrent/hash.rb +0 -5
- data/lib/asciidoctor/core_ext/1.8.7/hash/key.rb +0 -4
- data/lib/asciidoctor/core_ext/1.8.7/io/binread.rb +0 -6
- data/lib/asciidoctor/core_ext/1.8.7/io/write.rb +0 -5
- data/lib/asciidoctor/core_ext/1.8.7/string/chr.rb +0 -6
- data/lib/asciidoctor/core_ext/1.8.7/string/limit_bytesize.rb +0 -29
- data/lib/asciidoctor/core_ext/1.8.7/symbol/empty.rb +0 -6
- data/lib/asciidoctor/core_ext/1.8.7/symbol/length.rb +0 -6
- data/lib/asciidoctor/core_ext/string/limit_bytesize.rb +0 -10
- data/test/api_test.rb +0 -1240
- data/test/attribute_list_test.rb +0 -242
- data/test/attributes_test.rb +0 -1623
- data/test/blocks_test.rb +0 -3870
- data/test/converter_test.rb +0 -470
- data/test/document_test.rb +0 -1853
- data/test/extensions_test.rb +0 -1560
- data/test/fixtures/asciidoc_index.txt +0 -521
- data/test/fixtures/basic-docinfo-footer.html +0 -6
- data/test/fixtures/basic-docinfo-footer.xml +0 -8
- data/test/fixtures/basic-docinfo.html +0 -1
- data/test/fixtures/basic-docinfo.xml +0 -4
- data/test/fixtures/basic.asciidoc +0 -5
- data/test/fixtures/chapter-a.adoc +0 -3
- data/test/fixtures/child-include.adoc +0 -5
- data/test/fixtures/circle.svg +0 -9
- data/test/fixtures/custom-backends/erb/html5/block_paragraph.html.erb +0 -6
- data/test/fixtures/custom-backends/haml/docbook45/block_paragraph.xml.haml +0 -6
- data/test/fixtures/custom-backends/haml/html5/block_paragraph.html.haml +0 -3
- data/test/fixtures/custom-backends/haml/html5/block_sidebar.html.haml +0 -5
- data/test/fixtures/custom-backends/haml/html5-tweaks/block_paragraph.html.haml +0 -1
- data/test/fixtures/custom-backends/slim/docbook45/block_paragraph.xml.slim +0 -6
- data/test/fixtures/custom-backends/slim/html5/block_paragraph.html.slim +0 -3
- data/test/fixtures/custom-backends/slim/html5/block_sidebar.html.slim +0 -5
- data/test/fixtures/custom-docinfodir/basic-docinfo.html +0 -1
- data/test/fixtures/custom-docinfodir/docinfo.html +0 -1
- data/test/fixtures/docinfo-footer.html +0 -1
- data/test/fixtures/docinfo-footer.xml +0 -9
- data/test/fixtures/docinfo.html +0 -1
- data/test/fixtures/docinfo.xml +0 -3
- data/test/fixtures/doctime-localtime.adoc +0 -2
- data/test/fixtures/dot.gif +0 -0
- data/test/fixtures/encoding.asciidoc +0 -13
- data/test/fixtures/file-with-missing-include.adoc +0 -1
- data/test/fixtures/grandchild-include.adoc +0 -3
- data/test/fixtures/hello-asciidoctor.pdf +0 -69
- data/test/fixtures/include-file.asciidoc +0 -24
- data/test/fixtures/include-file.jsx +0 -8
- data/test/fixtures/include-file.ml +0 -3
- data/test/fixtures/include-file.xml +0 -5
- data/test/fixtures/lists.adoc +0 -96
- data/test/fixtures/master.adoc +0 -5
- data/test/fixtures/mismatched-end-tag.adoc +0 -7
- data/test/fixtures/other-chapters.adoc +0 -11
- data/test/fixtures/outer-include.adoc +0 -5
- data/test/fixtures/parent-include-restricted.adoc +0 -5
- data/test/fixtures/parent-include.adoc +0 -5
- data/test/fixtures/sample.asciidoc +0 -30
- data/test/fixtures/section-a.adoc +0 -4
- data/test/fixtures/stylesheets/custom.css +0 -3
- data/test/fixtures/subdir/index.adoc +0 -3
- data/test/fixtures/subdir/inner-include.adoc +0 -3
- data/test/fixtures/subdir/middle-include.adoc +0 -5
- data/test/fixtures/subs-docinfo.html +0 -2
- data/test/fixtures/subs.adoc +0 -6
- data/test/fixtures/tagged-class-enclosed.rb +0 -25
- data/test/fixtures/tagged-class.rb +0 -23
- data/test/fixtures/tip.gif +0 -0
- data/test/fixtures/unclosed-tag.adoc +0 -3
- data/test/fixtures/unexpected-end-tag.adoc +0 -4
- data/test/invoker_test.rb +0 -745
- data/test/links_test.rb +0 -855
- data/test/lists_test.rb +0 -5151
- data/test/logger_test.rb +0 -211
- data/test/manpage_test.rb +0 -660
- data/test/options_test.rb +0 -262
- data/test/paragraphs_test.rb +0 -562
- data/test/parser_test.rb +0 -742
- data/test/paths_test.rb +0 -395
- data/test/preamble_test.rb +0 -173
- data/test/reader_test.rb +0 -2161
- data/test/sections_test.rb +0 -3575
- data/test/substitutions_test.rb +0 -2066
- data/test/tables_test.rb +0 -2036
- data/test/test_helper.rb +0 -447
- data/test/text_test.rb +0 -309
@@ -0,0 +1,253 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
module Asciidoctor
|
3
|
+
# Public: A pluggable adapter for integrating a syntax (aka code) highlighter into AsciiDoc processing.
|
4
|
+
#
|
5
|
+
# There are two types of syntax highlighter adapters. The first performs syntax highlighting during the convert phase.
|
6
|
+
# This adapter type must define a highlight? method that returns true. The companion highlight method will then be
|
7
|
+
# called to handle the :specialcharacters substitution for source blocks. The second assumes syntax highlighting is
|
8
|
+
# performed on the client (e.g., when the HTML document is loaded). This adapter type must define a docinfo? method
|
9
|
+
# that returns true. The companion docinfo method will then be called to insert markup into the output document. The
|
10
|
+
# docinfo functionality is available to both adapter types.
|
11
|
+
#
|
12
|
+
# Asciidoctor provides several built-in adapters, including coderay, pygments, rouge, highlight.js, html-pipeline, and
|
13
|
+
# prettify. Additional adapters can be registered using SyntaxHighlighter.register or by supplying a custom factory.
|
14
|
+
module SyntaxHighlighter
|
15
|
+
# Public: Returns the String name of this syntax highlighter for referencing it in messages and option names.
|
16
|
+
attr_reader :name
|
17
|
+
|
18
|
+
def initialize name, backend = 'html5', opts = {}
|
19
|
+
@name = @pre_class = name
|
20
|
+
end
|
21
|
+
|
22
|
+
# Public: Indicates whether this syntax highlighter has docinfo (i.e., markup) to insert into the output document at
|
23
|
+
# the specified location. Should be called by converter after main content has been converted.
|
24
|
+
#
|
25
|
+
# location - The Symbol representing the location slot (:head or :footer).
|
26
|
+
#
|
27
|
+
# Returns a [Boolean] indicating whether the docinfo method should be called for this location.
|
28
|
+
def docinfo? location; end
|
29
|
+
|
30
|
+
# Public: Generates docinfo markup for this syntax highlighter to insert at the specified location in the output document.
|
31
|
+
# Should be called by converter after main content has been converted.
|
32
|
+
#
|
33
|
+
# location - The Symbol representing the location slot (:head or :footer).
|
34
|
+
# doc - The Document in which this syntax highlighter is being used.
|
35
|
+
# opts - A Hash of options that configure the syntax highlighting:
|
36
|
+
# :linkcss - A Boolean indicating whether the stylesheet should be linked instead of embedded (optional).
|
37
|
+
# :cdn_base_url - The String base URL for assets loaded from the CDN.
|
38
|
+
# :self_closing_tag_slash - The String '/' if the converter calling this method emits self-closing tags.
|
39
|
+
#
|
40
|
+
# Return the [String] markup to insert.
|
41
|
+
def docinfo location, doc, opts
|
42
|
+
raise ::NotImplementedError, %(#{SyntaxHighlighter} subclass #{self.class} must implement the ##{__method__} method since #docinfo? returns true)
|
43
|
+
end
|
44
|
+
|
45
|
+
# Public: Indicates whether highlighting is handled by this syntax highlighter or by the client.
|
46
|
+
#
|
47
|
+
# Returns a [Boolean] indicating whether the highlight method should be used to handle the :specialchars substitution.
|
48
|
+
def highlight?; end
|
49
|
+
|
50
|
+
# Public: Highlights the specified source when this source block is being converted.
|
51
|
+
#
|
52
|
+
# If the source contains callout marks, the caller assumes the source remains on the same lines and no closing tags
|
53
|
+
# are added to the end of each line. If the source gets shifted by one or more lines, this method must return a
|
54
|
+
# tuple containing the highlighted source and the number of lines by which the source was shifted.
|
55
|
+
#
|
56
|
+
# node - The source Block to syntax highlight.
|
57
|
+
# source - The raw source text String of this source block (after preprocessing).
|
58
|
+
# lang - The source language String specified on this block (e.g., ruby).
|
59
|
+
# opts - A Hash of options that configure the syntax highlighting:
|
60
|
+
# :callouts - A Hash of callouts extracted from the source, indexed by line number (1-based) (optional).
|
61
|
+
# :css_mode - The Symbol CSS mode (:class or :inline).
|
62
|
+
# :highlight_lines - A 1-based Array of Integer line numbers to highlight (aka emphasize) (optional).
|
63
|
+
# :number_lines - A Symbol indicating whether lines should be numbered (:table or :inline) (optional).
|
64
|
+
# :start_line_number - The starting Integer (1-based) line number (optional, default: 1).
|
65
|
+
# :style - The String style (aka theme) to use for colorizing the code (optional).
|
66
|
+
#
|
67
|
+
# Returns the highlighted source String or a tuple of the highlighted source String and an Integer line offset.
|
68
|
+
def highlight node, source, lang, opts
|
69
|
+
raise ::NotImplementedError, %(#{SyntaxHighlighter} subclass #{self.class} must implement the ##{__method__} method since #highlight? returns true)
|
70
|
+
end
|
71
|
+
|
72
|
+
# Public: Format the highlighted source for inclusion in an HTML document.
|
73
|
+
#
|
74
|
+
# node - The source Block being processed.
|
75
|
+
# lang - The source language String for this Block (e.g., ruby).
|
76
|
+
# opts - A Hash of options that control syntax highlighting:
|
77
|
+
# :nowrap - A Boolean that indicates whether wrapping should be disabled (optional).
|
78
|
+
#
|
79
|
+
# Returns the highlighted source [String] wrapped in preformatted tags (e.g., pre and code)
|
80
|
+
def format node, lang, opts
|
81
|
+
raise ::NotImplementedError, %(#{SyntaxHighlighter} subclass #{self.class} must implement the ##{__method__} method)
|
82
|
+
end
|
83
|
+
|
84
|
+
# Public: Indicates whether this syntax highlighter wants to write a stylesheet to disk. Only called if both the
|
85
|
+
# linkcss and copycss attributes are set on the document.
|
86
|
+
#
|
87
|
+
# doc - The Document in which this syntax highlighter is being used.
|
88
|
+
#
|
89
|
+
# Returns a [Boolean] indicating whether the write_stylesheet method should be called.
|
90
|
+
def write_stylesheet? doc; end
|
91
|
+
|
92
|
+
# Public: Writes the stylesheet to support the highlighted source(s) to disk.
|
93
|
+
#
|
94
|
+
# doc - The Document in which this syntax highlighter is being used.
|
95
|
+
# to_dir - The absolute String path of the stylesheet output directory.
|
96
|
+
#
|
97
|
+
# Returns nothing.
|
98
|
+
def write_stylesheet doc, to_dir
|
99
|
+
raise ::NotImplementedError, %(#{SyntaxHighlighter} subclass #{self.class} must implement the ##{__method__} method since #write_stylesheet? returns true)
|
100
|
+
end
|
101
|
+
|
102
|
+
def self.included into
|
103
|
+
into.extend Config
|
104
|
+
end
|
105
|
+
private_class_method :included # use separate declaration for Ruby 2.0.x
|
106
|
+
|
107
|
+
module Config
|
108
|
+
# Public: Statically register the current class in the registry for the specified names.
|
109
|
+
#
|
110
|
+
# names - one or more String or Symbol names with which to register the current class as a syntax highlighter
|
111
|
+
# implementation. Symbol arguments are coerced to Strings.
|
112
|
+
#
|
113
|
+
# Returns nothing.
|
114
|
+
def register_for *names
|
115
|
+
SyntaxHighlighter.register self, *(names.map {|name| name.to_s })
|
116
|
+
end
|
117
|
+
end
|
118
|
+
|
119
|
+
module Factory
|
120
|
+
# Public: Associates the syntax highlighter class or object with the specified names.
|
121
|
+
#
|
122
|
+
# syntax_highlighter - the syntax highlighter implementation to register
|
123
|
+
# names - one or more String names with which to register this syntax highlighter implementation.
|
124
|
+
#
|
125
|
+
# Returns nothing.
|
126
|
+
def register syntax_highlighter, *names
|
127
|
+
names.each {|name| registry[name] = syntax_highlighter }
|
128
|
+
end
|
129
|
+
|
130
|
+
# Public: Retrieves the syntax highlighter class or object registered for the specified name.
|
131
|
+
#
|
132
|
+
# name - The String name of the syntax highlighter to retrieve.
|
133
|
+
#
|
134
|
+
# Returns the SyntaxHighlighter Class or Object instance registered for this name.
|
135
|
+
def for name
|
136
|
+
registry[name]
|
137
|
+
end
|
138
|
+
|
139
|
+
# Public: Resolves the name to a syntax highlighter instance, if found in the registry.
|
140
|
+
#
|
141
|
+
# name - The String name of the syntax highlighter to create.
|
142
|
+
# backend - The String name of the backend for which this syntax highlighter is being used (default: 'html5').
|
143
|
+
# opts - A Hash of options providing information about the context in which this syntax highlighter is used:
|
144
|
+
# :document - The Document for which this syntax highlighter was created.
|
145
|
+
#
|
146
|
+
# Returns a [SyntaxHighlighter] instance for the specified name.
|
147
|
+
def create name, backend = 'html5', opts = {}
|
148
|
+
if (syntax_hl = self.for name)
|
149
|
+
syntax_hl = syntax_hl.new name, backend, opts if ::Class === syntax_hl
|
150
|
+
raise ::NameError, %(#{syntax_hl.class} must specify a value for `name') unless syntax_hl.name
|
151
|
+
syntax_hl
|
152
|
+
end
|
153
|
+
end
|
154
|
+
|
155
|
+
private
|
156
|
+
|
157
|
+
def registry
|
158
|
+
raise ::NotImplementedError, %(#{Factory} subclass #{self.class} must implement the ##{__method__} method)
|
159
|
+
end
|
160
|
+
end
|
161
|
+
|
162
|
+
class CustomFactory
|
163
|
+
include Factory
|
164
|
+
|
165
|
+
def initialize seed_registry = nil
|
166
|
+
@registry = seed_registry || {}
|
167
|
+
end
|
168
|
+
|
169
|
+
private
|
170
|
+
|
171
|
+
attr_reader :registry
|
172
|
+
end
|
173
|
+
|
174
|
+
module DefaultFactory
|
175
|
+
include Factory
|
176
|
+
|
177
|
+
@@registry = {}
|
178
|
+
|
179
|
+
private
|
180
|
+
|
181
|
+
def registry
|
182
|
+
@@registry
|
183
|
+
end
|
184
|
+
|
185
|
+
unless RUBY_ENGINE == 'opal'
|
186
|
+
public
|
187
|
+
|
188
|
+
def register syntax_highlighter, *names
|
189
|
+
@@mutex.owned? ? names.each {|name| @@registry = @@registry.merge name => syntax_highlighter } :
|
190
|
+
@@mutex.synchronize { register syntax_highlighter, *names }
|
191
|
+
end
|
192
|
+
|
193
|
+
# This method will lazy require and register additional built-in implementations, which include coderay,
|
194
|
+
# pygments, rouge, and prettify. Refer to {Factory#for} for parameters and return value.
|
195
|
+
def for name
|
196
|
+
@@registry.fetch name do
|
197
|
+
@@mutex.synchronize do
|
198
|
+
@@registry.fetch name do
|
199
|
+
if (require_path = PROVIDED[name])
|
200
|
+
require require_path
|
201
|
+
@@registry[name]
|
202
|
+
else
|
203
|
+
@@registry = @@registry.merge name => nil
|
204
|
+
nil
|
205
|
+
end
|
206
|
+
end
|
207
|
+
end
|
208
|
+
end
|
209
|
+
end
|
210
|
+
|
211
|
+
PROVIDED = {
|
212
|
+
'coderay' => %(#{__dir__}/syntax_highlighter/coderay),
|
213
|
+
'prettify' => %(#{__dir__}/syntax_highlighter/prettify),
|
214
|
+
'pygments' => %(#{__dir__}/syntax_highlighter/pygments),
|
215
|
+
'rouge' => %(#{__dir__}/syntax_highlighter/rouge),
|
216
|
+
}
|
217
|
+
|
218
|
+
@@mutex = ::Mutex.new
|
219
|
+
end
|
220
|
+
end
|
221
|
+
|
222
|
+
class DefaultFactoryProxy < CustomFactory
|
223
|
+
include DefaultFactory # inserts module into ancestors immediately after superclass
|
224
|
+
|
225
|
+
def for name
|
226
|
+
@registry.fetch(name) { super }
|
227
|
+
end unless RUBY_ENGINE == 'opal'
|
228
|
+
end
|
229
|
+
|
230
|
+
class Base
|
231
|
+
include SyntaxHighlighter
|
232
|
+
|
233
|
+
def format node, lang, opts
|
234
|
+
class_attr_val = opts[:nowrap] ? %(#{@pre_class} highlight nowrap) : %(#{@pre_class} highlight)
|
235
|
+
if (transform = opts[:transform])
|
236
|
+
transform[(pre = { 'class' => class_attr_val }), (code = lang ? { 'data-lang' => lang } : {})]
|
237
|
+
# NOTE: make sure data-lang is the last attribute on the code tag to remain consistent with 1.5.x
|
238
|
+
if (lang = code.delete 'data-lang')
|
239
|
+
code['data-lang'] = lang
|
240
|
+
end
|
241
|
+
%(<pre#{pre.map {|k, v| %[ #{k}="#{v}"] }.join}><code#{code.map {|k, v| %[ #{k}="#{v}"] }.join}>#{node.content}</code></pre>)
|
242
|
+
else
|
243
|
+
%(<pre class="#{class_attr_val}"><code#{lang ? %[ data-lang="#{lang}"] : ''}>#{node.content}</code></pre>)
|
244
|
+
end
|
245
|
+
end
|
246
|
+
end
|
247
|
+
|
248
|
+
extend DefaultFactory # exports static methods
|
249
|
+
end
|
250
|
+
end
|
251
|
+
|
252
|
+
require_relative 'syntax_highlighter/highlightjs'
|
253
|
+
require_relative 'syntax_highlighter/html_pipeline' unless RUBY_ENGINE == 'opal'
|