coradoc-mirror 0.1.6 → 0.1.7

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: 576065e7e1df118cef928c6412777012caa0e8a165ef5c596c9d1b331711c8bb
4
- data.tar.gz: cb78e786ccf1d4686f6d964fa9c0cfa34bc01fe32eb12132ab406baf45f2e509
3
+ metadata.gz: 29f073186a23485753658ba4782ec7022461c2869351d6bb273eda9f30fda92e
4
+ data.tar.gz: aee881fe73fa219d89415deb8b6eb0e9a509cbd4b5b71b3f4ddfe6456ef114f8
5
5
  SHA512:
6
- metadata.gz: a316f677682b17a95a7d86f4e93504a035062c8b1ae39f5b0bcacd20a26ae839534c4dae6458bf54522400ff0f39ce8a899681e71298ab949899f6c7b2136266
7
- data.tar.gz: bd09f0bb9fb15365bb55f305aa85af2772dbc5dd650ab017c5814ceb3d5dae80d60db6930573037d798b0f203967a6b150316252a92bcec52be8929fe0db7fac
6
+ metadata.gz: beabd828aeb5e91a4a3c9e6049045123a2c4884ceef8a9887d4ec27874242a22e36661d2f807a67cbb7bc4a19b4616b8b578463d4ecfb763d98fcf56d5c5a591
7
+ data.tar.gz: 23e77c6e5dc7605ba5e4ff8a4cab88efc7433c30554cb5afcb71cff4345d4dc6906ca2efa03d58034e07f6a594e543c7291e9dd88e02f2f458fb5c6c197cdee9
@@ -0,0 +1,19 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Coradoc
4
+ module Mirror
5
+ module Handlers
6
+ module Abstract
7
+ def self.call(element, context:)
8
+ content = context.extract_content(element)
9
+ return nil if content.empty?
10
+
11
+ Node::Abstract.new(
12
+ attrs: Node::Abstract::Attrs.new(id: element.id, title: element.title),
13
+ content: content
14
+ )
15
+ end
16
+ end
17
+ end
18
+ end
19
+ end
@@ -102,7 +102,9 @@ module Coradoc
102
102
  build_span_mark(element, context)
103
103
  when CoreModel::FootnoteElement
104
104
  build_footnote_node(element, context)
105
- when CoreModel::HardLineBreakElement, CoreModel::LineBreakElement
105
+ when CoreModel::HardLineBreakElement
106
+ Node::HardBreak.new
107
+ when CoreModel::LineBreakElement
106
108
  Node::SoftBreak.new
107
109
  when CoreModel::TextElement
108
110
  build_text_only(element, context)
@@ -0,0 +1,19 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Coradoc
4
+ module Mirror
5
+ module Handlers
6
+ module Partintro
7
+ def self.call(element, context:)
8
+ content = context.extract_content(element)
9
+ return nil if content.empty?
10
+
11
+ Node::Partintro.new(
12
+ attrs: Node::Partintro::Attrs.new(id: element.id, title: element.title),
13
+ content: content
14
+ )
15
+ end
16
+ end
17
+ end
18
+ end
19
+ end
@@ -17,6 +17,8 @@ module Coradoc
17
17
  autoload :Blockquote, "#{__dir__}/handlers/blockquote"
18
18
  autoload :Example, "#{__dir__}/handlers/example"
19
19
  autoload :Sidebar, "#{__dir__}/handlers/sidebar"
20
+ autoload :Abstract, "#{__dir__}/handlers/abstract"
21
+ autoload :Partintro, "#{__dir__}/handlers/partintro"
20
22
  autoload :OpenBlock, "#{__dir__}/handlers/open_block"
21
23
  autoload :Verse, "#{__dir__}/handlers/verse"
22
24
  autoload :Comment, "#{__dir__}/handlers/comment"
@@ -303,6 +303,60 @@ module Coradoc
303
303
  end
304
304
  end
305
305
 
