documentation-editor 0.7.3 → 0.7.4

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
  SHA1:
3
- metadata.gz: 5250f883b4283cdca899e237a2151c0a7ef5965b
4
- data.tar.gz: 0e71d88f7c6bfcc0b8e3828cbc5172c0a00ba2f6
3
+ metadata.gz: de6ab5535b10be65fab39e5972515d3c86606535
4
+ data.tar.gz: e03d7aaab44c81e490bc1319d2dfc2c49e7ec667
5
5
  SHA512:
6
- metadata.gz: ff664142b92947c9e36b51101bfa845e623fa675b4731d6afe192977bed246e269fc9e2b219d7bd94b1e79316f3b1fce0501af9fe172a05634b799bae9c72891
7
- data.tar.gz: 50fe800d79986d48317f1f243a4a6f9df8e00de3e78461dd635a40f89756027faa0b240e7a5a168b414f28383fd6d37741492167c7826ee838af570953e05b46
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
- code ||= content['codes'].detect { |code| code['language'].end_with?("|*") }
23
- @tree.children << Element.new(:html_element, 'pre')
24
- @tree.children.last.children << Element.new(:raw, code ? highlight(code['language'].split('|').first, code['code']) : "FIXME")
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
- ul = Element.new(:html_element, 'ul', { class: 'nav nav-tabs' })
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
@@ -1,3 +1,3 @@
1
1
  module DocumentationEditor
2
- VERSION = "0.7.3"
2
+ VERSION = "0.7.4"
3
3
  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.3
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-10 00:00:00.000000000 Z
11
+ date: 2016-05-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails