Class: Coradoc::CoreModel::InlineElement

Inherits:
Base
  • Object
show all
Includes:
ChildrenContent
Defined in:
lib/coradoc/core_model/inline_element.rb

Overview

Generic inline formatting element

Represents all inline text formatting in AsciiDoc:

  • Bold (text or text)

  • Italic (text or __text__)

  • Monospace (‘text` or “text“)

  • Subscript (~text~)

  • Superscript (^text^)

  • Underline ([underline]#text#)

  • Small ([small]#text#)

  • Links

  • Cross-references

  • Footnotes

Inline elements can be nested within each other, allowing for complex formatting like bold italic text.

Examples:

Simple bold text

bold = CoreModel::InlineElement.new(
  format_type: "bold",
  constrained: true,
  content: "important"
)

Nested formatting (bold italic)

italic = CoreModel::InlineElement.new(
  format_type: "italic",
  content: "text"
)
bold = CoreModel::InlineElement.new(
  format_type: "bold",
  content: "bold ",
  nested_elements: [italic]
)

Unconstrained bold

bold = CoreModel::InlineElement.new(
  format_type: "bold",
  constrained: false,
  content: "word"
)

Constant Summary collapse

FORMAT_TYPES =

Canonical set of format_type values produced by ToCoreModel transformers. Extended types (text, span, break, etc.) are produced only by HTML input converters.

%w[
  bold italic monospace underline strikethrough
  subscript superscript highlight
  link xref stem footnote
  hard_line_break
].freeze

Instance Attribute Summary collapse

Attributes inherited from Base

#element_attributes, #id, #metadata_entries, #title

Method Summary

Methods included from ChildrenContent

#children=, #flat_text, included, #initialize, #renderable_content, #to_hash

Methods inherited from Base

#accept, #attr, #metadata, #semantically_equivalent?, #set_attr, #set_metadata

Instance Attribute Details

#constrainedBoolean

Returns whether the formatting uses constrained syntax (true for text, false for text).

Returns:

  • (Boolean)

    whether the formatting uses constrained syntax (true for text, false for text)



66
# File 'lib/coradoc/core_model/inline_element.rb', line 66

attribute :constrained, :boolean, default: -> { true }

#contentString?

Returns text content of the element.

Returns:

  • (String, nil)

    text content of the element



70
# File 'lib/coradoc/core_model/inline_element.rb', line 70

attribute :content, :string

#format_typeString?

Returns type of inline formatting (e.g., ‘bold’, ‘italic’, ‘monospace’, ‘link’, ‘xref’).

Returns:

  • (String, nil)

    type of inline formatting (e.g., ‘bold’, ‘italic’, ‘monospace’, ‘link’, ‘xref’)



61
# File 'lib/coradoc/core_model/inline_element.rb', line 61

attribute :format_type, :string

#nested_elementsArray<InlineElement>?

Returns nested inline formatting.

Returns:



74
# File 'lib/coradoc/core_model/inline_element.rb', line 74

attribute :nested_elements, InlineElement, collection: true

#stem_typeString?

Returns stem notation type (e.g., ‘latexmath’, ‘asciimath’, ‘stem’).

Returns:

  • (String, nil)

    stem notation type (e.g., ‘latexmath’, ‘asciimath’, ‘stem’)



82
# File 'lib/coradoc/core_model/inline_element.rb', line 82

attribute :stem_type, :string

#targetString?

Returns target URL or reference (for links, xrefs).

Returns:

  • (String, nil)

    target URL or reference (for links, xrefs)



78
# File 'lib/coradoc/core_model/inline_element.rb', line 78

attribute :target, :string