306
+ # Abstract block — `[abstract]\n====\n...\n====` in AsciiDoc. Carries
307
+ # the same shape as Sidebar/Example but a distinct wire type so the
308
+ # block-level construct does not collide with the section-level
309
+ # `abstract` (one of Section's PM_ALIASES). The block preserves its
310
+ # block identity through round-trip; renderers that want a section
311
+ # view should look at SectionElement-style sources instead.
312
+ class Abstract < Node
313
+ PM_TYPE = 'abstract_block'
314
+
315
+ class Attrs < Lutaml::Model::Serializable
316
+ attribute :title, :string
317
+ attribute :id, :string
318
+
319
+ key_value do
320
+ map 'title', to: :title
321
+ map 'id', to: :id
322
+ end
323
+ end
324
+
325
+ attribute :attrs, Attrs
326
+
327
+ key_value do
328
+ map 'type', to: :type, render_default: true
329
+ map 'attrs', to: :attrs
330
+ map 'content', to: :content, polymorphic: Node::POLYMORPHIC
331
+ end
332
+ end
333
+
334
+ # Partintro block — `[partintro]\n====\n...\n====` in AsciiDoc, used
335
+ # to introduce a "part" in multi-part documents. Distinct wire type
336
+ # for the same reason as Abstract (no collision with potential
337
+ # section-level uses of "partintro").
338
+ class Partintro < Node
339
+ PM_TYPE = 'partintro_block'
340
+
341
+ class Attrs < Lutaml::Model::Serializable
342
+ attribute :title, :string
343
+ attribute :id, :string
344
+
345
+ key_value do
346
+ map 'title', to: :title
347
+ map 'id', to: :id
348
+ end
349
+ end
350
+
351
+ attribute :attrs, Attrs
352
+
353
+ key_value do
354
+ map 'type', to: :type, render_default: true
355
+ map 'attrs', to: :attrs
356
+ map 'content', to: :content, polymorphic: Node::POLYMORPHIC
357
+ end
358
+ end
359
+
306
360
  class OpenBlock < Node
307
361
  PM_TYPE = 'open_block'
308
362
 
@@ -344,6 +398,15 @@ module Coradoc
344
398
  PM_TYPE = 'soft_break'
345
399
  end
346
400
 
401
+ # Hard line break — author-requested explicit break (`foo +\nbar` in
402
+ # AsciiDoc, `<br>` semantics in HTML). Distinct from SoftBreak so
403
+ # downstream renderers can map it to `<br>` rather than collapsing
404
+ # the break into a soft newline-or-space convention. ProseMirror's
405
+ # schema uses `hard_break` for the same purpose.
406
+ class HardBreak < Node
407
+ PM_TYPE = 'hard_break'
408
+ end
409
+
347
410
  # ── Admonition (NOTE, TIP, WARNING, CAUTION, IMPORTANT) ──
348
411
  #
349
412
  # The Ruby attribute name is `admonition_type` (kept distinct from
@@ -0,0 +1,21 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'base'
4
+
5
+ module Coradoc
6
+ module Mirror
7
+ module ReverseBuilder
8
+ class Abstract < Base
9
+ registers 'abstract_block'
10
+
11
+ def build(node)
12
+ CoreModel::AbstractBlock.new(
13
+ title: node.attrs&.title,
14
+ id: node.attrs&.id,
15
+ children: build_content(node)
16
+ )
17
+ end
18
+ end
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,17 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'base'
4
+
5
+ module Coradoc
6
+ module Mirror
7
+ module ReverseBuilder
8
+ class HardBreak < Base
9
+ registers 'hard_break'
10
+
11
+ def build(_node)
12
+ CoreModel::HardLineBreakElement.new(content: '')
13
+ end
14
+ end
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,21 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'base'
4
+
5
+ module Coradoc
6
+ module Mirror
7
+ module ReverseBuilder
8
+ class Partintro < Base
9
+ registers 'partintro_block'
10
+
11
+ def build(node)
12
+ CoreModel::PartintroBlock.new(
13
+ title: node.attrs&.title,
14
+ id: node.attrs&.id,
15
+ children: build_content(node)
16
+ )
17
+ end
18
+ end
19
+ end
20
+ end
21
+ end
@@ -62,6 +62,8 @@ module Coradoc
62
62
  require_relative 'reverse_builder/blockquote'
63
63
  require_relative 'reverse_builder/example'
64
64
  require_relative 'reverse_builder/sidebar'
65
+ require_relative 'reverse_builder/abstract'
66
+ require_relative 'reverse_builder/partintro'
65
67
  require_relative 'reverse_builder/open_block'
66
68
  require_relative 'reverse_builder/verse'
67
69
  require_relative 'reverse_builder/horizontal_rule'
