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 +4 -4
- data/lib/coradoc/asciidoc/parser/attribute_list.rb +1 -1
- data/lib/coradoc/asciidoc/parser/inline.rb +1 -0
- data/lib/coradoc/asciidoc/parser/list.rb +25 -1
- data/lib/coradoc/asciidoc/transform/element_transformers/block_transformer.rb +12 -1
- data/lib/coradoc/asciidoc/transform/element_transformers/other_transformer.rb +11 -1
- data/lib/coradoc/asciidoc/transformer/block_rules.rb +1 -1
- data/lib/coradoc/asciidoc/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: d8b381debf5d0742992318f775804846b9a2560e59dcff0dad3518999fcb39ad
|
|
4
|
+
data.tar.gz: 5556652e925b9d3081562849790252900e9a2b2493ca7f6eb8ae023d888ed38a
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 7bae7c856ed3b6c8c804c614e009a1efe36327c94cd8d1b5b48429b1fe849f75e99df68f1c85f719c63d57b05fd9584a707881bd01e8d232a5cf189bc9c7e69f
|
|
7
|
+
data.tar.gz: 121f12dea70e459c11f7f91233fb7189dedf92bdc0ad8665063c427df67456a8bf0d0bfa035dec43f46919b851fad078bf48598cdac323ff2c86a02102b560f4
|
|
@@ -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
|
-
|
|
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?(
|
|
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:
|
|
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[:
|
|
49
|
+
attrs = AttributeListNormalizer.coerce(block_image[:attribute_list_macro])
|
|
50
50
|
Model::Image::BlockImage.new(
|
|
51
51
|
title: title,
|
|
52
52
|
id: id,
|