coradoc-adoc 2.0.17 → 2.0.18

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: 99b9b654a8eebde5418dfbee6f7b184e65bbbcd830b24f0211963d61ed6c1201
4
- data.tar.gz: 93e69befaf29a65358e5b6655b7b6cf63d0fb9baab9a828848d7468290c87e3b
3
+ metadata.gz: d8b381debf5d0742992318f775804846b9a2560e59dcff0dad3518999fcb39ad
4
+ data.tar.gz: 5556652e925b9d3081562849790252900e9a2b2493ca7f6eb8ae023d888ed38a
5
5
  SHA512:
6
- metadata.gz: 1480db996c2768544ae15657c7f394bcaed954c31c79bdf1bfd3f3493b608aad77dc078ed44058ac0964632626585f096a7c96d6047a256ed07f902291ac204a
7
- data.tar.gz: b3d0d2044b40702ad13d2f500e06e4e5881e865eda9ac0bc3f01fba94c82175b9b1752e3076b05781d7fd03075af7d276b8af55ef18b4be08576ea5018ea07b0
6
+ metadata.gz: 7bae7c856ed3b6c8c804c614e009a1efe36327c94cd8d1b5b48429b1fe849f75e99df68f1c85f719c63d57b05fd9584a707881bd01e8d232a5cf189bc9c7e69f
7
+ data.tar.gz: 121f12dea70e459c11f7f91233fb7189dedf92bdc0ad8665063c427df67456a8bf0d0bfa035dec43f46919b851fad078bf48598cdac323ff2c86a02102b560f4
@@ -44,7 +44,7 @@ module Coradoc
44
44
  end
45
45
 
46
46
  def positional_value_unquoted
47
- match('[^\]\s,]').repeat(1) >> space.absent?
47
+ match('[^\],]').repeat(1)
48
48
  end
49
49
 
50
50
  def positional_value_single_quote
@@ -118,6 +118,7 @@ module Coradoc
118
118
 
119
119
  def inline_image
120
120
  (str('image:').present? >> str('image:') >>
121
+ str(':').absent? >>
121
122
  match('[A-Za-z0-9_.\\-:/&?=+,%#~;]+').repeat(1).as(:path) >>
122
123
  (str('[') >> match('[^\\]]').repeat(1).as(:text) >> str(']')).maybe
123
124
  ).as(:inline_image)
@@ -72,11 +72,35 @@ module Coradoc
72
72
  def ulist_marker(nesting_level = 1)
73
73
  line_start? >>
74
74
  (nesting_level > 1 ? literal_space.maybe : str('')) >>
75
- str('*' * nesting_level) >>
75
+ (
76
+ asterisk_marker(nesting_level) |
77
+ dash_marker(nesting_level)
78
+ )
79
+ end
80
+
81
+ # AsciiDoc standard bullet: `*`, `**`, `***`, ... matching the
82
+ # nesting level. Excludes table delimiters (`|===`) and deeper
83
+ # asterisk runs that belong to a sibling level.
84
+ def asterisk_marker(nesting_level)
85
+ str('*' * nesting_level) >>
76
86
  str('*').absent? >>
77
87
  str('===').absent?
78
88
  end
79
89
 
90
+ # Markdown-style dash bullet: `-`. Accepted only at the top level
91
+ # because Markdown nests via indentation rather than multi-char
92
+ # markers — deeper levels stay on the AsciiDoc `*` form. Guards
93
+ # exclude em-dashes (`--`), delimited-block fences (`----`),
94
+ # and negative-number runs (`-1`, `-42`) which are not list
95
+ # markers in any common dialect.
96
+ def dash_marker(nesting_level)
97
+ return match('').absent? unless nesting_level == 1
98
+
99
+ str('-') >>
100
+ str('-').absent? >>
101
+ match('[0-9]').absent?
102
+ end
103
+
80
104
  def ulist_item(nesting_level = 1)
81
105
  item = ulist_marker(nesting_level).as(:marker) >>
82
106
  str(' [[[').absent? >>
@@ -128,7 +128,7 @@ module Coradoc
128
128
 
129
129
  def transform_typed_block(block, klass, extra_attrs = {})
130
130
  raw_lines = Array(block.lines)
131
- has_nested_blocks = raw_lines.any?(Coradoc::AsciiDoc::Model::Block::Core)
131
+ has_nested_blocks = raw_lines.any? { |line| block_level_child?(line) }
132
132
 
133
133
  if has_nested_blocks
134
134
  children = raw_lines.reject do |line|
@@ -195,6 +195,17 @@ module Coradoc
195
195
  groups << current if current.any?
196
196
  groups
197
197
  end
198
+
199
+ # A line that should be emitted as a direct child of the
200
+ # enclosing block rather than joined into a paragraph sibling.
201
+ # The AsciiDoc model layer declares level via `block_level?`
202
+ # (true for Block::Core delimited blocks, BlockImage, Table,
203
+ # List::Core, Section, CommentBlock, Attached). Inline content
204
+ # (String, TextElement, LineBreak, PageBreak) returns false and
205
+ # stays inside paragraphs.
206
+ def block_level_child?(line)
207
+ line.is_a?(Coradoc::AsciiDoc::Model::Base) && line.block_level?
208
+ end
198
209
  end
199
210
  end
200
211
  end
@@ -27,9 +27,19 @@ module Coradoc
27
27
  def transform_image(image)
28
28
  src = image.src.to_s
29
29
  src = src[1..] if src.start_with?(':')
30
+ positional = image.attributes&.positional || []
31
+ positional_alt = positional.first&.value&.to_s || ''
32
+ caption = positional[1]&.value&.to_s
33
+ title = image.title&.to_s
34
+ # AsciiDoc block-title (`.Caption`) is semantically a caption,
35
+ # but for compatibility with the existing pipeline that treated
36
+ # it as alt when no positional alt was supplied, fall back to it.
37
+ alt = positional_alt.empty? ? title : positional_alt
30
38
  Coradoc::CoreModel::Image.new(
31
39
  src: src,
32
- alt: image.title&.to_s,
40
+ alt: alt,
41
+ caption: caption,
42
+ title: title,
33
43
  width: image.attributes&.[]('width'),
34
44
  height: image.attributes&.[]('height')
35
45
  )
@@ -46,7 +46,7 @@ module Coradoc
46
46
  id = block_image[:id]
47
47
  title = block_image[:title]
48
48
  path = block_image[:path]
49
- attrs = AttributeListNormalizer.coerce(block_image[:attribute_list])
49
+ attrs = AttributeListNormalizer.coerce(block_image[:attribute_list_macro])
50
50
  Model::Image::BlockImage.new(
51
51
  title: title,
52
52
  id: id,
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Coradoc
4
4
  module AsciiDoc
5
- VERSION = '2.0.17'
5
+ VERSION = '2.0.18'
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: coradoc-adoc
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.17
4
+ version: 2.0.18
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.