asciidoctor-boost 0.1.2 → 0.1.5

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: 75a4ae581c094dce6c60322d8f490d16e60c619a3772aa1a777e3a14d518c1cd
4
- data.tar.gz: 9803f6d7813beb549cb8baa2ddc1b6e0be292e51ffecf97ef0e9d4b7e2939c1c
3
+ metadata.gz: cc36671574d2dbb27181bdfd41fbb3215ae537ae007efc04414df02d8c9249ed
4
+ data.tar.gz: d391b4741b1c524aebd323dfa6ec29f96a6b59f8cfb17d94ccff46f2cf94c90b
5
5
  SHA512:
6
- metadata.gz: cd57499a073850b525904c7e0f1437e0713975a8678670c044a120d75da30823fb29e437172f202cfe7bb15df3f6e0cf9620011f8e3e75de2f406970097caffc
7
- data.tar.gz: a9cbe3948859666de10e10b2926e5af9be1bc237374b49094f83d2f507fedfd9313e16e404727e9514aa2341e54ebe66407a85386e8e286b46e7ace4248197d1
6
+ metadata.gz: b97dfd29b4dd276d9c86cd018205db330690c2de43ba5d705d1ae01109310c17bf348aea1c850627c963df1b407e7cc1e60ab27ab7ec26326ab282177837cfbc
7
+ data.tar.gz: defbf6d0e572e52e9c9cf78d713d160457d86d167e4593cc7e37462fb05603a4fb91cfe8fc98cded048ba7d919a206b81e2ed1f1d2721c229537560d2d97104c
@@ -12,11 +12,44 @@ require 'asciidoctor/extensions'
12
12
  class PhraseInlineMacro < Asciidoctor::Extensions::InlineMacroProcessor
13
13
  use_dsl
14
14
  named :boost_phrase
15
- name_positional_attributes 'text'
15
+ name_positional_attributes 'text', 'link'
16
16
 
17
17
  def process(parent, target, attrs)
18
- node = create_inline parent, :quoted, attrs['text'], type: :unquoted
19
- node.add_role target
20
- node
18
+ role = target
19
+ text = attrs['text'] || target
20
+ link = attrs['link']
21
+ backend = parent.document.backend
22
+
23
+ if link && !link.strip.empty?
24
+ process_with_link(parent, role, text, link, backend)
25
+ else
26
+ process_without_link(parent, role, text)
27
+ end
28
+ end
29
+
30
+ private
31
+
32
+ def process_with_link(parent, role, text, link, backend)
33
+ if backend == 'html5'
34
+ generate_html_output(role, link, text)
35
+ else
36
+ create_anchor_with_role(parent, role, text, link)
37
+ end
38
+ end
39
+
40
+ def process_without_link(parent, role, text)
41
+ span_node = create_inline parent, :quoted, text, type: :unquoted
42
+ span_node.add_role role
43
+ span_node
44
+ end
45
+
46
+ def generate_html_output(role, link, text)
47
+ %(<span class="#{role}"><a href="#{link}">#{text}</a></span>)
48
+ end
49
+
50
+ def create_anchor_with_role(parent, role, text, link)
51
+ anchor_node = create_inline parent, :anchor, text, type: :link, target: link
52
+ anchor_node.add_role role
53
+ anchor_node
21
54
  end
22
55
  end
data/lib/version.rb CHANGED
@@ -6,5 +6,5 @@
6
6
  # frozen_string_literal: true
7
7
 
8
8
  module Boost
9
- VERSION = '0.1.2'
9
+ VERSION = '0.1.5'
10
10
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: asciidoctor-boost
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dave O'Connor