asciidoctor-dita-topic 1.1.2 → 1.1.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/dita-topic.rb +34 -22
  3. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 172e330842b5b5f390c287fd0adfe4e51a055c669145c09a0a4b07d7a85057ba
4
- data.tar.gz: 3e76bd3a36ed2954827156500d393ac982506862395fbceb30b84c075db95e72
3
+ metadata.gz: c8500891ad21dc6be419992bbb3ce0746bfb3c5e96f4cdb5c0faea28cd00fe59
4
+ data.tar.gz: df920f7ae7d468b8e981a05d1a16c932e2fcd31d9e22d22b5e7406cef880ca01
5
5
  SHA512:
6
- metadata.gz: 4f5cc15df1b03d9198a87d9996859b067a957928375a6469c8901c3850d76dc0f06f5f3e9e3ff9eb86a8f369c55bf9d7c9a9074e2937ff5798b7b9157bb4a428
7
- data.tar.gz: 2986bb1e278b253df0d1d0768d695e8799191253f3527c58f8ef027159ce237e7a09e517dfa78d6cc1043d0c437ff09866848c6ddbe8db7cbb7781806c342252
6
+ metadata.gz: d788246489a2ce5c11b1f293401d70efbc373c4561e266a497bee45a7de82fc20cae10a3cf3dcded6635e1054279a51250405d36fb6bd219c7602636d6ed2aa9
7
+ data.tar.gz: 9d4a9e9638f983baf60e401d3d4477c29036d028a12c751acd9e6e88527bcb97238838cccd9234cb750b560b76b23693bfa50726b483c853355eedaee0bf5f52
data/lib/dita-topic.rb CHANGED
@@ -29,6 +29,8 @@ class DitaTopic < Asciidoctor::Converter::Base
29
29
  NAME = 'dita-topic'
30
30
  register_for NAME
31
31
 
32
+ require 'securerandom'
33
+
32
34
  def initialize *args
33
35
  super
34
36
  outfilesuffix '.dita'
@@ -70,7 +72,7 @@ class DitaTopic < Asciidoctor::Converter::Base
70
72
  # Open the document:
71
73
  result = ["<?xml version='1.0' encoding='utf-8' ?>"]
72
74
  result << %(<!DOCTYPE topic PUBLIC "-//OASIS//DTD DITA Topic//EN" "topic.dtd">)
73
- result << %(<topic#{compose_id (node.id or node.attributes['docname'])}#{outputclass}>)
75
+ result << %(<topic#{compose_id (node.id or node.attributes['docname'] or 'topic-'+SecureRandom.uuid)}#{outputclass}>)
74
76
  result << %(<title>#{node.doctitle}</title>)
75
77
 
76
78
  # Check if the author line is enabled and defined:
@@ -142,42 +144,36 @@ class DitaTopic < Asciidoctor::Converter::Base
142
144
  # Reset the counter:
143
145
  number = 0
144
146
 
145
- # Open the table:
146
- result = ['<table outputclass="callout-list">']
147
- result << %(<tgroup cols="2">)
148
- result << %(<colspec colwidth="15*" />)
149
- result << %(<colspec colwidth="85*" />)
150
- result << %(<tbody>)
147
+ # Open the definition list:
148
+ result = ['<dl outputclass="callout-list">']
151
149
 
152
150
  # Process individual list items:
153
151
  node.items.each do |item|
154
152
  # Increment the counter:
155
153
  number += 1
156
154
 
157
- # Open the table row:
158
- result << %(<row>)
155
+ # Open the definition entry:
156
+ result << %(<dlentry>)
159
157
 
160
158
  # Compose the callout number:
161
- result << %(<entry>#{compose_circled_number number}</entry>)
159
+ result << %(<dt>#{compose_circled_number number}</dt>)
162
160
 
163
161
  # Check if description contains multiple block elements:
164
162
  if item.blocks
165
- result << %(<entry>)
166
- result << %(<p>#{item.text}</p>)
163
+ result << %(<dd>)
164
+ result << item.text
167
165
  result << item.content
168
- result << %(</entry>)
166
+ result << %(</dd>)
169
167
  else
170
168
  result << %(<entry>#{item.text}</entry>)
171
169
  end
172
170
 
173
- # Close the row:
174
- result << %(</row>)
171
+ # Close the definition entry:
172
+ result << %(</dlentry>)
175
173
  end
176
174
 
177
- # Close the table:
178
- result << %(</tbody>)
179
- result << %(</tgroup>)
180
- result << %(</table>)
175
+ # Close the definition list:
176
+ result << %(</dl>)
181
177
 
182
178
  # Return the XML output:
183
179
  result.join LF
@@ -248,12 +244,16 @@ class DitaTopic < Asciidoctor::Converter::Base
248
244
  %(<p outputclass="title sect#{node.level}"><b>#{node.title}</b></p>)
249
245
  end
250
246
 
251
- def convert_image(node)
247
+ def convert_image node
252
248
  # Check if additional attributes are specified:
253
249
  width = (node.attr? 'width') ? %( width="#{node.attr 'width'}") : ''
254
250
  height = (node.attr? 'height') ? %( height="#{node.attr 'height'}") : ''
255
251
  scale = (node.attr? 'scale') ? %( scale="#{(node.attr 'scale').tr('%', '')}") : ''
256
252
 
253
+ # Exclude width and height attributes with percentage values:
254
+ width = '' if width.include? '%'
255
+ height = '' if height.include? '%'
256
+
257
257
  # Check if the image has a title specified:
258
258
  if node.title?
259
259
  <<~EOF.chomp
@@ -355,9 +355,17 @@ class DitaTopic < Asciidoctor::Converter::Base
355
355
  compose_circled_number node.text.to_i
356
356
  end
357
357
 
358
- # FIXME: Add support for footnoteref equivalent.
359
358
  def convert_inline_footnote node
360
- %(<fn>#{node.text}</fn>)
359
+ # Check whether the footnote is a definition or a reference:
360
+ if node.type == :xref
361
+ %(<xref href="#./#{node.target}" type="fn" />)
362
+ elsif node.id
363
+ # Define the footnote and immediately reference it to match AsdciiDoc
364
+ # behavior:
365
+ %(<fn#{compose_id node.id}>#{node.text}</fn><xref href="#./#{node.id}" type="fn" />)
366
+ else
367
+ %(<fn>#{node.text}</fn>)
368
+ end
361
369
  end
362
370
 
363
371
  def convert_inline_image node
@@ -365,6 +373,10 @@ class DitaTopic < Asciidoctor::Converter::Base
365
373
  width = (node.attr? 'width') ? %( width="#{node.attr 'width'}") : ''
366
374
  height = (node.attr? 'height') ? %( height="#{node.attr 'height'}") : ''
367
375
 
376
+ # Exclude width and height attributes with percentage values:
377
+ width = '' if width.include? '%'
378
+ height = '' if height.include? '%'
379
+
368
380
  # Return the XML output:
369
381
  %(<image href="#{node.image_uri node.target}"#{width}#{height} placement="inline"><alt>#{node.alt}</alt></image>)
370
382
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: asciidoctor-dita-topic
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.2
4
+ version: 1.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jaromir Hradilek
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2025-03-23 00:00:00.000000000 Z
11
+ date: 2025-04-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: asciidoctor