asciidoctor-tabs 1.0.0.beta.3 → 1.0.0.beta.5

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
  SHA256:
3
- metadata.gz: 79ee9882999f6e27787ce575352f3382272a502fa99c3e33090c265110290ab8
4
- data.tar.gz: 1c8d5d2001a1b8f277ae84fc0c4e0f0d54f65266d97bd948e78835de7d5a91ae
3
+ metadata.gz: 917cc515ced6b0c7599132ddab2d1f72da09b6af4bf7e62774fed3be43363377
4
+ data.tar.gz: f72d696d910cd046e05acdec439da2f2d407088e2972bbc2a5259049cd3626a0
5
5
  SHA512:
6
- metadata.gz: 4bf6818b2492f96aee01f2d29658e09a5bac3614e3c6e6565a83a817d0b1c5cf80897da04ca7859f0fe2fa6ce587cd5f10e37b74688a78e3c4d07a94a0b8d350
7
- data.tar.gz: 12a6df3597b1c1da6fbff9f3bf130d1ec34d0485102bf780a27d8cde79596a22ca44b8f6620ab202ca6ac03d386da94e155d58b49d186e47117a02864ea5998e
6
+ metadata.gz: 500f6ee93e370b09e404531abad5d9fae5eea8cbb81ea1bf3b5a5c599dac1a48c961922fe88b9260bf8cf5a536e2db91378314433b5c35eeefff348016313f40
7
+ data.tar.gz: e0c6683a932a88629d79d72b38bc3c9ff0fd8ac7446a16d264e7579b13b91ebfd83032ab1193e4c389b649c418b680d5790f52e00d7e8ba2e6c6fccf847c8915
data/CHANGELOG.adoc CHANGED
@@ -4,6 +4,37 @@
4
4
  This document provides a curated view of the changes to Asciidoctor Tabs per release.
5
5
  For a detailed view of what has changed, refer to the {url-repo}/commits/main[commit history] on GitHub.
6
6
 
