asciidoctor-instant-articles 0.1.2.pre → 0.1.3.pre
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.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c2dc22152358268209280292f3996d98665c45b5
|
4
|
+
data.tar.gz: c583b22e3a2c5500d424b1e16e26e6231b128e33
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fff25b24052e8be31fdaf28a8f45cd935d7f7fdf5d19ffe55d5fbb835ad7182d60521e7111a9a9ee125dee9f60f7bbd53c3773981cac44bc52947480ff3bdaee
|
7
|
+
data.tar.gz: 52d5874174c745f16a7feba9969d7daeb0f4e650f32be9ef44c6d79c42d8eb3e6a15898432a3f567fb3583fb22db209c7e2b1880c5907a24f5210eab3b13aaa4
|
@@ -1 +1 @@
|
|
1
|
-
p content
|
1
|
+
p = content
|
@@ -2,7 +2,8 @@ doctype 5
|
|
2
2
|
html lang=(attr :lang, 'en' unless attr? :nolang)
|
3
3
|
head
|
4
4
|
meta charset="utf-8"
|
5
|
-
|
5
|
+
meta property="fb:use_automatic_ad_placement" content="true"
|
6
|
+
link href="#{attr :canonical_href}" rel="canonical"
|
6
7
|
title=(doctitle(sanitize: true, use_fallback: true) || (attr 'untitled-label'))
|
7
8
|
meta content="default" property="fb:article_style"
|
8
9
|
body
|
@@ -13,10 +14,7 @@ html lang=(attr :lang, 'en' unless attr? :nolang)
|
|
13
14
|
img src="#{(attr :header_image)}" alt="" title="" layout="responsive" width="720" height="480"
|
14
15
|
address=(attr :author)
|
15
16
|
time class="op-modified" datetime="#{attr :docdatetime}" = attr :docdatetime
|
16
|
-
time class="op-published" datetime="
|
17
|
-
| article.header
|
17
|
+
time class="op-published" datetime="#{attr :revdatetime}" = attr :revdatetime
|
18
18
|
== content
|
19
19
|
footer
|
20
|
-
|
21
|
-
small © Copyright
|
22
|
-
| article.footer
|
20
|
+
small Spinoff © Copyright
|
@@ -0,0 +1,532 @@
|
|
1
|
+
require 'asciidoctor'
|
2
|
+
require 'json'
|
3
|
+
|
4
|
+
if Gem::Version.new(Asciidoctor::VERSION) <= Gem::Version.new('1.5.1')
|
5
|
+
fail 'asciidoctor: FAILED: HTML5/Slim backend needs Asciidoctor >=1.5.2!'
|
6
|
+
end
|
7
|
+
|
8
|
+
unless defined? Slim::Include
|
9
|
+
fail 'asciidoctor: FAILED: HTML5/Slim backend needs Slim >= 2.1.0!'
|
10
|
+
end
|
11
|
+
|
12
|
+
# Add custom functions to this module that you want to use in your Slim
|
13
|
+
# templates. Within the template you can invoke them as top-level functions
|
14
|
+
# just like in Haml.
|
15
|
+
module Slim::Helpers
|
16
|
+
|
17
|
+
# URIs of external assets.
|
18
|
+
FONT_AWESOME_URI = '//cdnjs.cloudflare.com/ajax/libs/font-awesome/4.5.0/css/font-awesome.min.css'
|
19
|
+
HIGHLIGHTJS_BASE_URI = '//cdnjs.cloudflare.com/ajax/libs/highlight.js/7.4'
|
20
|
+
MATHJAX_JS_URI = '//cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-MML-AM_HTMLorMML'
|
21
|
+
PRETTIFY_BASE_URI = '//cdnjs.cloudflare.com/ajax/libs/prettify/r298'
|
22
|
+
|
23
|
+
# Defaults
|
24
|
+
DEFAULT_HIGHLIGHTJS_THEME = 'github'
|
25
|
+
DEFAULT_PRETTIFY_THEME = 'prettify'
|
26
|
+
DEFAULT_SECTNUMLEVELS = 3
|
27
|
+
DEFAULT_TOCLEVELS = 2
|
28
|
+
|
29
|
+
# The MathJax configuration.
|
30
|
+
MATHJAX_CONFIG = {
|
31
|
+
tex2jax: {
|
32
|
+
inlineMath: [::Asciidoctor::INLINE_MATH_DELIMITERS[:latexmath]],
|
33
|
+
displayMath: [::Asciidoctor::BLOCK_MATH_DELIMITERS[:latexmath]],
|
34
|
+
ignoreClass: 'nostem|nolatexmath'
|
35
|
+
},
|
36
|
+
asciimath2jax: {
|
37
|
+
delimiters: [::Asciidoctor::BLOCK_MATH_DELIMITERS[:asciimath]],
|
38
|
+
ignoreClass: 'nostem|noasciimath'
|
39
|
+
}
|
40
|
+
}.to_json
|
41
|
+
|
42
|
+
VOID_ELEMENTS = %w(area base br col command embed hr img input keygen link meta param source track wbr)
|
43
|
+
|
44
|
+
|
45
|
+
##
|
46
|
+
# Creates an HTML tag with the given name and optionally attributes. Can take
|
47
|
+
# a block that will run between the opening and closing tags.
|
48
|
+
#
|
49
|
+
# @param name [#to_s] the name of the tag.
|
50
|
+
# @param attributes [Hash]
|
51
|
+
# @param content [#to_s] the content; +nil+ to call the block.
|
52
|
+
# @yield The block of Slim/HTML code within the tag (optional).
|
53
|
+
# @return [String] a rendered HTML element.
|
54
|
+
#
|
55
|
+
def html_tag(name, attributes = {}, content = nil)
|
56
|
+
attrs = attributes.reject { |_, v|
|
57
|
+
v.nil? || (v.respond_to?(:empty?) && v.empty?)
|
58
|
+
}.map do |k, v|
|
59
|
+
v = v.compact.join(' ') if v.is_a? Array
|
60
|
+
v = nil if v == true
|
61
|
+
v = %("#{v}") if v
|
62
|
+
[k, v] * '='
|
63
|
+
end
|
64
|
+
attrs_str = attrs.empty? ? '' : attrs.join(' ').prepend(' ')
|
65
|
+
|
66
|
+
if VOID_ELEMENTS.include? name.to_s
|
67
|
+
%(<#{name}#{attrs_str}>)
|
68
|
+
else
|
69
|
+
content ||= yield if block_given?
|
70
|
+
%(<#{name}#{attrs_str}>#{content}</#{name}>)
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
##
|
75
|
+
# Conditionally wraps a block in an element. If condition is +true+ then it
|
76
|
+
# renders the specified tag with optional attributes and the given
|
77
|
+
# block inside, otherwise it just renders the block.
|
78
|
+
#
|
79
|
+
# For example:
|
80
|
+
#
|
81
|
+
# = html_tag_if link?, 'a', {class: 'image', href: (attr :link)}
|
82
|
+
# img src='./img/tux.png'
|
83
|
+
#
|
84
|
+
# will produce:
|
85
|
+
#
|
86
|
+
# <a href="http://example.org" class="image">
|
87
|
+
# <img src="./img/tux.png">
|
88
|
+
# </a>
|
89
|
+
#
|
90
|
+
# if +link?+ is truthy, and just
|
91
|
+
#
|
92
|
+
# <img src="./img/tux.png">
|
93
|
+
#
|
94
|
+
# otherwise.
|
95
|
+
#
|
96
|
+
# @param condition [Boolean] the condition to test to determine whether to
|
97
|
+
# render the enclosing tag.
|
98
|
+
# @param name (see #html_tag)
|
99
|
+
# @param attributes (see #html_tag)
|
100
|
+
# @yield (see #html_tag)
|
101
|
+
# @return [String] a rendered HTML fragment.
|
102
|
+
#
|
103
|
+
def html_tag_if(condition, name, attributes = {}, &block)
|
104
|
+
if condition
|
105
|
+
html_tag name, attributes, &block
|
106
|
+
else
|
107
|
+
yield
|
108
|
+
end
|
109
|
+
end
|
110
|
+
|
111
|
+
##
|
112
|
+
# Surrounds a block with strings, with no whitespace in between.
|
113
|
+
#
|
114
|
+
# @example
|
115
|
+
# = surround '[', ']' do
|
116
|
+
# a href="#_footnote_1" 1
|
117
|
+
#
|
118
|
+
# [<a href="#_footnote_1">1</a>]
|
119
|
+
#
|
120
|
+
# @param front [String] the string to add before the block.
|
121
|
+
# @param back [String] the string to add after the block.
|
122
|
+
# @yield The block of Slim/HTML code to surround.
|
123
|
+
# @return [String] a rendered HTML fragment.
|
124
|
+
#
|
125
|
+
def surround(front, back = front)
|
126
|
+
[front, yield.chomp, back].join
|
127
|
+
end
|
128
|
+
|
129
|
+
##
|
130
|
+
# Wraps a block in a div element with the specified class and optionally
|
131
|
+
# the node's +id+ and +role+(s). If the node's +captioned_title+ is not
|
132
|
+
# empty, than a nested div with the class "title" and the title's content
|
133
|
+
# is added as well.
|
134
|
+
#
|
135
|
+
# Note: Every node has method +captioned_title+; if it doesn't have a
|
136
|
+
# caption, then this method returns just a naked title.
|
137
|
+
#
|
138
|
+
# @example When @id, @role and @title attributes are set.
|
139
|
+
# = block_with_title class: ['quoteblock', 'center']
|
140
|
+
# blockquote =content
|
141
|
+
#
|
142
|
+
# <div id="myid" class="quoteblock center myrole1 myrole2">
|
143
|
+
# <div class="title">Block Title</div>
|
144
|
+
# <blockquote>Lorem ipsum</blockquote>
|
145
|
+
# </div>
|
146
|
+
#
|
147
|
+
# @example When @id, @role and @title attributes are empty.
|
148
|
+
# = block_with_title class: 'quoteblock center', style: style_value(float: 'left')
|
149
|
+
# blockquote =content
|
150
|
+
#
|
151
|
+
# <div class="quoteblock center" style="float: left;">
|
152
|
+
# <blockquote>Lorem ipsum</blockquote>
|
153
|
+
# </div>
|
154
|
+
#
|
155
|
+
# @example When shorthand style for class attribute is used.
|
156
|
+
# = block_with_title 'quoteblock center'
|
157
|
+
# blockquote =content
|
158
|
+
#
|
159
|
+
# <div class="quoteblock center">
|
160
|
+
# <blockquote>Lorem ipsum</blockquote>
|
161
|
+
# </div>
|
162
|
+
#
|
163
|
+
# @param attributes [Hash, String] the tag's attributes as Hash),
|
164
|
+
# or the tag's class if it's not a Hash.
|
165
|
+
# @param title_position [:top, :bottom] position of the title element.
|
166
|
+
# @yield The block of Slim/HTML code within the tag (optional).
|
167
|
+
# @return [String] a rendered HTML fragment.
|
168
|
+
#
|
169
|
+
def block_with_title(attributes = {}, title_position = :top, &block)
|
170
|
+
if attributes.is_a? Hash
|
171
|
+
klass = attributes.delete(:class)
|
172
|
+
else
|
173
|
+
klass = attributes
|
174
|
+
attributes = {}
|
175
|
+
end
|
176
|
+
klass = klass.split(' ') if klass.is_a? String
|
177
|
+
attributes[:class] = [klass, role].flatten.uniq
|
178
|
+
attributes[:id] = id
|
179
|
+
|
180
|
+
html_tag 'div', attributes do
|
181
|
+
if captioned_title.nil_or_empty?
|
182
|
+
yield
|
183
|
+
else
|
184
|
+
ary = [ html_tag('div', {class: 'title'}, captioned_title), yield ]
|
185
|
+
ary.reverse! if title_position == :bottom
|
186
|
+
ary.compact.join "\n"
|
187
|
+
end
|
188
|
+
end
|
189
|
+
end
|
190
|
+
|
191
|
+
##
|
192
|
+
# Delimite the given equation as a STEM of the specified type.
|
193
|
+
#
|
194
|
+
# @param equation [String] the equation to delimite.
|
195
|
+
# @param type [#to_sym] the type of the STEM renderer (latexmath, or asciimath).
|
196
|
+
# @return [String] the delimited equation.
|
197
|
+
#
|
198
|
+
def delimit_stem(equation, type)
|
199
|
+
if is_a? ::Asciidoctor::Block
|
200
|
+
open, close = ::Asciidoctor::BLOCK_MATH_DELIMITERS[type.to_sym]
|
201
|
+
else
|
202
|
+
open, close = ::Asciidoctor::INLINE_MATH_DELIMITERS[type.to_sym]
|
203
|
+
end
|
204
|
+
|
205
|
+
unless equation.start_with?(open) && equation.end_with?(close)
|
206
|
+
equation = [open, equation, close].join
|
207
|
+
end
|
208
|
+
equation
|
209
|
+
end
|
210
|
+
|
211
|
+
##
|
212
|
+
# Formats the given hash as CSS declarations for an inline style.
|
213
|
+
#
|
214
|
+
# @example
|
215
|
+
# style_value(text_align: 'right', float: 'left')
|
216
|
+
# => "text-align: right; float: left;"
|
217
|
+
#
|
218
|
+
# style_value(text_align: nil, float: 'left')
|
219
|
+
# => "float: left;"
|
220
|
+
#
|
221
|
+
# style_value(width: [90, '%'], height: '50px')
|
222
|
+
# => "width: 90%; height: 50px;"
|
223
|
+
#
|
224
|
+
# style_value(width: ['120px', 'px'])
|
225
|
+
# => "width: 90px;"
|
226
|
+
#
|
227
|
+
# style_value(width: [nil, 'px'])
|
228
|
+
# => nil
|
229
|
+
#
|
230
|
+
# @param declarations [Hash]
|
231
|
+
# @return [String, nil]
|
232
|
+
#
|
233
|
+
def style_value(declarations)
|
234
|
+
decls = []
|
235
|
+
|
236
|
+
declarations.each do |prop, value|
|
237
|
+
next if value.nil?
|
238
|
+
|
239
|
+
if value.is_a? Array
|
240
|
+
value, unit = value
|
241
|
+
next if value.nil?
|
242
|
+
value = value.to_s + unit unless value.end_with? unit
|
243
|
+
end
|
244
|
+
prop = prop.to_s.gsub('_', '-')
|
245
|
+
decls << %(#{prop}: #{value})
|
246
|
+
end
|
247
|
+
|
248
|
+
decls.empty? ? nil : decls.join('; ') + ';'
|
249
|
+
end
|
250
|
+
|
251
|
+
def urlize(*segments)
|
252
|
+
path = segments * '/'
|
253
|
+
if path.start_with? '//'
|
254
|
+
@_uri_scheme ||= document.attr 'asset-uri-scheme', 'https'
|
255
|
+
path = %(#{@_uri_scheme}:#{path}) unless @_uri_scheme.empty?
|
256
|
+
end
|
257
|
+
normalize_web_path path
|
258
|
+
end
|
259
|
+
|
260
|
+
|
261
|
+
##
|
262
|
+
# @param index [Integer] the footnote's index.
|
263
|
+
# @return [String] footnote id to be used in a link.
|
264
|
+
def footnote_id(index = (attr :index))
|
265
|
+
%(_footnote_#{index})
|
266
|
+
end
|
267
|
+
|
268
|
+
##
|
269
|
+
# @param index (see #footnote_id)
|
270
|
+
# @return [String] footnoteref id to be used in a link.
|
271
|
+
def footnoteref_id(index = (attr :index))
|
272
|
+
%(_footnoteref_#{index})
|
273
|
+
end
|
274
|
+
|
275
|
+
def icons?
|
276
|
+
document.attr? :icons
|
277
|
+
end
|
278
|
+
|
279
|
+
def font_icons?
|
280
|
+
document.attr? :icons, 'font'
|
281
|
+
end
|
282
|
+
|
283
|
+
def nowrap?
|
284
|
+
'nowrap' if !document.attr?(:prewrap) || option?('nowrap')
|
285
|
+
end
|
286
|
+
|
287
|
+
##
|
288
|
+
# Returns corrected section level.
|
289
|
+
#
|
290
|
+
# @param sec [Asciidoctor::Section] the section node (default: self).
|
291
|
+
# @return [Integer]
|
292
|
+
#
|
293
|
+
def section_level(sec = self)
|
294
|
+
@_section_level ||= (sec.level == 0 && sec.special) ? 1 : sec.level
|
295
|
+
end
|
296
|
+
|
297
|
+
##
|
298
|
+
# Returns the captioned section's title, optionally numbered.
|
299
|
+
#
|
300
|
+
# @param sec [Asciidoctor::Section] the section node (default: self).
|
301
|
+
# @return [String]
|
302
|
+
#
|
303
|
+
def section_title(sec = self)
|
304
|
+
sectnumlevels = document.attr(:sectnumlevels, DEFAULT_SECTNUMLEVELS).to_i
|
305
|
+
|
306
|
+
if sec.numbered && !sec.caption && sec.level <= sectnumlevels
|
307
|
+
[sec.sectnum, sec.captioned_title].join(' ')
|
308
|
+
else
|
309
|
+
sec.captioned_title
|
310
|
+
end
|
311
|
+
end
|
312
|
+
|
313
|
+
#--------------------------------------------------------
|
314
|
+
# block_listing
|
315
|
+
#
|
316
|
+
|
317
|
+
def source_lang
|
318
|
+
attr :language, nil, false
|
319
|
+
end
|
320
|
+
|
321
|
+
#--------------------------------------------------------
|
322
|
+
# block_open
|
323
|
+
#
|
324
|
+
|
325
|
+
##
|
326
|
+
# Returns +true+ if an abstract block is allowed in this document type,
|
327
|
+
# otherwise prints warning and returns +false+.
|
328
|
+
def abstract_allowed?
|
329
|
+
if result = (parent == document && document.doctype == 'book')
|
330
|
+
puts 'asciidoctor: WARNING: abstract block cannot be used in a document without a title when doctype is book. Excluding block content.'
|
331
|
+
end
|
332
|
+
!result
|
333
|
+
end
|
334
|
+
|
335
|
+
##
|
336
|
+
# Returns +true+ if a partintro block is allowed in this context, otherwise
|
337
|
+
# prints warning and returns +false+.
|
338
|
+
def partintro_allowed?
|
339
|
+
if result = (level != 0 || parent.context != :section || document.doctype != 'book')
|
340
|
+
puts 'asciidoctor: ERROR: partintro block can only be used when doctype is book and it\'s a child of a book part. Excluding block content.'
|
341
|
+
end
|
342
|
+
!result
|
343
|
+
end
|
344
|
+
|
345
|
+
#--------------------------------------------------------
|
346
|
+
# block_table
|
347
|
+
#
|
348
|
+
|
349
|
+
def autowidth?
|
350
|
+
option? :autowidth
|
351
|
+
end
|
352
|
+
|
353
|
+
def spread?
|
354
|
+
'spread' if !(option? 'autowidth') && (attr :tablepcwidth) == 100
|
355
|
+
end
|
356
|
+
|
357
|
+
#--------------------------------------------------------
|
358
|
+
# block_video
|
359
|
+
#
|
360
|
+
|
361
|
+
# @return [Boolean] +true+ if the video should be embedded in an iframe.
|
362
|
+
def video_iframe?
|
363
|
+
['vimeo', 'youtube'].include?(attr :poster)
|
364
|
+
end
|
365
|
+
|
366
|
+
def video_uri
|
367
|
+
case (attr :poster, '').to_sym
|
368
|
+
when :vimeo
|
369
|
+
params = {
|
370
|
+
autoplay: (1 if option? 'autoplay'),
|
371
|
+
loop: (1 if option? 'loop')
|
372
|
+
}
|
373
|
+
start_anchor = %(#at=#{attr :start}) if attr? :start
|
374
|
+
%(//player.vimeo.com/video/#{attr :target}#{start_anchor}#{url_query params})
|
375
|
+
|
376
|
+
when :youtube
|
377
|
+
video_id, list_id = (attr :target).split('/', 2)
|
378
|
+
params = {
|
379
|
+
rel: 0,
|
380
|
+
start: (attr :start),
|
381
|
+
end: (attr :end),
|
382
|
+
list: (attr :list, list_id),
|
383
|
+
autoplay: (1 if option? 'autoplay'),
|
384
|
+
loop: (1 if option? 'loop'),
|
385
|
+
controls: (0 if option? 'nocontrols')
|
386
|
+
}
|
387
|
+
%(//www.youtube.com/embed/#{video_id}#{url_query params})
|
388
|
+
else
|
389
|
+
anchor = [(attr :start), (attr :end)].join(',').chomp(',')
|
390
|
+
anchor.prepend '#t=' unless anchor.empty?
|
391
|
+
media_uri %(#{attr :target}#{anchor})
|
392
|
+
end
|
393
|
+
end
|
394
|
+
|
395
|
+
# Formats URL query parameters.
|
396
|
+
def url_query(params)
|
397
|
+
str = params.map { |k, v|
|
398
|
+
next if v.nil? || v.to_s.empty?
|
399
|
+
[k, v] * '='
|
400
|
+
}.compact.join('&')
|
401
|
+
|
402
|
+
str.prepend('?') unless str.empty?
|
403
|
+
end
|
404
|
+
|
405
|
+
#--------------------------------------------------------
|
406
|
+
# document
|
407
|
+
#
|
408
|
+
|
409
|
+
##
|
410
|
+
# Returns HTML meta tag if the given +content+ is not +nil+.
|
411
|
+
#
|
412
|
+
# @param name [#to_s] the name for the metadata.
|
413
|
+
# @param content [#to_s, nil] the value of the metadata, or +nil+.
|
414
|
+
# @return [String, nil] the meta tag, or +nil+ if the +content+ is +nil+.
|
415
|
+
#
|
416
|
+
def html_meta_if(name, content)
|
417
|
+
%(<meta name="#{name}" content="#{content}">) if content
|
418
|
+
end
|
419
|
+
|
420
|
+
# Returns formatted style/link and script tags for header.
|
421
|
+
def styles_and_scripts
|
422
|
+
scripts = []
|
423
|
+
styles = []
|
424
|
+
tags = []
|
425
|
+
|
426
|
+
stylesheet = attr :stylesheet
|
427
|
+
stylesdir = attr :stylesdir, ''
|
428
|
+
default_style = ::Asciidoctor::DEFAULT_STYLESHEET_KEYS.include? stylesheet
|
429
|
+
linkcss = (attr? :linkcss) || safe >= ::Asciidoctor::SafeMode::SECURE
|
430
|
+
ss = ::Asciidoctor::Stylesheets.instance
|
431
|
+
|
432
|
+
if linkcss
|
433
|
+
path = default_style ? ::Asciidoctor::DEFAULT_STYLESHEET_NAME : stylesheet
|
434
|
+
styles << { href: [stylesdir, path] }
|
435
|
+
elsif default_style
|
436
|
+
styles << { text: ss.primary_stylesheet_data }
|
437
|
+
else
|
438
|
+
styles << { text: read_asset(normalize_system_path(stylesheet, stylesdir), true) }
|
439
|
+
end
|
440
|
+
|
441
|
+
if attr? :icons, 'font'
|
442
|
+
if attr? 'iconfont-remote'
|
443
|
+
styles << { href: (attr 'iconfont-cdn', FONT_AWESOME_URI) }
|
444
|
+
else
|
445
|
+
styles << { href: [stylesdir, %(#{attr 'iconfont-name', 'font-awesome'}.css)] }
|
446
|
+
end
|
447
|
+
end
|
448
|
+
|
449
|
+
if attr? 'stem'
|
450
|
+
scripts << { src: MATHJAX_JS_URI }
|
451
|
+
scripts << { type: 'text/x-mathjax-config', text: %(MathJax.Hub.Config(#{MATHJAX_CONFIG});) }
|
452
|
+
end
|
453
|
+
|
454
|
+
case attr 'source-highlighter'
|
455
|
+
when 'coderay'
|
456
|
+
if (attr 'coderay-css', 'class') == 'class'
|
457
|
+
if linkcss
|
458
|
+
styles << { href: [stylesdir, ss.coderay_stylesheet_name] }
|
459
|
+
else
|
460
|
+
styles << { text: ss.coderay_stylesheet_data }
|
461
|
+
end
|
462
|
+
end
|
463
|
+
|
464
|
+
when 'pygments'
|
465
|
+
if (attr 'pygments-css', 'class') == 'class'
|
466
|
+
if linkcss
|
467
|
+
styles << { href: [stylesdir, ss.pygments_stylesheet_name(attr 'pygments-style')] }
|
468
|
+
else
|
469
|
+
styles << { text: ss.pygments_stylesheet_data(attr 'pygments-style') }
|
470
|
+
end
|
471
|
+
end
|
472
|
+
|
473
|
+
when 'highlightjs'
|
474
|
+
hjs_base = attr :highlightjsdir, HIGHLIGHTJS_BASE_URI
|
475
|
+
hjs_theme = attr 'highlightjs-theme', DEFAULT_HIGHLIGHTJS_THEME
|
476
|
+
|
477
|
+
scripts << { src: [hjs_base, 'highlight.min.js'] }
|
478
|
+
scripts << { src: [hjs_base, 'lang/common.min.js'] }
|
479
|
+
scripts << { text: 'hljs.initHighlightingOnLoad()' }
|
480
|
+
styles << { href: [hjs_base, %(styles/#{hjs_theme}.min.css)] }
|
481
|
+
|
482
|
+
when 'prettify'
|
483
|
+
prettify_base = attr :prettifydir, PRETTIFY_BASE_URI
|
484
|
+
prettify_theme = attr 'prettify-theme', DEFAULT_PRETTIFY_THEME
|
485
|
+
|
486
|
+
scripts << { src: [prettify_base, 'prettify.min.js'] }
|
487
|
+
scripts << { text: 'document.addEventListener("DOMContentLoaded", prettyPrint)' }
|
488
|
+
styles << { href: [prettify_base, %(#{prettify_theme}.min.css)] }
|
489
|
+
end
|
490
|
+
|
491
|
+
styles.each do |item|
|
492
|
+
if item.key?(:text)
|
493
|
+
tags << html_tag(:style, {}, item[:text])
|
494
|
+
else
|
495
|
+
tags << html_tag(:link, rel: 'stylesheet', href: urlize(*item[:href]))
|
496
|
+
end
|
497
|
+
end
|
498
|
+
|
499
|
+
scripts.each do |item|
|
500
|
+
if item.key? :text
|
501
|
+
tags << html_tag(:script, {type: item[:type]}, item[:text])
|
502
|
+
else
|
503
|
+
tags << html_tag(:script, type: item[:type], src: urlize(*item[:src]))
|
504
|
+
end
|
505
|
+
end
|
506
|
+
|
507
|
+
tags.join "\n"
|
508
|
+
end
|
509
|
+
|
510
|
+
#--------------------------------------------------------
|
511
|
+
# inline_anchor
|
512
|
+
#
|
513
|
+
|
514
|
+
# @return [String, nil] text of the xref anchor, or +nil+ if not found.
|
515
|
+
def xref_text
|
516
|
+
str = text || document.references[:ids][attr :refid || target]
|
517
|
+
str.tr_s("\n", ' ') if str
|
518
|
+
end
|
519
|
+
|
520
|
+
#--------------------------------------------------------
|
521
|
+
# inline_image
|
522
|
+
#
|
523
|
+
|
524
|
+
# @return [Array] style classes for a Font Awesome icon.
|
525
|
+
def icon_fa_classes
|
526
|
+
[ %(fa fa-#{target}),
|
527
|
+
(%(fa-#{attr :size}) if attr? :size),
|
528
|
+
(%(fa-rotate-#{attr :rotate}) if attr? :rotate),
|
529
|
+
(%(fa-flip-#{attr :flip}) if attr? :flip)
|
530
|
+
].compact
|
531
|
+
end
|
532
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
- sect0 = section_level == 0
|
2
|
+
= html_tag_if !sect0, :div, class: [%(sect#{section_level}), role]
|
3
|
+
*{tag: %(h#{section_level + 1}), id: id, class: ('sect0' if sect0)}
|
4
|
+
- if id && (document.attr? :sectanchors)
|
5
|
+
a.anchor href="##{id}"
|
6
|
+
=section_title
|
7
|
+
- elsif id && (document.attr? :sectlinks)
|
8
|
+
a.link href="##{id}" =section_title
|
9
|
+
- else
|
10
|
+
=section_title
|
11
|
+
- if section_level == 1
|
12
|
+
/ .sectionbody =content
|
13
|
+
=content
|
14
|
+
- else
|
15
|
+
=content
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: asciidoctor-instant-articles
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.3.pre
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Fritz Lee
|
@@ -82,7 +82,9 @@ files:
|
|
82
82
|
- templates/slim/block_image.html.slim
|
83
83
|
- templates/slim/block_paragraph.html.slim
|
84
84
|
- templates/slim/document.html.slim
|
85
|
+
- templates/slim/helpers.rb
|
85
86
|
- templates/slim/inline_image.html.slim
|
87
|
+
- templates/slim/section.html.slim
|
86
88
|
homepage: https://github.com/askagirl/asciidoctor-instant-articles
|
87
89
|
licenses:
|
88
90
|
- MIT
|