asciidoctor-dita-topic 1.0.6 → 1.0.8

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/dita-topic.rb +31 -47
  3. metadata +3 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: af4723a781b24e522548c852bd873f9db6547c0bc546365b5cabdbfdd296b2f9
4
- data.tar.gz: 4485c9cdc6f4232dbef55d5e837a9cd9206a716caac657302591b00129d44515
3
+ metadata.gz: 073b164893413640198b0938df78f0b180a4a25366a34bee47cf85585efddd51
4
+ data.tar.gz: 75b381d82f68f838a237b666fe8a38929dbc99101f0024086888d83a4c59471a
5
5
  SHA512:
6
- metadata.gz: 95e315d78112be6948c464167e76318e5211e9b6f0e16822b82ec2b4bfa419b0900ac11dc9108570a341485106c2e68ea332b41a37505e8cdcb08d59f27a40b0
7
- data.tar.gz: 5cd3c94ff7b4f25684b334dfc5282aa7452ba07060136589bdbb373d31e3c1147e1439783668336e7c78aa2761959f4149a1df22ed3c84fcf702b145811dfda7
6
+ metadata.gz: f1b4cf1080f6ab776de1d62c122f89c190f68d03836bd3a41e2612c4b673ab97e2947abab161f9f4c1f976acddc9a41acf9ffcbdbfd7308a4c0e1bc64da87e17
7
+ data.tar.gz: 9acb585946816133087779410d66279ec4567118a3ed14a9ec318c353a647e50dcb5ee46adf835bfa9a94a511b0a8ec772e49fe224bac042946021ad902c5902
data/lib/dita-topic.rb CHANGED
@@ -47,28 +47,19 @@ class DitaTopic < Asciidoctor::Converter::Base
47
47
  # Check if callouts are enabled:
48
48
  @callouts_allowed = false if (node.attr 'dita-topic-callouts') == 'off'
49
49
 
