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: 4af9421f3be892d3f963f70789a03201faf12f95ba487207c3affb9f0dd94ba0
4
- data.tar.gz: d1dfcfe239edf6ad09a67bf1dd9a39ac7992466e9aa979475d376b525e0472b5
3
+ metadata.gz: 05d6ea3852e5fb5c4bae0176556b9dd3b7a572b09ab1fc8c9d3752ebe0833548
4
+ data.tar.gz: c9d4a61637e3e04a3fb0ad4b8394b8577236dbf0a9853375f01d750d8ff30f64
5
5
  SHA512:
6
- metadata.gz: eb5d3978b3777a0b04fa51cf736fcee2cf4ce6de38bca4353eff5bd4b8cbf7dcce849f84fb60c05c2979f339fa6b182ff74662e491825a939ca29ea5424152c3
7
- data.tar.gz: 0fc692a6bd815a8ee102f485c2724b1941fe90bffb09cfdcc066ab6ddf90479386f848fe4ad0ea63f66f8d75b12f40a53ed946a4e0343b3f9d201e860f3d042c
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('[^*\n]').repeat(1).as(:text).repeat(1, 1) >>
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('[^_\n]').repeat(1).as(:text).repeat(1, 1) >>
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('[^`\n]').repeat(1).as(:text).repeat(1, 1) >>
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
- klass.new(
12
- content: ToCoreModel.extract_text_content(inline.content),
13
- source_line: inline.source_line
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 soft_break_before?(previous, item)
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 in the content array indicate the
66
- # parser split a paragraph across source lines. Join them with a
67
- # space (soft break) unless the second one carries a hard-break
68
- # marker the model owns that predicate, so this method does
69
- # not reach into parser-specific line_break string values.
70
- def soft_break_before?(previous, current)
71
- previous.is_a?(Model::TextElement) &&
72
- current.is_a?(Model::TextElement) &&
73
- !current.hard_break?
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)
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Coradoc
4
4
  module AsciiDoc
5
- VERSION = '2.0.28'
5
+ VERSION = '2.0.29'
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.28
4
+ version: 2.0.29
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.