Class: Coradoc::Mirror::Mark

Inherits:
Lutaml::Model::Serializable
  • Object
show all
Defined in:
lib/coradoc/mirror/mark.rb,
lib/coradoc/mirror/mark.rb,
lib/coradoc/mirror/mark.rb

Overview

ProseMirror-compatible inline mark (formatting annotation).

Marks decorate inline text nodes with formatting semantics like bold, italic, link, etc. Wire format:

{ "type": "strong" }
{ "type": "link", "attrs": { "href": "..." } }

All built-in Mark subclasses live below in this file so the TYPE_TO_CLASS registry at the bottom can see every PM_TYPE at load time. Adding a new mark type = adding one subclass + letting the registry walker pick it up (OCP).

Defined Under Namespace

Classes: Bold, CrossReference, Highlight, Italic, Link, Monospace, Span, Stem, Strikethrough, Subscript, Superscript, Underline

Constant Summary collapse

PM_TYPE =
'mark'
TYPE_TO_CLASS =

Polymorphic class map — flat hash from PM_TYPE wire string to fully-qualified Ruby class name. Used by Node and Mark mappings to dispatch polymorphic deserialization. Populated once after all subclasses are defined above.

begin
  result = {}
  Mark.constants.each do |name|
    k = Mark.const_get(name)
    next unless k.is_a?(Class) && k < Mark && k::PM_TYPE != 'mark'

    result[k::PM_TYPE] = k.name
  end
  result.freeze
end
POLYMORPHIC =

Frozen polymorphic option block. Referenced verbatim by every Node mapping that has a ‘marks` collection.

{
  attribute: 'type',
  class_map: TYPE_TO_CLASS
}.freeze

Instance Method Summary collapse

Instance Method Details

#text_contentObject



28
29
30
# File 'lib/coradoc/mirror/mark.rb', line 28

def text_content
  ''
end