7
+ == 1.0.0-beta.5 (2023-05-28) - @mojavelinux
8
+
9
+ === Changed
10
+
11
+ * Ensure tab number sequence follows document order when tabs blocks are nested (#61)
12
+
13
+ === Fixed
14
+
15
+ * Only remove open block enclosure around tab content if it is anonymous; preserve nested tabs block (#59)
16
+
17
+ === Details
18
+
19
+ {url-repo}/releases/tag/v1.0.0-beta.5[git tag] | {url-repo}/compare/v1.0.0-beta.4\...v1.0.0-beta.5[full diff]
20
+
21
+ == 1.0.0-beta.4 (2023-05-22) - @mojavelinux
22
+
23
+ === Changed
24
+
25
+ * Rework styles for tab to make them compatible with a transition effect; stub in effect in built-in stylesheet
26
+ * Add tab class to tab element (if missing) rather than overwriting className property to preserve existing class names
27
+
28
+ === Fixed
29
+
30
+ * Don't alter state of nested tabs when tab is selected (#55)
31
+ * Don't wrap tables inside nested tabs with tablecontainer div multiple times (#55)
32
+ * Fix fallback logic in behavior script when tab is missing ID or does not match a panel
33
+
34
+ === Details
35
+
36
+ {url-repo}/releases/tag/v1.0.0-beta.4[git tag] | {url-repo}/compare/v1.0.0-beta.3\...v1.0.0-beta.4[full diff]
37
+
7
38
  == 1.0.0-beta.3 (2023-02-01) - @mojavelinux
8
39
 
9
40
  === Added
data/README.adoc CHANGED
@@ -1,6 +1,6 @@
1
1
  = Asciidoctor Tabs
2
2
  Dan Allen <https://github.com/mojavelinux[@mojavelinux]>
3
- v1.0.0-beta.3, 2023-02-01
3
+ v1.0.0-beta.5, 2023-05-28
4
4
  :idprefix:
5
5
  :idseparator: -
6
6
  ifndef::env-github[:icons: font]
@@ -12,14 +12,14 @@ endif::[]
12
12
  An Asciidoctor extension that adds a tabs block to the AsciiDoc syntax.
13
13
 
14
14
  NOTE: This extension is intended to be used with HTML backends (e.g., `html5`).
15
- For all other backends (i.e., the filetype is not html), the custom block enclosure is taken away and its contents (a dlist) is converted normally.
15
+ For all other backends (i.e., the filetype is not html), the custom block enclosure is discarded and its contents (a dlist) is converted normally.
16
16
 
17
17
  TIP: This extension is also published as an npm package named `@asciidoctor/tabs` for use with Asciidoctor.js.
18
18
  See the xref:js/README.adoc[README in the js folder] for details.
19
19
 
20
20
  == Overview
21
21
 
22
- Each set of tabs (aka a "`tabset`" or tabs block) is constructed from a description list (dlist) enclosed in an example block marked with the tabs style (i.e., `[tab]`).
22
+ Each set of tabs (i.e., a "`tabset`" or tabs block) is constructed from a description list (dlist) enclosed in an example block annotated with the tabs style (i.e., `[tab]`).
23
23
  That nested combination of blocks gets translated by this extension into a single tabs block that is a specialization of an open block.
24
24
 
25
25
  The tabbed interface produced from this block can help organize information by code language, operating system, or product variant.
@@ -57,37 +57,38 @@ Then use Bundler to install the gem:
57
57
 
58
58
  == Syntax
59
59
 
60
- A tabset is defined using a description list (dlist) enclosed in an example block marked with the tabs style.
60
+ A tabset is defined using a description list (dlist) enclosed in an example block annotated with the tabs style.
61
61
 
62
- .document-with-tabs.adoc
62
+ .tabs.adoc
63
63
  [,asciidoc]
64
64
  ----
65
65
  [tabs]
66
66
  ====
67
- Tab A:: Contents of tab A.
67
+ Tab A:: Contents of Tab A.
68
68
 
69
69
  Tab B::
70
70
  +
71
- Contents of tab B.
71
+ Contents of Tab B.
72
72
 
73
73
  Tab C::
74
74
  +
75
75
  --
76
- Contents of tab C.
76
+ Contents of Tab C.
77
77
 
78
78
  Contains more than one block.
79
79
  --
80
80
  ====
81
81
  ----
82
82
 
83
- The tabbed content is modeled as a dlist.
83
+ The tabs themselves are modeled as a dlist.
84
84
  Each item in the dlist becomes a separate tab.
85
85
  The term is used as the tab's label and the description is used as the tab's contents.
86
86
  The contents can be defined as primary text, attached blocks, or both.
87
- If the attached blocks are themselves enclosed in a single open block, the open block enclosure itself is discarded upon conversion.
87
+ If the tab has a single attached block, and that block is an open block with no attributes, the open block enclosure itself is discarded upon conversion.
88
88
 
89
89
  You may choose to extend the block delimiter length from the typical 4 characters to 6 in order to avoid conflicts with any example blocks inside the tabs block (or just as a matter of style).
90
90
 
91
+ .tab-with-example-block.adoc
91
92
  [,asciidoc]
92
93
  ----
93
94
  [tabs]
@@ -102,52 +103,172 @@ Tab B:: Just text.
102
103
  ======
103
104
  ----
104
105
 
106
+ Using this technique, you can also create nested tabsets.
107
+
108
+ .tab-with-nested-tabs.adoc
109
+ [,asciidoc]
110
+ ----
111
+ [tabs]
112
+ ======
113
+ Tab A::
114
+ +
115
+ Selecting Tab A reveals a tabset with Tab Y and Tab Z.
116
+ +
117
+ [tabs]
118
+ ====
119
+ Tab Y:: Contents of Tab Y, nested inside Tab A.
120
+ Tab Z:: Contents of Tab Z, nested inside Tab A.
121
+ ====
122
+
123
+ Tab B:: Just text.
124
+ ======
125
+ ----
126
+
105
127
  == Tabs Sync
106
128
 
107
- If you want to synchronize the tab selection across tabsets, set the `tabs-sync-option` on the document.
129
+ If you want to synchronize (i.e., sync) the tab selection across tabsets, set the `tabs-sync-option` on the document.
108
130
 
109
- .document-with-tabs-sync.adoc
131
+ .tabs-sync.adoc
110
132
  [,asciidoc]
111
133
  ----
112
134
  :tabs-sync-option:
113
135
 
114
136
  [tabs]
115
137
  ====
116
- Tab A:: Contents of tab A in first tabset.
117
- Tab B:: Contents of tab B in first tabset.
138
+ Tab A:: Triggers selection of Tab A in other congruent tabsets.
139
+ Tab B:: Triggers selection of Tab B in other congruent tabsets.
118
140
  ====
119
141
 
120
142
  ...
121
143
 
122
144
  [tabs]
123
145
  ====
124
- Tab A:: Contents of tab A in second tabset.
125
- Tab B:: Contents of tab B in second tabset.
146
+ Tab A:: Triggers selection of Tab A in other congruent tabsets.
147
+ Tab B:: Triggers selection of Tab B in other congruent tabsets.
148
+ ====
149
+ ----
150
+
151
+ Only tabsets that have the same sync group ID are synchronized.
152
+ By default, the sync group ID is computed by taking the text of each tab, sorting that list, and joining it on `|` (e.g., `A|B`).
153
+ Each unique combination of tabs--or congruent tablist--implicitly creates a new sync group.
154
+
155
+ You can override the sync group ID of a tabset using the `sync-group-id` attribute on the block.
156
+ This allows you to control the scope of the sync or to force a tabset to participate in a sync group even if its not congruent.
157
+
158
+ .tabs-with-custom-sync-groups.adoc
159
+ [,asciidoc]
160
+ ----
161
+ :tabs-sync-option:
162
+
163
+ [tabs,sync-group-id=group-1]
164
+ ====
165
+ Tab A:: Triggers selection of Tab A in second tabset.
166
+ Tab B:: Triggers selection of Tab B in second tabset.
167
+ ====
168
+
169
+ [tabs,sync-group-id=group-1]
170
+ ====
171
+ Tab A:: Triggers selection of Tab A in first tabset.
172
+ Tab B:: Triggers selection of Tab B in first tabset.
173
+ ====
174
+
175
+ [tabs,sync-group-id=group-2]
176
+ ====
177
+ Tab A:: Triggers selection of Tab A in fourth tabset.
178
+ Tab B:: Triggers selection of Tab B in fourth tabset.
179
+ ====
180
+
181
+ [tabs,sync-group-id=group-2]
182
+ ====
183
+ Tab A:: Triggers selection of Tab A in third tabset.
184
+ Tab B:: Triggers selection of Tab B in third tabset.
126
185
  ====
127
186
  ----
128
187
 
129
- Only tabs blocks with congruent tablists are synchronized by default.
130
- Each unique combination of tabs implicitly creates a new sync group.
131
- You can override the sync group ID using the `sync-group-id` attribute on a tabs block to force it to participate in a sync group.
132
- By default, the sync group ID is derived from the text of each tab, sorted, then joined on `|` (e.g., `A|B`).
188
+ Instead of enabling tabs sync globally, you can set the `sync` option on individual tabs blocks.
133
189
 
134
- Alternately, you can set the `sync` option on each tabs block.
135
- If you want to delist a tabs block from sync, set the `nosync` option on that block.
190
+ .tabs-with-sync-option.adoc
191
+ [,asciidoc]
192
+ ----
193
+ [tabs%sync]
194
+ ====
195
+ Tab A:: Triggers selection of Tab A in third tabset.
196
+ Tab B:: Triggers selection of Tab B in third tabset.
197
+ ====
198
+
199
+ [tabs]
200
+ ====
201
+ Tab A:: Does not trigger selection of Tab A in other tabsets.
202
+ Tab B:: Does not trigger selection of Tab B in other tabsets.
203
+ ====
204
+
205
+ [tabs%sync]
206
+ ====
207
+ Tab A:: Triggers selection of Tab A in first tabset.
208
+ Tab B:: Triggers selection of Tab B in first tabset.
209
+ ====
210
+ ----
211
+
212
+ Conversely, if you want to delist a tabs block from the global sync, set the `nosync` option on that block.
213
+
214
+ .tabs-with-nosync-option.adoc
215
+ [,asciidoc]
216
+ ----
217
+ :tabs-sync-option:
218
+
219
+ [tabs]
220
+ ====
221
+ Tab A:: Triggers selection of Tab A in third tabset.
222
+ Tab B:: Triggers selection of Tab B in third tabset.
223
+ ====
224
+
225
+ [tabs%nosync]
226
+ ====
227
+ Tab A:: Does not trigger selection of Tab A in other tabsets.
228
+ Tab B:: Does not trigger selection of Tab B in other tabsets.
229
+ ====
230
+
231
+ [tabs]
232
+ ====
233
+ Tab A:: Triggers selection of Tab A in first tabset.
234
+ Tab B:: Triggers selection of Tab B in first tabset.
235
+ ====
236
+ ----
136
237
 
137
238
  If you want to persist the sync selection, assign a value to the `data-sync-storage-key` attribute on the `<script>` tag.
138
- By default, the sync selection will be assigned to the specified key in local storage.
139
- You can set the `data-sync-storage-scope` attribute on the `<script>` tag to `session` to use session storage instead.
140
- When using the extension on a standalone document, you can configure these options using the `tabs-sync-storage-key` and `tabs-sync-storage-scope` document attributes, respectively.
239
+
240
+ [,js]
241
+ ----
242
+ <script data-sync-storage-key="preferred-tab">
243
+ ----
244
+
245
+ By default, the sync selection (per group) will be persisted to local storage (i.e., `data-sync-storage-scope="local"`) using the specified key.
246
+ You can set the `data-sync-storage-scope` attribute on the `<script>` tag to `session` to use session storage instead of local storage.
247
+
248
+ [,js]
249
+ ----
250
+ <script data-sync-storage-key="preferred-tab" data-sync-storage-scope="session">
251
+ ----
252
+
253
+ When using the extension on a standalone document (which will automatically embed the supporting script), you can configure these options using the `tabs-sync-storage-key` and `tabs-sync-storage-scope` document attributes, respectively.
254
+
255
+ [,asciidoc]
256
+ ----
257
+ :tabs-sync-storage-key: tabs
258
+ :tabs-sync-storage-scope: session
259
+ ----
260
+
261
+ In this case, the converter will set the corresponding attributes on the `<script>` tag automatically.
141
262
 
142
263
  == Usage
143
264
 
144
265
  === CLI
145
266
 
146
- $ asciidoctor -r asciidoctor-tabs document-with-tabs.adoc
267
+ $ asciidoctor -r asciidoctor-tabs tabs.adoc
147
268
 
148
269
  You can specify an alternate stylesheet for tabs using the `tabs-stylesheet` document attribute.
149
270
 
150
- $ asciidoctor -r asciidoctor-tabs -a tabs-stylesheet=my-tabs.css document-with-tabs.adoc
271
+ $ asciidoctor -r asciidoctor-tabs -a tabs-stylesheet=my-tabs.css tabs.adoc
151
272
 
152
273
  The value of the `tabs-stylesheet` attribute is handled in the same way as the built-in `stylesheet` document attribute.
153
274
  A relative path is resolved starting from the value of the `stylesdir` document attribute, which defaults to the directory of the document.
@@ -164,7 +285,7 @@ You can require `asciidoctor/tabs` to register the extension as a global extensi
164
285
  require 'asciidoctor'
165
286
  require 'asciidoctor/tabs'
166
287
 
167
- Asciidoctor.convert_file 'document-with-tabs.adoc', safe: :safe
288
+ Asciidoctor.convert_file 'tabs.adoc', safe: :safe
168
289
  ----
169
290
 
170
291
  Or you can pass a registry instance to the `Extensions.register` method to register the extension with a scoped registry.
@@ -177,14 +298,14 @@ require 'asciidoctor/tabs/extensions'
177
298
  registry = Asciidoctor::Extensions.create
178
299
  Asciidoctor::Tabs::Extensions.register registry
179
300
 
180
- Asciidoctor.convert_file 'document-with-tabs.adoc', extension_registry: registry, safe: :safe
301
+ Asciidoctor.convert_file 'tabs.adoc', extension_registry: registry, safe: :safe
181
302
  ----
182
303
 
183
304
  If you're not using other scoped extensions, you can pass in the extensions group without first creating a registry instance:
184
305
 
185
306
  [,js]
186
307
  ----
187
- Asciidoctor.convert_file 'document-with-tabs.adoc', extensions: Asciidoctor::Tabs::Extensions.group, safe: :safe
308
+ Asciidoctor.convert_file 'tabs.adoc', extensions: Asciidoctor::Tabs::Extensions.group, safe: :safe
188
309
  ----
189
310
 
190
311
  == How it Works
data/data/css/tabs.css CHANGED
@@ -35,6 +35,16 @@
35
35
  margin-left: 0.25em;
36
36
  }
37
37
 
38
+ .tabs .tablist li::after {
39
+ content: "";
40
+ display: block;
41
+ height: 1px;
42
+ position: absolute;
43
+ bottom: -1px;
44
+ left: 0;
45
+ right: 0;
46
+ }
47
+
38
48
  .tabs.is-loading .tablist li:not(:first-child),
39
49
  .tabs:not(.is-loading) .tablist li:not(.is-selected) {
40
50
  background-color: #f5f5f5;
@@ -42,15 +52,15 @@
42
52
 
43
53
  .tabs.is-loading .tablist li:first-child::after,
44
54
  .tabs:not(.is-loading) .tablist li.is-selected::after {
45
- background-color: inherit;
46
- content: "";
47
- display: block;
48
- height: 3px; /* Chrome doesn't always paint the line accurately, so add a little extra */
49
- position: absolute;
50
- bottom: -1.5px;
51
- left: 0;
52
- right: 0;
55
+ background-color: #fff;
56
+ }
57
+
58
+ /*
59
+ .tabs:not(.is-loading) .tablist li,
60
+ .tabs:not(.is-loading) .tablist li::after {
61
+ transition: background-color 200ms ease-in-out;
53
62
  }
63
+ */
54
64
 
55
65
  .tablist > ul p {
56
66
  line-height: inherit;
data/data/js/tabs.js CHANGED
@@ -12,30 +12,31 @@
12
12
  var syncIds = tabs.classList.contains('is-sync') ? {} : undefined
13
13
  var tablist = tabs.querySelector('.tablist ul')
14
14
  tablist.setAttribute('role', 'tablist')
15
- var initial
15
+ var start
16
16
  forEach.call(tablist.querySelectorAll('li'), function (tab, idx) {
17
- tab.setAttribute('role', (tab.className = 'tab')) // NOTE converter may not have set class on li
17
+ tab.tabIndex = -1
18
+ tab.setAttribute('role', tab.classList.add('tab') || 'tab')
18
19
  var id, anchor, syncId
19
- if (!(id = tab.id)) {
20
- if (!(anchor = tab.querySelector('a[id]'))) return // invalid state
21
- tab.id = id = anchor.parentNode.removeChild(anchor).id
20
+ if (!(id = tab.id) && (anchor = tab.querySelector('a[id]'))) {
21
+ id = tab.id = anchor.parentNode.removeChild(anchor).id
22
22
  }
23
- var panel = tabs.querySelector('.tabpanel[aria-labelledby~="' + id + '"]')
24
- if (!panel) return // invalid state
25
- tab.tabIndex = -1
23
+ var panel = id && tabs.querySelector('.tabpanel[aria-labelledby~="' + id + '"]')
24
+ if (!panel) return idx ? undefined : toggleSelected(tab, true) // invalid state
26
25
  syncIds && (((syncId = tab.textContent.trim()) in syncIds) ? (syncId = undefined) : true) &&
27
26
  (syncIds[(tab.dataset.syncId = syncId)] = tab)
28
- idx || (initial = { tab: tab, panel: panel }) && syncIds ? toggleHidden(panel, true) : toggleSelected(tab, true)
27
+ idx || (syncIds && (start = { tab: tab, panel: panel })) ? toggleHidden(panel, true) : toggleSelected(tab, true)
29
28
  tab.setAttribute('aria-controls', panel.id)
30
29
  panel.setAttribute('role', 'tabpanel')
31
- forEach.call(panel.querySelectorAll('table.tableblock'), function (table) {
32
- var container = Object.assign(document.createElement('div'), { className: 'tablecontainer' })
33
- table.parentNode.insertBefore(container, table).appendChild(table)
34
- })
35
30
  var onClick = syncId === undefined ? activateTab : activateTabSync
36
31
  tab.addEventListener('click', onClick.bind({ tabs: tabs, tab: tab, panel: panel }))
37
32
  })
38
- if (syncIds && initial) {
33
+ if (!tabs.closest('.tabpanel')) {
34
+ forEach.call(tabs.querySelectorAll('.tabpanel table.tableblock'), function (table) {
35
+ var container = Object.assign(document.createElement('div'), { className: 'tablecontainer' })
36
+ table.parentNode.insertBefore(container, table).appendChild(table)
37
+ })
38
+ }
39
+ if (start) {
39
40
  var syncGroupId
40
41
  for (var i = 0, lst = tabs.classList, len = lst.length, className; i !== len; i++) {
41
42
  if (!(className = lst.item(i)).startsWith('data-sync-group-id=')) continue
@@ -46,8 +47,8 @@
46
47
  var preferredSyncId = 'syncStorageKey' in config &&
47
48
  window[(config.syncStorageScope || 'local') + 'Storage'].getItem(config.syncStorageKey + '-' + syncGroupId)
48
49
  var tab = preferredSyncId && syncIds[preferredSyncId]
49
- tab && Object.assign(initial, { tab: tab, panel: document.getElementById(tab.getAttribute('aria-controls')) })
50
- toggleSelected(initial.tab, true) || toggleHidden(initial.panel, false)
50
+ tab && Object.assign(start, { tab: tab, panel: document.getElementById(tab.getAttribute('aria-controls')) })
51
+ toggleSelected(start.tab, true) || toggleHidden(start.panel, false)
51
52
  }
52
53
  })
53
54
  onHashChange()
@@ -60,10 +61,10 @@
60
61
  var tab = this.tab
61
62
  var tabs = this.tabs || (this.tabs = tab.closest('.tabs'))
62
63
  var panel = this.panel || (this.panel = document.getElementById(tab.getAttribute('aria-controls')))
63
- forEach.call(tabs.querySelectorAll('.tablist .tab'), function (el) {
64
+ querySelectorWithSiblings(tabs, '.tablist .tab', 'tab').forEach(function (el) {
64
65
  toggleSelected(el, el === tab)
65
66
  })
66
- forEach.call(tabs.querySelectorAll('.tabpanel'), function (el) {
67
+ querySelectorWithSiblings(tabs, '.tabpanel', 'tabpanel').forEach(function (el) {
67
68
  toggleHidden(el, el !== panel)
68
69
  })
69
70
  if (!this.isSync && 'syncStorageKey' in config && 'syncGroupId' in tabs.dataset) {
@@ -84,7 +85,7 @@
84
85
  var initialY = thisTabs.getBoundingClientRect().y
85
86
  forEach.call(document.querySelectorAll('.tabs'), function (tabs) {
86
87
  if (tabs === thisTabs || tabs.dataset.syncGroupId !== thisTabs.dataset.syncGroupId) return
87
- forEach.call(tabs.querySelectorAll('.tablist .tab'), function (tab) {
88
+ querySelectorWithSiblings(tabs, '.tablist .tab', 'tab').forEach(function (tab) {
88
89
  if (tab.dataset.syncId === thisTab.dataset.syncId) activateTab.call({ tabs: tabs, tab: tab, isSync: true })
89
90
  })
90
91
  })
@@ -92,6 +93,14 @@
92
93
  if (shiftedBy && (shiftedBy = Math.round(shiftedBy))) window.scrollBy({ top: shiftedBy, behavior: 'instant' })
93
94
  }
94
95
 
96
+ function querySelectorWithSiblings (scope, selector, siblingClass) {
97
+ var el = scope.querySelector(selector)
98
+ if (!el) return []
99
+ var result = [el]
100
+ while ((el = el.nextElementSibling) && el.classList.contains(siblingClass)) result.push(el)
101
+ return result
102
+ }
103
+
95
104
  function toggleClassOnEach (elements, className, method) {
96
105
  forEach.call(elements, function (el) {
97
106
  el.classList[method](className)
@@ -7,16 +7,18 @@ module Asciidoctor
7
7
  on_context :example
8
8
 
9
9
  def process parent, reader, attrs
10
+ tabs_number = (doc = parent.document).counter 'tabs-number'
10
11
  block = create_block parent, attrs['cloaked-context'], nil, attrs, content_model: :compound
11
12
  children = (parse_content block, reader).blocks
12
- return block unless children.size == 1 && (seed_tabs = children[0]).context == :dlist && seed_tabs.items?
13
- unless (doc = parent.document).attr? 'filetype', 'html'
13
+ unless children.size == 1 && (seed_tabs = children[0]).context == :dlist && seed_tabs.items?
14
+ return (reset_counter doc, 'tabs-number', (tabs_number - 1)) || block
15
+ end
16
+ unless doc.attr? 'filetype', 'html'
14
17
  (id = attrs['id']) && (doc.register :refs, [(seed_tabs.id = id), seed_tabs]) unless seed_tabs.id
15
18
  (reftext = attrs['reftext']) && (seed_tabs.set_attr 'reftext', reftext) unless seed_tabs.reftext?
16
19
  parent << seed_tabs
17
- return
20
+ return reset_counter doc, 'tabs-number', (tabs_number - 1)
18
21
  end
19
- tabs_number = doc.counter 'tabs-number'
20
22
  tabs_id = attrs['id'] || (generate_id %(tabs #{tabs_number}), doc)
21
23
  tabs_role = 'tabs' + (!(block.option? 'nosync') && ((block.option? 'sync') || (doc.option? 'tabs-sync')) ?
22
24
  ((gid = attrs['sync-group-id']) ? %( is-sync data-sync-group-id=#{gid.gsub ' ', ?\u00a0}) : ' is-sync') : '')
@@ -39,7 +41,8 @@ module Asciidoctor
39
41
  tab_blocks = content.text? ?
40
42
  [(create_paragraph parent, (content.instance_variable_get :@text), nil, subs: :normal)] : []
41
43
  if content.blocks?
42
- if (block0 = (blocks = content.blocks)[0]).context == :open && blocks.size == 1 && block0.blocks?
44
+ if (block0 = (blocks = content.blocks)[0]).context == :open && block0.style == 'open' &&
45
+ blocks.size == 1 && !(block0.id || block0.title? || block0.attributes.keys.any? {|k| k != 'style' })
43
46
  blocks = block0.blocks
44
47
  end
45
48
  tab_blocks.push(*blocks)
@@ -81,6 +84,12 @@ module Asciidoctor
81
84
  converter.instance_variable_set :@list_item_supports_id, (output.include? ' id="name"')
82
85
  end
83
86
  end
87
+
88
+ def reset_counter doc, name, val
89
+ doc.counters[name] = val
90
+ doc.set_attr name, val unless doc.attribute_locked? name
91
+ nil
92
+ end
84
93
  end
85
94
  end
86
95
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Asciidoctor
4
4
  module Tabs
5
- VERSION = '1.0.0.beta.3'
5
+ VERSION = '1.0.0.beta.5'
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: asciidoctor-tabs
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0.beta.3
4
+ version: 1.0.0.beta.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dan Allen
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-02-01 00:00:00.000000000 Z
11
+ date: 2023-05-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: asciidoctor