-
Notifications
You must be signed in to change notification settings - Fork 102
/
Copy pathextension.rb
29 lines (27 loc) · 890 Bytes
/
extension.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
require 'asciidoctor/extensions' unless RUBY_ENGINE == 'opal'
include Asciidoctor
# An inline macro that extracts pull quotes for prose.
#
# Usage
#
# q:<[Content of pull quote.]
#
# TODO Use a DocinfoProcessor to add the necessary CSS to the output
# TODO Add a shortform that implies a default target position
class PullquoteInlineMacro < Extensions::InlineMacroProcessor
use_dsl
named :q
def process parent, target, attributes
align = (target == '<' || target == '<') ? 'left' : 'right'
if attributes.key? 'precede'
text = attributes['pull']
content = %(<span class="pullquote-#{align}" data-pullquote="#{text}"></span>
#{attributes['precede']}
#{text})
else
text = attributes.values * ', ' # iky!
content = %(<span class="pullquote-#{align}" data-pullquote="#{text}"></span>)
end
create_inline parent, :quoted, content
end
end