asciidoctor-htmlbook 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.adoc +17 -0
- data/exe/asciidoctor-htmlbook +0 -0
- data/lib/asciidoctor/htmlbook/converter.rb +14 -12
- data/lib/asciidoctor/htmlbook/version.rb +1 -1
- data/templates/toc.html +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6253feaef2c1aaacf514ecbaa67d5f7f189d1220
|
4
|
+
data.tar.gz: 95ffa7913b589d55699219f51e7161f13706102b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4125934edc5ac7efcb26b54e674a01cb676180b41915056f0ddf2bc985357ec464af6322be24c1cbad755fbaba9545e3e5adca903a7d360bcf36a8c32cb24b93
|
7
|
+
data.tar.gz: 3b156de47c90a083d28dc0677db2f0adae658df2888c357cee12feed2f95790511dc0045fe403a4fae902006a610fd5e41e29df9648f84b85a5c4d13a7dc5986
|
data/README.adoc
CHANGED
@@ -119,6 +119,23 @@ asciidoctor-htmlbook template do not compatible with asciidoctor built-in templa
|
|
119
119
|
View link:./templates[] for more info.
|
120
120
|
--
|
121
121
|
|
122
|
+
== Add Table of Contents
|
123
|
+
|
124
|
+
Asciidoctor-htmlbook ignore `:toc:` attribute in Asciidoctor, instead you can use toc section:
|
125
|
+
|
126
|
+
[source, asciidoc]
|
127
|
+
--
|
128
|
+
[preface]
|
129
|
+
== Preface
|
130
|
+
|
131
|
+
[toc]
|
132
|
+
== Table of Contents
|
133
|
+
|
134
|
+
== Chapter
|
135
|
+
--
|
136
|
+
|
137
|
+
So that you can control position of toc.
|
138
|
+
|
122
139
|
== Development
|
123
140
|
|
124
141
|
After checking out the repo, run `bin/setup` to install dependencies. Then, run `bin/rake` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
data/exe/asciidoctor-htmlbook
CHANGED
File without changes
|
@@ -14,6 +14,8 @@ module Asciidoctor
|
|
14
14
|
def convert(node, transform = nil, options = {})
|
15
15
|
template = if (node.node_name == 'document' && transform == 'embedded')
|
16
16
|
get_template('embedded')
|
17
|
+
elsif node.node_name == 'section' && node.sectname == 'toc'
|
18
|
+
get_template('toc')
|
17
19
|
else
|
18
20
|
get_template(node.node_name)
|
19
21
|
end
|
@@ -95,7 +97,7 @@ module Asciidoctor
|
|
95
97
|
end
|
96
98
|
|
97
99
|
def section_to_liquid(node)
|
98
|
-
abstract_block_to_liquid(node).merge({
|
100
|
+
attributes = abstract_block_to_liquid(node).merge({
|
99
101
|
'index' => node.index,
|
100
102
|
'number' => node.number,
|
101
103
|
'sectname' => node.sectname,
|
@@ -103,20 +105,18 @@ module Asciidoctor
|
|
103
105
|
'numbered' => node.numbered,
|
104
106
|
'sectnum' => node.sectnum
|
105
107
|
})
|
108
|
+
|
109
|
+
if node.sectname == 'toc'
|
110
|
+
attributes['content'] = outline(node.document)
|
111
|
+
end
|
112
|
+
|
113
|
+
attributes
|
106
114
|
end
|
107
115
|
|
108
116
|
def block_to_liquid(node)
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
'blockname' => node.blockname,
|
113
|
-
'content' => outline(node.document)
|
114
|
-
})
|
115
|
-
else
|
116
|
-
abstract_block_to_liquid(node).merge({
|
117
|
-
'blockname' => node.blockname
|
118
|
-
})
|
119
|
-
end
|
117
|
+
abstract_block_to_liquid(node).merge({
|
118
|
+
'blockname' => node.blockname
|
119
|
+
})
|
120
120
|
end
|
121
121
|
|
122
122
|
def outline(node)
|
@@ -124,6 +124,8 @@ module Asciidoctor
|
|
124
124
|
if node.sections.any? && node.level < (node.document.attributes['toclevels'] || 2)
|
125
125
|
result << "<ol>"
|
126
126
|
node.sections.each do |section|
|
127
|
+
next if section.sectname == 'toc'
|
128
|
+
|
127
129
|
result << "<li>"
|
128
130
|
result << %Q(<a href="##{section.id}">)
|
129
131
|
result << "#{section.sectnum} " if section.numbered && section.level < (node.document.attributes['sectnumlevels'] || 3)
|
data/templates/toc.html
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: asciidoctor-htmlbook
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Rei
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-02-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: asciidoctor
|
@@ -170,7 +170,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
170
170
|
version: '0'
|
171
171
|
requirements: []
|
172
172
|
rubyforge_project:
|
173
|
-
rubygems_version: 2.
|
173
|
+
rubygems_version: 2.6.8
|
174
174
|
signing_key:
|
175
175
|
specification_version: 4
|
176
176
|
summary: Asciidoctor HTMLBook is an Asciidoctor backend for converting AsciiDoc documents
|