Class: Asciidoctor::Diagram::DiagramInlineMacroProcessor

Inherits:
Extensions::InlineMacroProcessor
  • Object
show all
Includes:
DiagramProcessor
Defined in:
lib/asciidoctor-diagram/diagram_processor.rb

Overview

Base class for diagram inline macro processors.

Constant Summary

Constants included from DiagramProcessor

Asciidoctor::Diagram::DiagramProcessor::IMAGE_PARAMS, Asciidoctor::Diagram::DiagramProcessor::TEXT_FORMATS

Class Method Summary collapse

Instance Method Summary collapse

Methods included from DiagramProcessor

included

Class Method Details

.inherited(subclass) ⇒ Object



414
415
416
# File 'lib/asciidoctor-diagram/diagram_processor.rb', line 414

def self.inherited(subclass)
  subclass.name_positional_attributes ['format']
end

Instance Method Details

#apply_target_subs(parent, target) ⇒ Object



418
419
420
421
422
423
424
# File 'lib/asciidoctor-diagram/diagram_processor.rb', line 418

def apply_target_subs(parent, target)
  if target
    parent.normalize_system_path(parent.sub_attributes(target, :attribute_missing => 'warn'))
  else
    nil
  end
end

#create_source(parent, target, attributes) ⇒ FileSource

Creates a FileSource using target as the file name.

Returns:



451
452
453
# File 'lib/asciidoctor-diagram/diagram_processor.rb', line 451

def create_source(parent, target, attributes)
  FileSource.new(self, parent, apply_target_subs(parent, target), attributes)
end

#generate_blockObject



426
# File 'lib/asciidoctor-diagram/diagram_processor.rb', line 426

alias_method(:generate_block,:process)

#process(parent, reader_or_target, attributes) ⇒ Object



428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
# File 'lib/asciidoctor-diagram/diagram_processor.rb', line 428

def process(parent, reader_or_target, attributes)
  block = generate_block(parent, reader_or_target, attributes)
  attrs = block.attributes.dup
  target = attrs.delete('target')

  # Don't let the asciidoctor try to apply substitutions.
  # The text of inline macros is nil which will cause an error
  attrs.delete('subs')

  if block.context == :image
    create_inline(parent, :image, nil, :type => 'image', :target => target, :attributes => attrs)
  else
    create_inline(parent, :quoted, block.source, :type => :monospaced, :attributes => attrs)
  end
end

#supported_formats(converter) ⇒ Object



444
445
446
# File 'lib/asciidoctor-diagram/diagram_processor.rb', line 444

def supported_formats(converter)
  converter.supported_formats.reject { |f| TEXT_FORMATS.include?(f) }
end