Sha256: dcb4e09a6aa7b36f23a5e4ed49c84be9b97c03bc40c2e8d29d6dcfb8ae31ad98

Contents?: true

Size: 1.8 KB

Versions: 16

Compression:

Stored size: 1.8 KB

Contents

# frozen_string_literal: true
module Asciidoctor
# Public: Methods for managing inline elements in AsciiDoc block
class Inline < AbstractNode
  # Public: Get the text of this inline element
  attr_accessor :text

  # Public: Get the type (qualifier) of this inline element
  attr_reader :type

  # Public: Get/Set the target (e.g., uri) of this inline element
  attr_accessor :target

  def initialize(parent, context, text = nil, opts = {})
    super(parent, context, opts)
    @node_name = %(inline_#{context})
    @text = text
    @id = opts[:id]
    @type = opts[:type]
    @target = opts[:target]
  end

  def block?
    false
  end

  def inline?
    true
  end

  def convert
    converter.convert self
  end

  # Deprecated: Use {Inline#convert} instead.
  alias render convert

  # Public: Returns the converted alt text for this inline image.
  #
  # Returns the [String] value of the alt attribute.
  def alt
    (attr 'alt') || ''
  end

  # For a reference node (:ref or :bibref), the text is the reftext (and the reftext attribute is not set).
  #
  # (see AbstractNode#reftext?)
  def reftext?
    @text && (@type == :ref || @type == :bibref)
  end

  # For a reference node (:ref or :bibref), the text is the reftext (and the reftext attribute is not set).
  #
  # (see AbstractNode#reftext)
  def reftext
    (val = @text) ? (apply_reftext_subs val) : nil
  end

  # Public: Generate cross reference text (xreftext) that can be used to refer
  # to this inline node.
  #
  # Use the explicit reftext for this inline node, if specified, retrieved by
  # calling the reftext method. Otherwise, returns nil.
  #
  # xrefstyle - Not currently used (default: nil).
  #
  # Returns the [String] reftext to refer to this inline node or nothing if no
  # reftext is defined.
  def xreftext xrefstyle = nil
    reftext
  end
end
end

Version data entries

16 entries across 16 versions & 2 rubygems

Version Path
asciidoctor-2.0.22 lib/asciidoctor/inline.rb
asciidoctor-2.0.21 lib/asciidoctor/inline.rb
asciidoctor-2.0.20 lib/asciidoctor/inline.rb
asciidoctor-2.0.19 lib/asciidoctor/inline.rb
asciidoctor-2.0.18 lib/asciidoctor/inline.rb
asciidoctor-2.0.17 lib/asciidoctor/inline.rb
asciidoctor-2.0.16 lib/asciidoctor/inline.rb
asciidoctor-2.0.15 lib/asciidoctor/inline.rb
asciidoctor-2.0.14 lib/asciidoctor/inline.rb
asciidoctor-2.0.13 lib/asciidoctor/inline.rb
asciidoctor-2.0.12 lib/asciidoctor/inline.rb
asciidoctor-2.0.11 lib/asciidoctor/inline.rb
metanorma-cli-1.3.4 gems/ruby/2.6.0/gems/asciidoctor-2.0.10/lib/asciidoctor/inline.rb
metanorma-cli-1.3.3.1 gems/ruby/2.6.0/gems/asciidoctor-2.0.10/lib/asciidoctor/inline.rb
asciidoctor-2.0.10 lib/asciidoctor/inline.rb
asciidoctor-2.0.9 lib/asciidoctor/inline.rb