card-mod-legacy 0.11.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 816a384eee47d066c842f9a8be422ac6a0bb6b410e2e66b785d188a8bda1f9fe
4
+ data.tar.gz: 7c5e92fb9e8a4083091709fe40feaa99eaca3e8942ef9a917c3ba55fc9958a84
5
+ SHA512:
6
+ metadata.gz: c8d56fda67159d55eb44d08a8264788987bca67115a1b728b8782b07f4422ac59f02094b252b5c2da68d70961739f334711bec60c8268dd8297bef8c2b00f3d8
7
+ data.tar.gz: fc98eb15189a0cf22ce3048d7cb7a75250eee82549954f6f0ea6ba8f87fab2b2e7583fdbc9b5bb474585d177f8e45324f3593b89a7b67e5f4ffaf48a19879af4
@@ -0,0 +1,64 @@
1
+ format :html do
2
+ view :open_content do
3
+ with_table_of_contents _render_core
4
+ end
5
+
6
+ view :titled_content do
7
+ with_table_of_contents _render_core
8
+ end
9
+
10
+ def with_table_of_contents content
11
+ table_of_contents(content) || content
12
+ end
13
+
14
+ def table_of_contents content
15
+ return if nest_mode == :compact || !content.present? || toc_minimum&.zero?
16
+
17
+ toc = toc_items content
18
+ return unless toc.flatten.length >= toc_minimum
19
+
20
+ content.replace(
21
+ %( <div class="table-of-contents"> <h5>#{tr(:toc)}</h5> ) +
22
+ make_table_of_contents_list(toc) + "</div>" + content
23
+ )
24
+ end
25
+
26
+ def toc_minimum
27
+ @toc_minimum ||= card.rule(:table_of_contents).to_i
28
+ end
29
+
30
+ def toc_items content
31
+ toc = []
32
+ dep = 1
33
+ content.gsub!(/<(h\d)>(.*?)<\/h\d>/i) do |match|
34
+ if $LAST_MATCH_INFO
35
+ tag, value = $LAST_MATCH_INFO[1, 2]
36
+ value = strip_tags(value).strip
37
+ next if value.empty?
38
+ item = { value: value, uri: URI.escape(value) }
39
+ case tag.downcase
40
+ when "h1"
41
+ item[:depth] = dep = 1
42
+ toc << item
43
+ when "h2"
44
+ toc << [] if dep == 1
45
+ item[:depth] = dep = 2
46
+ toc.last << item
47
+ end
48
+ %(<a name="#{item[:uri]}"></a>#{match})
49
+ end
50
+ end
51
+ toc
52
+ end
53
+
54
+ def make_table_of_contents_list items
55
+ list = items.map do |i|
56
+ if i.is_a?(Array)
57
+ make_table_of_contents_list(i)
58
+ else
59
+ %(<li><a href="##{i[:uri]}"> #{i[:value]}</a></li>)
60
+ end
61
+ end.join("\n")
62
+ "<ol>" + list + "</ol>"
63
+ end
64
+ end
@@ -0,0 +1 @@
1
+ setting_opts group: :templating, position: 3, rule_type_editable: true
@@ -0,0 +1 @@
1
+ setting_opts group: :other, position: 4, rule_type_editable: false
@@ -0,0 +1,4 @@
1
+ setting_opts group: :other, position: 1, rule_type_editable: false,
2
+ help_text: "Autogenerate [[http://decko.org/table_of_contents|"\
3
+ "table of contents]] on cards with at least this many headers "\
4
+ '("0" means never).'
@@ -0,0 +1 @@
1
+ include_set Abstract::TableOfContents
metadata ADDED
@@ -0,0 +1,65 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: card-mod-legacy
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.11.0
5
+ platform: ruby
6
+ authors:
7
+ - Ethan McCutchen
8
+ - Philipp Kühl
9
+ - Gerry Gleason
10
+ autorequire:
11
+ bindir: bin
12
+ cert_chain: []
13
+ date: 2020-12-24 00:00:00.000000000 Z
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: card
17
+ requirement: !ruby/object:Gem::Requirement
18
+ requirements:
19
+ - - '='
20
+ - !ruby/object:Gem::Version
21
+ version: 1.101.0
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ requirements:
26
+ - - '='
27
+ - !ruby/object:Gem::Version
28
+ version: 1.101.0
29
+ description: ''
30
+ email:
31
+ - info@decko.org
32
+ executables: []
33
+ extensions: []
34
+ extra_rdoc_files: []
35
+ files:
36
+ - set/abstract/table_of_contents.rb
37
+ - set/self/csv_structure.rb
38
+ - set/self/default_html_view.rb
39
+ - set/self/table_of_contents.rb
40
+ - set/type/basic.rb
41
+ homepage: http://decko.org
42
+ licenses:
43
+ - GPL-3.0
44
+ metadata:
45
+ card-mod: legacy
46
+ post_install_message:
47
+ rdoc_options: []
48
+ require_paths:
49
+ - lib
50
+ required_ruby_version: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '2.5'
55
+ required_rubygems_version: !ruby/object:Gem::Requirement
56
+ requirements:
57
+ - - ">="
58
+ - !ruby/object:Gem::Version
59
+ version: '0'
60
+ requirements: []
61
+ rubygems_version: 3.0.3
62
+ signing_key:
63
+ specification_version: 4
64
+ summary: legacy
65
+ test_files: []