asciidoctor-boost 0.1.4 → 0.1.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/github/extension.rb +2 -2
- data/lib/phrase/extension.rb +37 -4
- data/lib/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fd1b00f5722b9ca23d796e7dc32af7101830ff7cfd3887c1d791fd988ad0a056
|
4
|
+
data.tar.gz: 7f5e9af6d0b19921298ae26fe8fab3d188d4fda732e99ce08bb6e68249f72ce0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f07626559ca226bef9540a8d47b88ad433e89f2d3c24b86a56cbceb8410e53e1959d9b5991f1536a783a996e1e32a4b302deedb48c1a0503fbefad46f8ea4161
|
7
|
+
data.tar.gz: 1daa5db9629dfb6436d81dc5ae8f636602a5910346068270f7291dc7b5150fc0aa2a5ae6981b8392198e9f5aac401a28622d6e3272280ec93b4e4a1be9ccefee
|
data/lib/github/extension.rb
CHANGED
@@ -17,9 +17,9 @@ class GithubInlineMacro < Asciidoctor::Extensions::InlineMacroProcessor
|
|
17
17
|
def process(parent, target, attrs)
|
18
18
|
content = "Target '#{target}' is invalid, check your syntax. Should be 'issue' or 'pr', not #{target}."
|
19
19
|
if target == 'issue'
|
20
|
-
content = "https://github.com/boostorg/#{attrs['repo']}/issues/#{attrs['number']}[
|
20
|
+
content = "https://github.com/boostorg/#{attrs['repo']}/issues/#{attrs['number']}[\##{attrs['number']}]"
|
21
21
|
elsif target == 'pr'
|
22
|
-
content = "https://github.com/boostorg/#{attrs['repo']}/pull/#{attrs['number']}[
|
22
|
+
content = "https://github.com/boostorg/#{attrs['repo']}/pull/#{attrs['number']}[PR\##{attrs['number']}]"
|
23
23
|
end
|
24
24
|
create_inline_pass parent, content
|
25
25
|
end
|
data/lib/phrase/extension.rb
CHANGED
@@ -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
|
-
|
19
|
-
|
20
|
-
|
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