kramdown-asciidoc 2.0.1 → 2.1.1

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e2f299ca0d156093eca0b0bf206f13bbedb23604e4f6a237b2b5aa16faa76eb0
4
- data.tar.gz: 7bc8f03b29ecc1986f25c53858a3f4920b3ff3ba8a1d4b3313cee73c4be0dcaa
3
+ metadata.gz: 4b026dc30505b178f8854dce27a0b5d9972a6ce80d81e0fdde7eaf8c7a9792d5
4
+ data.tar.gz: ae96a96821d9e9e94fc75f952284e748fb2018debbd6097eb066e8b1666eb1eb
5
5
  SHA512:
6
- metadata.gz: 3d67ddef393d8155a0362ca7c8f0a997cf16f232f1293c13c8cb49ffa08009353224fa9703a25a4f1ab3b3b3dc4b048b56721b15d344695ec025ab3c8223efbe
7
- data.tar.gz: 3ad990caafd8c8dd4eb0854e1af5095be820b735feff16d28aeac09b98967aabbefc43d6ecae35bda318d8cfdf65a691ea1e34e6b8a060337b17086b4a58e61e
6
+ metadata.gz: b97537e4d267473a0ae9cb8cfab8e89ad01e2a8811f42d9b95bfe06299fec0a1c0fe48979c630ab1b93b380b216a217af1a92b42c272b272e378e6e13e00cffb
7
+ data.tar.gz: d17563c0d85bbced68ef54fa6ed267a00c62de88ac912a38f8518d797c385a5cb707530a681ccb5699a0606d9139b029fb4ab5ded35ecf04a8f452fcc85e1c0e
data/CHANGELOG.adoc CHANGED
@@ -5,6 +5,39 @@
5
5
  This document provides a high-level view of the changes to {project-name} by release.
6
6
  For a detailed view of what has changed, refer to the {uri-repo}/commits/master[commit history] on GitHub.
7
7
 