50
- # Check if a specific topic type is provided:
51
- if (value = node.attr 'dita-topic-type') =~ /^(concept|reference|task)$/
52
- type = value
53
- body = (type == 'task') ? 'taskbody' : %(#{type[0,3]}body)
54
- else
55
- type = 'topic'
56
- body = 'body'
57
- end
58
-
59
50
  # Check if the modular documentation content type is specified:
60
51
  outputclass = (node.attr? '_mod-docs-content-type') ? %( outputclass="#{(node.attr '_mod-docs-content-type').downcase}") : ''
61
52
 
62
53
  # Return the XML output:
63
54
  <<~EOF.chomp
64
55
  <?xml version='1.0' encoding='utf-8' ?>
65
- <!DOCTYPE #{type} PUBLIC "-//OASIS//DTD DITA #{type.capitalize}//EN" "#{type}.dtd">
66
- <#{type}#{compose_id (node.id or node.attributes['docname'])}#{outputclass}>
56
+ <!DOCTYPE topic PUBLIC "-//OASIS//DTD DITA Topic//EN" "topic.dtd">
57
+ <topic#{compose_id (node.id or node.attributes['docname'])}#{outputclass}>
67
58
  <title>#{node.doctitle}</title>
68
- <#{body}>
59
+ <body>
69
60
  #{node.content}
70
- </#{body}>
71
- </#{type}>
61
+ </body>
62
+ </topic>
72
63
  EOF
73
64
  end
74
65
 
@@ -109,8 +100,8 @@ class DitaTopic < Asciidoctor::Converter::Base
109
100
  # Open the table:
110
101
  result = ['<table outputclass="callout-list">']
111
102
  result << %(<tgroup cols="2">)
112
- result << %(<colspec colwidth="#{node.attr 'labelwidth', 15}*" />)
113
- result << %(<colspec colwidth="#{node.attr 'itemwidth', 85}*" />)
103
+ result << %(<colspec colwidth="15*" />)
104
+ result << %(<colspec colwidth="85*" />)
114
105
  result << %(<tbody>)
115
106
 
116
107
  # Process individual list items:
@@ -186,7 +177,7 @@ class DitaTopic < Asciidoctor::Converter::Base
186
177
  result << '</dl>'
187
178
 
188
179
  # Return the XML output:
189
- add_block_title (result.join LF), node.title, 'dlist'
180
+ add_block_title (result.join LF), node.title
190
181
  end
191
182
 
192
183
  def convert_example node
@@ -379,28 +370,18 @@ class DitaTopic < Asciidoctor::Converter::Base
379
370
  end
380
371
 
381
372
  def convert_listing node
382
- # Check the listing style:
383
- if node.style == 'source'
384
- # Check whether the source language is defined:
385
- language = (node.attributes.key? 'language') ? %( outputclass="language-#{node.attributes['language']}") : ''
386
-
387
- # Compose the XML output:
388
- result = <<~EOF.chomp
389
- <codeblock#{language}>
390
- #{node.content}
391
- </codeblock>
392
- EOF
393
- else
394
- # Compose the XML output:
395
- result = <<~EOF.chomp
396
- <screen>
397
- #{node.content}
398
- </screen>
399
- EOF
400
- end
373
+ # Check whether the source language is defined:
374
+ language = (node.attributes.key? 'language') ? %( outputclass="language-#{node.attributes['language']}") : ''
375
+
376
+ # Compose the XML output:
377
+ result = <<~EOF.chomp
378
+ <codeblock#{language}>
379
+ #{node.content}
380
+ </codeblock>
381
+ EOF
401
382
 
402
383
  # Return the XML output:
403
- add_block_title result, node.title, 'listing'
384
+ add_block_title result, node.title
404
385
  end
405
386
 
406
387
  def convert_literal node
@@ -412,7 +393,7 @@ class DitaTopic < Asciidoctor::Converter::Base
412
393
  EOF
413
394
 
414
395
  # Return the XML output:
415
- add_block_title result, node.title, 'literal'
396
+ add_block_title result, node.title
416
397
  end
417
398
 
418
399
  def convert_olist node
@@ -436,7 +417,7 @@ class DitaTopic < Asciidoctor::Converter::Base
436
417
  result << '</ol>'
437
418
 
438
419
  # Return the XML output:
439
- add_block_title (result.join LF), node.title, 'olist'
420
+ add_block_title (result.join LF), node.title
440
421
  end
441
422
 
442
423
  # FIXME: This is not the top priority.
@@ -455,7 +436,7 @@ class DitaTopic < Asciidoctor::Converter::Base
455
436
  end
456
437
 
457
438
  def convert_paragraph node
458
- add_block_title %(<p>#{node.content}</p>), node.title, 'paragraph'
439
+ add_block_title %(<p>#{node.content}</p>), node.title
459
440
  end
460
441
 
461
442
  def convert_preamble node
@@ -652,7 +633,7 @@ class DitaTopic < Asciidoctor::Converter::Base
652
633
  result << '</ul>'
653
634
 
654
635
  # Returned the XML output:
655
- add_block_title (result.join LF), node.title, 'ulist'
636
+ add_block_title (result.join LF), node.title
656
637
  end
657
638
 
658
639
  def convert_verse node
@@ -704,12 +685,17 @@ class DitaTopic < Asciidoctor::Converter::Base
704
685
  result << '</ol>'
705
686
 
706
687
  # Return the XML output:
707
- add_block_title (result.join LF), node.title, 'qanda'
688
+ add_block_title (result.join LF), node.title
708
689
  end
709
690
 
710
691
  def compose_horizontal_dlist node
711
692
  # Open the table:
712
693
  result = ['<table outputclass="horizontal-dlist">']
694
+
695
+ # Check if the title is specified:
696
+ result << %(<title>#{node.title}</title>) if node.title?
697
+
698
+ # Define the table properties and open the tgroup:
713
699
  result << %(<tgroup cols="2">)
714
700
  result << %(<colspec colwidth="#{node.attr 'labelwidth', 15}*" />)
715
701
  result << %(<colspec colwidth="#{node.attr 'itemwidth', 85}*" />)
@@ -755,7 +741,7 @@ class DitaTopic < Asciidoctor::Converter::Base
755
741
  result << %(</table>)
756
742
 
757
743
  # Return the XML output:
758
- add_block_title (result.join LF), node.title, 'horizontal'
744
+ result.join LF
759
745
  end
760
746
 
761
747
  # Method aliases
@@ -766,10 +752,10 @@ class DitaTopic < Asciidoctor::Converter::Base
766
752
 
767
753
  # Helper methods
768
754
 
769
- def add_block_title content, title, context='wrapper'
755
+ def add_block_title content, title
770
756
  # NOTE: Unlike AsciiDoc, DITA does not support titles assigned to
771
757
  # certain block elements. As a workaround, I decided to use a paragraph
772
- # with the outputclass attribute and wrap the block in a div element.
758
+ # with the outputclass attribute.
773
759
 
774
760
  # Check if the title is defined:
775
761
  return content unless title
@@ -782,10 +768,8 @@ class DitaTopic < Asciidoctor::Converter::Base
782
768
 
783
769
  # Return the XML output:
784
770
  <<~EOF.chomp
785
- <div outputclass="#{context}">
786
771
  <p outputclass="title"><b>#{title}</b></p>
787
772
  #{content}
788
- </div>
789
773
  EOF
790
774
  end
791
775
 
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.0.6
4
+ version: 1.0.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jaromir Hradilek
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-08-05 00:00:00.000000000 Z
11
+ date: 2024-11-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: asciidoctor
@@ -102,7 +102,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
102
102
  - !ruby/object:Gem::Version
103
103
  version: '0'
104
104
  requirements: []
105
- rubygems_version: 3.5.11
105
+ rubygems_version: 3.5.16
106
106
  signing_key:
107
107
  specification_version: 4
108
108
  summary: A custom AsciiDoc converter that generates individual DITA topics