Skip to content

Commit 1a387a2

Browse files
committed
Add copy button for dotted config properties
1 parent db90a71 commit 1a387a2

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

_plugins/asciidoctor-extension.rb

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,21 @@
5252
end
5353
end
5454

55+
def escape_double_quotes(str)
56+
str.gsub(/"/) { |x| %(\\#{x}) }
57+
end
58+
59+
Extensions.register do
60+
inline_macro do
61+
named :config_property_copy_button
62+
resolve_attributes false
63+
process do |parent, target, attrs|
64+
config_property = escape_double_quotes(target)
65+
copy_btn = %(<button class="btn-copy fa fa-clipboard inline-btn-copy" data-clipboard-action="copy" data-clipboard-text="#{config_property}" title="Copy to clipboard" do-not-collapse="true"></button>)
66+
create_inline_pass parent, %(#{copy_btn})
67+
end
68+
end
69+
end
5570

5671
### ALL CONFIG page processors
5772

0 commit comments

Comments
 (0)