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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 698b27b3f58ab674d66a92098ccfff53d860e451
4
- data.tar.gz: f23c83a00cd575f20102a1c46a06005b86e53649
3
+ metadata.gz: 6253feaef2c1aaacf514ecbaa67d5f7f189d1220
4
+ data.tar.gz: 95ffa7913b589d55699219f51e7161f13706102b
5
5
  SHA512:
6
- metadata.gz: a646db7a4e9701ffefb81acff7fcbdd41e7853407690da7dbe13a35642f8fcc0ce0fe1c659dfb30bce679896a7f3e2952a6f2e10e08a2e8f4383e8b58a5d437c
7
- data.tar.gz: 187c948b262edf7ecc2b10cdf03ee84ac966445311211e4994817595eb91c65c65032e8c9bd77904cbf988a95832102096ae0ef3bc9bb0b0f381378a0e654f46
6
+ metadata.gz: 4125934edc5ac7efcb26b54e674a01cb676180b41915056f0ddf2bc985357ec464af6322be24c1cbad755fbaba9545e3e5adca903a7d360bcf36a8c32cb24b93
7
+ data.tar.gz: 3b156de47c90a083d28dc0677db2f0adae658df2888c357cee12feed2f95790511dc0045fe403a4fae902006a610fd5e41e29df9648f84b85a5c4d13a7dc5986
@@ -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.
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
- case node.context
110
- when :toc
111
- abstract_block_to_liquid(node).merge({
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)
@@ -1,5 +1,5 @@
1
1
  module Asciidoctor
2
2
  module Htmlbook
3
- VERSION = "0.0.2"
3
+ VERSION = "0.0.3"
4
4
  end
5
5
  end
@@ -1,4 +1,4 @@
1
- <nav data-type="toc">
1
+ <nav id="{{ node.id }}" data-type="toc">
2
2
  <h1>{{ node.document.attributes.toc-title }}</h1>
3
3
  {{ node.content }}
4
4
  </nav>
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.2
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-01-31 00:00:00.000000000 Z
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.5.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