coradoc-adoc 2.0.28 → 2.0.29
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:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 05d6ea3852e5fb5c4bae0176556b9dd3b7a572b09ab1fc8c9d3752ebe0833548
|
|
4
|
+
data.tar.gz: c9d4a61637e3e04a3fb0ad4b8394b8577236dbf0a9853375f01d750d8ff30f64
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 2927618c321c352e622dfd8dc69dbeb5658715e76d4062b05793641dc8c35a829c168a8d1e446b7f382bfb86c7f09a0919b4c05409e0a262e41aa8f327a82755
|
|
7
|
+
data.tar.gz: 1fd71a5b04f52748ef48b0529b7d6d8dcbb46987002c6ec442d511fa5902b31761eff9c83d1f3bbb1c0992b7e9d34a544443b55ef5f4580247d93591bbc3f98d
|
|
@@ -41,7 +41,7 @@ module Coradoc
|
|
|
41
41
|
|
|
42
42
|
def bold_unconstrained
|
|
43
43
|
(str('**').present? >> str('**') >>
|
|
44
|
-
match('[
|
|
44
|
+
match('[^*]').repeat(1).as(:text).repeat(1, 1) >>
|
|
45
45
|
str('**')
|
|
46
46
|
).as(:bold_unconstrained)
|
|
47
47
|
end
|
|
@@ -71,7 +71,7 @@ module Coradoc
|
|
|
71
71
|
|
|
72
72
|
def italic_unconstrained
|
|
73
73
|
(str('__') >>
|
|
74
|
-
match('[^_
|
|
74
|
+
match('[^_]').repeat(1).as(:text).repeat(1, 1) >>
|
|
75
75
|
str('__')
|
|
76
76
|
).as(:italic_unconstrained)
|
|
77
77
|
end
|
|
@@ -99,7 +99,7 @@ module Coradoc
|
|
|
99
99
|
|
|
100
100
|
def monospace_unconstrained
|
|
101
101
|
(str('``') >>
|
|
102
|
-
match('[
|
|
102
|
+
match('[^\`]').repeat(1).as(:text).repeat(1, 1) >>
|
|
103
103
|
str('``')
|
|
104
104
|
).as(:monospace_unconstrained)
|
|
105
105
|
end
|
|
@@ -8,10 +8,49 @@ module Coradoc
|
|
|
8
8
|
class << self
|
|
9
9
|
def transform_inline(inline, format_type)
|
|
10
10
|
klass = Coradoc::CoreModel::InlineElement.format_type_class(format_type)
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
)
|
|
11
|
+
raw_content = ToCoreModel.extract_text_content(inline.content)
|
|
12
|
+
|
|
13
|
+
# Recursively parse the mark's content to recognise nested
|
|
14
|
+
# inline marks (Bug 16B). For `**Per-repo \`file.yml\`**`,
|
|
15
|
+
# the outer Bold's content "Per-repo `file.yml`" is fed
|
|
16
|
+
# back through the inline parser so the inner constrained
|
|
17
|
+
# monospace is recognised. The parsed children are stored
|
|
18
|
+
# on the BoldElement; the Mirror handler walks them to
|
|
19
|
+
# produce ProseMirror's flat text-node-with-marks shape.
|
|
20
|
+
children = parse_nested_inline_children(raw_content)
|
|
21
|
+
|
|
22
|
+
if children.any?
|
|
23
|
+
klass.new(
|
|
24
|
+
content: raw_content,
|
|
25
|
+
children: children,
|
|
26
|
+
source_line: inline.source_line
|
|
27
|
+
)
|
|
28
|
+
else
|
|
29
|
+
klass.new(
|
|
30
|
+
content: raw_content,
|
|
31
|
+
source_line: inline.source_line
|
|
32
|
+
)
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
# Re-parse a mark's raw content string through the inline
|
|
37
|
+
# parser. Returns the list of CoreModel children when the
|
|
38
|
+
# content contains nested inline marks; returns [] when
|
|
39
|
+
# the content is plain text (no nested marks to preserve).
|
|
40
|
+
# The empty return is the recursion terminator — once a
|
|
41
|
+
# mark's content has no further mark characters, the
|
|
42
|
+
# parser produces only TextContent nodes, which we drop
|
|
43
|
+
# in favour of the mark's flat content string.
|
|
44
|
+
def parse_nested_inline_children(text)
|
|
45
|
+
return [] if text.nil? || text.to_s.empty?
|
|
46
|
+
|
|
47
|
+
parsed = ToCoreModel.parse_and_transform_inline(text.to_s)
|
|
48
|
+
return [] unless parsed.is_a?(Array)
|
|
49
|
+
|
|
50
|
+
has_marks = parsed.any? do |child|
|
|
51
|
+
child.is_a?(Coradoc::CoreModel::InlineElement)
|
|
52
|
+
end
|
|
53
|
+
has_marks ? parsed : []
|
|
15
54
|
end
|
|
16
55
|
|
|
17
56
|
def transform_inline_text(inline, format_type)
|
|
@@ -55,22 +55,25 @@ module Coradoc
|
|
|
55
55
|
transformed = visit_content(item)
|
|
56
56
|
next if transformed.empty?
|
|
57
57
|
|
|
58
|
-
result << CoreModel::TextContent.new(text: ' ') if
|
|
58
|
+
result << CoreModel::TextContent.new(text: ' ') if line_break_between?(previous, item)
|
|
59
59
|
result.concat(transformed)
|
|
60
60
|
previous = item
|
|
61
61
|
end
|
|
62
62
|
result
|
|
63
63
|
end
|
|
64
64
|
|
|
65
|
-
# Two adjacent TextElements
|
|
66
|
-
# parser split
|
|
67
|
-
#
|
|
68
|
-
#
|
|
69
|
-
#
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
65
|
+
# Two adjacent TextElements only warrant a synthesised soft-break
|
|
66
|
+
# space when the parser actually split them across a source line —
|
|
67
|
+
# i.e. the previous TextElement carries a non-empty line_break.
|
|
68
|
+
# Adjacent inline elements whose source was a single line
|
|
69
|
+
# (e.g. text + typographic-quote + text) do NOT need a synthesised
|
|
70
|
+
# space: their source adjacency is exact, and adding one would
|
|
71
|
+
# introduce spurious double-spaces (TODO.bugs/15A).
|
|
72
|
+
def line_break_between?(previous, current)
|
|
73
|
+
return false unless previous.is_a?(Model::TextElement)
|
|
74
|
+
return false if current.is_a?(Model::TextElement) && current.hard_break?
|
|
75
|
+
|
|
76
|
+
!previous.line_break.to_s.empty?
|
|
74
77
|
end
|
|
75
78
|
|
|
76
79
|
def visit_model(model)
|