documentation-editor 0.7.3 → 0.7.4
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 +4 -4
- data/lib/documentation_editor/parser.rb +26 -17
- data/lib/documentation_editor/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: de6ab5535b10be65fab39e5972515d3c86606535
|
4
|
+
data.tar.gz: e03d7aaab44c81e490bc1319d2dfc2c49e7ec667
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 010751dda66697d31eac0616851c702dedf4a0b006bff9f43a205a75994959c01c97adb4002f7b2386deace28d358bb44a6adfdae4aafe8e984c9d6308a106e1
|
7
|
+
data.tar.gz: c335fcbc750559cf1aa8772892ab8f1b91a5989fde5af0c96f5c9e86b889e870ab552b879472a57374645ac38aa3e2a24ca4ab3a320b61aeea7189c26b19152b
|
@@ -19,28 +19,20 @@ class Kramdown::Parser::BlockKramdown < Kramdown::Parser::Kramdown
|
|
19
19
|
when 'code'
|
20
20
|
if @language
|
21
21
|
code = content['codes'].detect { |code| code['language'] == @language || code['language'].end_with?("|#{@language}") }
|
22
|
-
|
23
|
-
|
24
|
-
|
22
|
+
matchall_codes = content['codes'].select { |code| code['language'].end_with?("|*") }
|
23
|
+
if code || matchall_codes.size == 1
|
24
|
+
code ||= matchall_codes.first
|
25
|
+
@tree.children << Element.new(:html_element, 'pre')
|
26
|
+
@tree.children.last.children << Element.new(:raw, code ? highlight(code['language'].split('|').first, code['code']) : "FIXME")
|
27
|
+
else
|
28
|
+
append_code_tabs matchall_codes
|
29
|
+
end
|
25
30
|
elsif content['codes'].size == 1
|
26
31
|
code = content['codes'].first
|
27
32
|
@tree.children << Element.new(:html_element, 'pre')
|
28
33
|
@tree.children.last.children << Element.new(:raw, highlight(code['language'].split('|').first, code['code']))
|
29
34
|
else
|
30
|
-
|
31
|
-
tab_content = Element.new(:html_element, 'div', { class: 'tab-content' })
|
32
|
-
content['codes'].each_with_index do |v, i|
|
33
|
-
language, label = v['language'].split('|')
|
34
|
-
label ||= language
|
35
|
-
id = "snippet_#{@src.pos}_#{generate_id(v['language'])}"
|
36
|
-
ul.children << Element.new(:html_element, 'li', { class: ('active' if i == 0) })
|
37
|
-
ul.children.last.children << Element.new(:html_element, 'a', { href: "##{id}", 'data-toggle' => 'tab' })
|
38
|
-
ul.children.last.children.last.children << Element.new(:raw, label)
|
39
|
-
tab_content.children << Element.new(:html_element, 'pre', { class: "tab-pane#{' in active' if i == 0}", id: id })
|
40
|
-
tab_content.children.last.children << Element.new(:raw, highlight(language, v['code']))
|
41
|
-
end
|
42
|
-
@tree.children << ul
|
43
|
-
@tree.children << tab_content
|
35
|
+
append_code_tabs(content['codes'])
|
44
36
|
end
|
45
37
|
when 'callout'
|
46
38
|
callout = new_block_el(:html_element, 'div', { class: "alert alert-#{content['type']}" })
|
@@ -151,4 +143,21 @@ class Kramdown::Parser::BlockKramdown < Kramdown::Parser::Kramdown
|
|
151
143
|
Kramdown::Document.new(text, input: 'BlockKramdown').to_html
|
152
144
|
end
|
153
145
|
end
|
146
|
+
|
147
|
+
def append_code_tabs(codes)
|
148
|
+
ul = Element.new(:html_element, 'ul', { class: 'nav nav-tabs' })
|
149
|
+
tab_content = Element.new(:html_element, 'div', { class: 'tab-content' })
|
150
|
+
codes.each_with_index do |v, i|
|
151
|
+
language, label = v['language'].split('|')
|
152
|
+
label = language if label.nil? || label == '*'
|
153
|
+
id = "snippet_#{@src.pos}_#{generate_id(v['language'])}"
|
154
|
+
ul.children << Element.new(:html_element, 'li', { class: ('active' if i == 0) })
|
155
|
+
ul.children.last.children << Element.new(:html_element, 'a', { href: "##{id}", 'data-toggle' => 'tab' })
|
156
|
+
ul.children.last.children.last.children << Element.new(:raw, label)
|
157
|
+
tab_content.children << Element.new(:html_element, 'pre', { class: "tab-pane#{' in active' if i == 0}", id: id })
|
158
|
+
tab_content.children.last.children << Element.new(:raw, highlight(language, v['code']))
|
159
|
+
end
|
160
|
+
@tree.children << ul
|
161
|
+
@tree.children << tab_content
|
162
|
+
end
|
154
163
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: documentation-editor
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.7.
|
4
|
+
version: 0.7.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Algolia Team
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-03
|
11
|
+
date: 2016-05-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|