8
+ == 2.1.1 (2025-09-04) - @mojavelinux
9
+
10
+ === Fixed
11
+
12
+ * Convert language tag on source block to lowercase (#106)
13
+ * Turn off system-dependent newline conversion when writing output file
14
+ * Remove direct runtime dependency on rexml as the latest version is already pulled in by kramdown (#122)
15
+
16
+ === Details
17
+
18
+ {url-repo}/releases/tag/v2.1.1[git tag] | {url-repo}/compare/v2.1.0\...v2.1.1[full diff]
19
+
20
+ == 2.1.0 (2022-07-04) - @mojavelinux
21
+
22
+ === Added
23
+
24
+ * Add support for multi-paragraph admonitions (#72)
25
+ * Add support for GFM-style admonitions (#103)
26
+ * Convert checkbox at start of items in a checklist (#94)
27
+ * Allow diagram languages to be specified and convert matching fenced code blocks to diagram literal blocks (#76)
28
+
29
+ === Fixed
30
+
31
+ * Separate adjacent delimited literal blocks
32
+
33
+ === Changed
34
+
35
+ * Upgrade kramdown to 2.4.x
36
+
37
+ === Details
38
+
39
+ {url-repo}/releases/tag/v2.1.0[git tag] | {url-repo}/compare/v2.0.1\...v2.1.0[full diff]
40
+
8
41
  == 2.0.1 (2022-06-29) - @mojavelinux
9
42
 
10
43
  === Fixed
@@ -41,7 +74,7 @@ For a detailed view of what has changed, refer to the {uri-repo}/commits/master[
41
74
 
42
75
  * Upgrade kramdown to 2.3.x and declare kramdown-parser-gfm as runtime dependency (#85)
43
76
  * Don't add source style to listing block when language is specified
44
- * Switch CI to GitHub Actions
77
+ * Switch CI to GitHub Actions (including Windows build)
45
78
  * Run test suite in CI environment on Windows and macOS
46
79
  * Apply style rules to source code
47
80
 
data/Gemfile CHANGED
@@ -4,20 +4,21 @@ source 'https://rubygems.org'
4
4
 
5
5
  gemspec
6
6
 
7
- without = (Bundler.settings['WITHOUT'] || '').split ':'
7
+ gem 'rexml', '~> 3.2.0' if (Gem::Version.new RUBY_VERSION) < (Gem::Version.new '2.5.0')
8
+
9
+ group :coverage do
10
+ gem 'deep-cover-core', '~> 1.1.0', require: false
11
+ gem 'simplecov', '~> 0.21.0', require: false
12
+ end unless (Gem::Version.new RUBY_VERSION) < (Gem::Version.new '2.5.0')
8
13
 
9
14
  group :docs do
10
15
  gem 'asciidoctor', require: false
11
16
  gem 'yard', require: false
12
- end unless without.include? 'docs'
17
+ end
13
18
 
14
19
  group :lint do
15
- gem 'rubocop', '~> 1.28.0', require: false
20
+ gem 'json', '~> 2.6.0', require: false
21
+ gem 'rubocop', '~> 1.36.0', require: false
16
22
  gem 'rubocop-rake', '~> 0.6.0', require: false
17
- gem 'rubocop-rspec', '~> 2.10.0', require: false
18
- end unless without.include? 'lint'
19
-
20
- group :coverage do
21
- gem 'deep-cover-core', '~> 1.1.0', require: false
22
- gem 'simplecov', '~> 0.21.0', require: false
23
- end unless without.include? 'coverage'
23
+ gem 'rubocop-rspec', '~> 2.13.0', require: false
24
+ end unless (Gem::Version.new RUBY_VERSION) < (Gem::Version.new '2.6.0')
data/README.adoc CHANGED
@@ -1,6 +1,6 @@
1
1
  = {project-name} (Markdown to AsciiDoc)
2
2
  Dan Allen <https://github.com/mojavelinux>
3
- v2.0.1, 2022-06-29
3
+ v2.1.1, 2025-09-04
4
4
  // Aliases:
5
5
  :project-name: Kramdown AsciiDoc
6
6
  :project-handle: kramdown-asciidoc
@@ -25,7 +25,7 @@ endif::[]
25
25
  :url-kramdown: https://kramdown.gettalong.org
26
26
  :url-rvm: https://rvm.io
27
27
  :url-rvm-install: https://rvm.io/rvm/install
28
- :url-api-docs: https://www.rubydoc.info/github/asciidoctor/kramdown-asciidoc/master
28
+ :url-api-docs: https://www.rubydoc.info/github/asciidoctor/kramdown-asciidoc
29
29
  :url-gem: https://rubygems.org/gems/kramdown-asciidoc
30
30
  :img-url-gem: https://img.shields.io/gem/v/kramdown-asciidoc.svg?label=gem
31
31
 
@@ -31,8 +31,7 @@ Gem::Specification.new do |s|
31
31
 
32
32
  s.require_paths = ['lib']
33
33
 
34
- s.add_runtime_dependency 'kramdown', '~> 2.3.0'
35
- s.add_runtime_dependency 'rexml', '~> 3.2.0'
34
+ s.add_runtime_dependency 'kramdown', '~> 2.4.0'
36
35
  s.add_runtime_dependency 'kramdown-parser-gfm', '~> 1.1.0'
37
36
 
38
37
  s.add_development_dependency 'rake', '~> 13.0.0'
@@ -63,7 +63,7 @@ module AsciiDoc
63
63
  if (to = opts[:to])
64
64
  if ::Pathname === to || (!(to.respond_to? :write) && (to = ::Pathname.new to.to_s))
65
65
  to.dirname.mkpath
66
- to.write asciidoc, encoding: UTF_8
66
+ to.write asciidoc, encoding: UTF_8, newline: :universal
67
67
  else
68
68
  to.write asciidoc
69
69
  end
@@ -14,12 +14,12 @@ module AsciiDoc
14
14
 
15
15
  opt_parser = ::OptionParser.new do |opts|
16
16
  opts.program_name = 'kramdoc'
17
- opts.banner = <<~EOS
17
+ opts.banner = <<~END
18
18
  Usage: #{opts.program_name} [OPTION]... FILE
19
19
 
20
20
  Converts Markdown to AsciiDoc.
21
21
 
22
- EOS
22
+ END
23
23
 
24
24
  opts.on '-o FILE', '--output=FILE', 'Set the output filename or stream' do |file|
25
25
  options[:output_file] = file
@@ -35,6 +35,10 @@ module AsciiDoc
35
35
  options[:attributes][key] = val
36
36
  end
37
37
 
38
+ opts.on '--diagram-languages=VALUES', 'Specify source languages to treat as diagrams (default: plantuml,mermaid)' do |names|
39
+ options[:diagram_languages] = names.split ','
40
+ end
41
+
38
42
  opts.on '--wrap=preserve|none|ventilate', [:none, :preserve, :ventilate], 'Set how lines are wrapped in the AsciiDoc document (default: preserve)' do |wrap|
39
43
  options[:wrap] = wrap
40
44
  end
@@ -92,6 +92,7 @@ module AsciiDoc
92
92
  @ids_seen = {}
93
93
  @footnote_ids = ::Set.new
94
94
  @auto_links = opts.fetch :auto_links, true
95
+ @diagram_languages = opts[:diagram_languages] || %w(plantuml mermaid)
95
96
  @heading_offset = opts[:heading_offset] || 0
96
97
  @imagesdir = opts[:imagesdir] || @attributes['imagesdir']
97
98
  @wrap = opts[:wrap] || :preserve
@@ -185,7 +186,8 @@ module AsciiDoc
185
186
  elsif (child_i.type == :strong || child_i.type == :em) &&
186
187
  (marker_el = child_i.children[0]) && ((marker = ADMON_FORMATTED_MARKERS[marker_el.value]) ||
187
188
  ((marker = ADMON_LABELS[marker_el.value]) && (child_ii = to_element children[1]).type == :text &&
188
- ((child_ii_text = child_ii.value).start_with? ': ')))
189
+ (((child_ii_text = child_ii.value).start_with? ': ') ||
190
+ (opts[:parent].type == :blockquote && (child_ii_text.start_with? ?\n)))))
189
191
  children = children.drop 1
190
192
  children[0] = clone child_ii, value: (child_ii_text.slice 1, child_ii_text.length) if child_ii
191
193
  # Q: should we only rstrip?
@@ -203,8 +205,16 @@ module AsciiDoc
203
205
  (writer = opts[:writer]).start_block
204
206
  traverse el, (opts.merge writer: (block_writer = Writer.new), blockquote_depth: (depth = opts[:blockquote_depth] || 0) + 1)
205
207
  contents = block_writer.body
206
- if contents[0].start_with?(*ADMON_MARKERS_ASCIIDOC) && !(contents.include? '')
207
- writer.add_lines contents
208
+ if contents[0].start_with?(*ADMON_MARKERS_ASCIIDOC)
209
+ if contents.include? ''
210
+ style, _, contents[0] = contents[0].partition ': '
211
+ writer.add_line %([#{style}])
212
+ writer.start_delimited_block '='
213
+ writer.add_lines contents
214
+ writer.end_delimited_block
215
+ else
216
+ writer.add_lines contents
217
+ end
208
218
  else
209
219
  if contents.size > 1 && ::String === (last_line = contents[-1]) && (last_line.start_with? '-- ')
210
220
  attribution = (attribution_line = contents.pop).slice 3, attribution_line.length
@@ -224,7 +234,8 @@ module AsciiDoc
224
234
  def convert_codeblock el, opts
225
235
  writer = opts[:writer]
226
236
  # NOTE hack to down-convert level-5 heading to block title
227
- if (current_line = writer.current_line) && (!(current_line.start_with? '.') || (current_line.start_with? '. '))
237
+ if (current_line = writer.current_line) &&
238
+ ((current_line.start_with? '.') ? (current_line == '....' || (current_line.start_with? '. ')) : true)
228
239
  writer.start_block
229
240
  end
230
241
  lines = el.value.rstrip.split LF
@@ -232,14 +243,21 @@ module AsciiDoc
232
243
  if (lang = el.attr['class'])
233
244
  # NOTE Kramdown always prefixes class with language-
234
245
  # TODO remap lang if requested
235
- writer.add_line %([,#{lang = lang.slice 9, lang.length}])
246
+ lang = (lang.slice 9, lang.length).downcase
247
+ if @diagram_languages.include? lang
248
+ diagram = true
249
+ writer.add_line %([#{lang}])
250
+ else
251
+ writer.add_line %([,#{lang}])
252
+ end
236
253
  elsif (prompt = first_line && (first_line.start_with? '$ '))
237
254
  writer.add_line %([,#{lang = 'console'}]) if lines.include? ''
238
255
  end
239
256
  if lang || (el.options[:fenced] && !prompt)
240
- writer.add_line '----'
257
+ delimiter = diagram ? '....' : '----'
258
+ writer.add_line delimiter
241
259
  writer.add_lines lines
242
- writer.add_line '----'
260
+ writer.add_line delimiter
243
261
  elsif !prompt && ((lines.include? '') || (first_line && (ListMarkerRx.match? first_line)))
244
262
  writer.add_line '....'
245
263
  writer.add_lines lines
@@ -322,12 +340,11 @@ module AsciiDoc
322
340
  end
323
341
  primary_lines.unshift %(#{indent > 0 ? ' ' * indent : ''}#{marker * level} #{primary_lines.shift})
324
342
  writer.add_lines primary_lines
325
- unless remaining.empty?
326
- if remaining.find {|n| (type = n.type) == :blank ? nil : ((BLOCK_TYPES.include? type) ? true : break) }
327
- el.options[:compound] = true
328
- end
329
- traverse remaining, (opts.merge parent: el)
343
+ return if remaining.empty?
344
+ if remaining.find {|n| (type = n.type) == :blank ? nil : ((BLOCK_TYPES.include? type) ? true : break) }
345
+ el.options[:compound] = true
330
346
  end
347
+ traverse remaining, (opts.merge parent: el)
331
348
  end
332
349
 
333
350
  def convert_dt el, opts
@@ -353,12 +370,11 @@ module AsciiDoc
353
370
  opts[:writer].add_lines primary_lines
354
371
  end
355
372
  end
356
- unless remaining.empty?
357
- if remaining.find {|n| (type = n.type) == :blank ? nil : ((BLOCK_TYPES.include? type) ? true : break) }
358
- el.options[:compound] = true
359
- end
360
- traverse remaining, (opts.merge parent: el)
373
+ return if remaining.empty?
374
+ if remaining.find {|n| (type = n.type) == :blank ? nil : ((BLOCK_TYPES.include? type) ? true : break) }
375
+ el.options[:compound] = true
361
376
  end
377
+ traverse remaining, (opts.merge parent: el)
362
378
  end
363
379
 
364
380
  def convert_table el, opts
@@ -556,7 +572,7 @@ module AsciiDoc
556
572
  opts[:writer].add_lines ['++++', '<script>', el.children[0].value.strip, '</script>', '++++']
557
573
  return
558
574
  elsif tag == 'div' && (child_i = el.children[0]) && child_i.options[:transparent] && (child_i_i = child_i.children[0])
559
- if child_i_i.value == 'span' && ((role = el.attr['class'].to_s).start_with? 'note') && child_i_i.attr['class'] == 'notetitle'
575
+ if child_i_i.value == 'span' && ((role = el.attr['class'].to_s).start_with? 'note') && child_i_i.attr['class'] == 'notetitle' # rubocop:disable Style/GuardClause
560
576
  marker = ADMON_FORMATTED_MARKERS[(to_element child_i_i.children[0]).value] || 'Note'
561
577
  lines = compose_text (child_i.children.drop 1), parent: child_i, strip: true, split: true, wrap: @wrap
562
578
  lines.unshift %(#{ADMON_TYPE_MAP[marker]}: #{lines.shift})
@@ -585,8 +601,12 @@ module AsciiDoc
585
601
  when 'sub'
586
602
  opts[:writer].append %(~#{contents}~)
587
603
  else
588
- attrs = (attrs = el.attr).empty? ? '' : attrs.map {|k, v| %( #{k}="#{v}") }.join
589
- opts[:writer].append %(+++<#{tag}#{attrs}>+++#{contents}+++</#{tag}>+++)
604
+ if tag == 'input' && el.attr['type'] == 'checkbox' && el.attr['class'] == 'task-list-item-checkbox'
605
+ opts[:writer].append %([#{el.attr['checked'] ? 'x' : ' '}] )
606
+ else
607
+ attrs = (attrs = el.attr).empty? ? '' : attrs.map {|k, v| %( #{k}="#{v}") }.join
608
+ opts[:writer].append %(+++<#{tag}#{attrs}>+++#{contents}+++</#{tag}>+++)
609
+ end
590
610
  end
591
611
  end
592
612
 
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Kramdown
4
4
  module AsciiDoc
5
- VERSION = '2.0.1'
5
+ VERSION = '2.1.1'
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kramdown-asciidoc
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.1
4
+ version: 2.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dan Allen
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-06-29 00:00:00.000000000 Z
11
+ date: 2025-09-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: kramdown
@@ -16,28 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: 2.3.0
19
+ version: 2.4.0
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: 2.3.0
27
- - !ruby/object:Gem::Dependency
28
- name: rexml
29
- requirement: !ruby/object:Gem::Requirement
30
- requirements:
31
- - - "~>"
32
- - !ruby/object:Gem::Version
33
- version: 3.2.0
34
- type: :runtime
35
- prerelease: false
36
- version_requirements: !ruby/object:Gem::Requirement
37
- requirements:
38
- - - "~>"
39
- - !ruby/object:Gem::Version
40
- version: 3.2.0
26
+ version: 2.4.0
41
27
  - !ruby/object:Gem::Dependency
42
28
  name: kramdown-parser-gfm
43
29
  requirement: !ruby/object:Gem::Requirement
@@ -129,7 +115,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
129
115
  - !ruby/object:Gem::Version
130
116
  version: '0'
131
117
  requirements: []
132
- rubygems_version: 3.3.7
118
+ rubygems_version: 3.3.27
133
119
  signing_key:
134
120
  specification_version: 4
135
121
  summary: A Markdown to AsciiDoc converter based on kramdown