@@ -91,6 +93,7 @@ module Coradoc
91
93
  require_relative 'reverse_builder/text'
92
94
  require_relative 'reverse_builder/raw_inline'
93
95
  require_relative 'reverse_builder/soft_break'
96
+ require_relative 'reverse_builder/hard_break'
94
97
  require_relative 'reverse_builder/generic_block'
95
98
  end
96
99
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Coradoc
4
4
  module Mirror
5
- VERSION = '0.1.6'
5
+ VERSION = '0.1.7'
6
6
  end
7
7
  end
@@ -75,6 +75,8 @@ module Coradoc
75
75
  registry.register(CoreModel::QuoteBlock, Handlers::Blockquote)
76
76
  registry.register(CoreModel::ExampleBlock, Handlers::Example)
77
77
  registry.register(CoreModel::SidebarBlock, Handlers::Sidebar)
78
+ registry.register(CoreModel::AbstractBlock, Handlers::Abstract)
79
+ registry.register(CoreModel::PartintroBlock, Handlers::Partintro)
78
80
  registry.register(CoreModel::OpenBlock, Handlers::OpenBlock)
79
81
  registry.register(CoreModel::VerseBlock, Handlers::Verse)
80
82
  registry.register(CoreModel::CommentBlock, Handlers::Comment)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: coradoc-mirror
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.6
4
+ version: 0.1.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.
@@ -81,6 +81,7 @@ files:
81
81
  - lib/coradoc/mirror/frontmatter_tree_to_hash.rb
82
82
  - lib/coradoc/mirror/handler_registry.rb
83
83
  - lib/coradoc/mirror/handlers.rb
84
+ - lib/coradoc/mirror/handlers/abstract.rb
84
85
  - lib/coradoc/mirror/handlers/admonition.rb
85
86
  - lib/coradoc/mirror/handlers/bibliography.rb
86
87
  - lib/coradoc/mirror/handlers/blockquote.rb
@@ -98,6 +99,7 @@ files:
98
99
  - lib/coradoc/mirror/handlers/list.rb
99
100
  - lib/coradoc/mirror/handlers/open_block.rb
100
101
  - lib/coradoc/mirror/handlers/paragraph.rb
102
+ - lib/coradoc/mirror/handlers/partintro.rb
101
103
  - lib/coradoc/mirror/handlers/reviewer.rb
102
104
  - lib/coradoc/mirror/handlers/sidebar.rb
103
105
  - lib/coradoc/mirror/handlers/structural.rb
@@ -112,6 +114,7 @@ files:
112
114
  - lib/coradoc/mirror/node.rb
113
115
  - lib/coradoc/mirror/partitioner.rb
114
116
  - lib/coradoc/mirror/reverse_builder.rb
117
+ - lib/coradoc/mirror/reverse_builder/abstract.rb
115
118
  - lib/coradoc/mirror/reverse_builder/admonition.rb
116
119
  - lib/coradoc/mirror/reverse_builder/base.rb
117
120
  - lib/coradoc/mirror/reverse_builder/biblio_entry.rb
@@ -129,6 +132,7 @@ files:
129
132
  - lib/coradoc/mirror/reverse_builder/footnotes.rb
130
133
  - lib/coradoc/mirror/reverse_builder/frontmatter.rb
131
134
  - lib/coradoc/mirror/reverse_builder/generic_block.rb
135
+ - lib/coradoc/mirror/reverse_builder/hard_break.rb
132
136
  - lib/coradoc/mirror/reverse_builder/header.rb
133
137
  - lib/coradoc/mirror/reverse_builder/horizontal_rule.rb
134
138
  - lib/coradoc/mirror/reverse_builder/image.rb
@@ -139,6 +143,7 @@ files:
139
143
  - lib/coradoc/mirror/reverse_builder/open_block.rb
140
144
  - lib/coradoc/mirror/reverse_builder/ordered_list.rb
141
145
  - lib/coradoc/mirror/reverse_builder/paragraph.rb
146
+ - lib/coradoc/mirror/reverse_builder/partintro.rb
142
147
  - lib/coradoc/mirror/reverse_builder/pass_block.rb
143
148
  - lib/coradoc/mirror/reverse_builder/preamble.rb
144
149
  - lib/coradoc/mirror/reverse_builder/raw_inline.rb