Class: Asciidoctor::Inline

Inherits:
AbstractNode show all
Defined in:
lib/asciidoctor/inline.rb

Overview

Methods for managing inline elements in AsciiDoc block

Constant Summary

Constants included from Substitutors

Substitutors::CAN, Substitutors::CGI, Substitutors::DEL, Substitutors::ESC_R_SB, Substitutors::HighlightedPassSlotRx, Substitutors::PASS_END, Substitutors::PASS_START, Substitutors::PLUS, Substitutors::PassSlotRx, Substitutors::QuotedTextSniffRx, Substitutors::RS, Substitutors::R_SB, Substitutors::SUB_GROUPS, Substitutors::SUB_HINTS, Substitutors::SUB_OPTIONS, Substitutors::SpecialCharsRx, Substitutors::SpecialCharsTr

Instance Attribute Summary collapse

Attributes inherited from AbstractNode

#attributes, #context, #document, #id, #node_name, #parent

Instance Method Summary collapse

Methods inherited from AbstractNode

#add_role, #attr, #attr?, #converter, #enabled_options, #generate_data_uri, #generate_data_uri_from_uri, #has_role?, #icon_uri, #image_uri, #is_uri?, #media_uri, #normalize_asset_path, #normalize_system_path, #normalize_web_path, #option?, #read_asset, #read_contents, #remove_attr, #remove_role, #role, #role=, #role?, #roles, #set_attr, #set_option, #update_attributes

Methods included from Substitutors

#apply_header_subs, #apply_normal_subs, #apply_reftext_subs, #apply_subs, #expand_subs, #extract_passthroughs, #highlight_source, #resolve_block_subs, #resolve_lines_to_highlight, #resolve_pass_subs, #resolve_subs, #restore_passthroughs, #sub_attributes, #sub_callouts, #sub_macros, #sub_post_replacements, #sub_quotes, #sub_replacements, #sub_source, #sub_specialchars

Methods included from Logging

#logger, #message_with_context

Constructor Details

#initialize(parent, context, text = nil, opts = {}) ⇒ Inline

Returns a new instance of Inline.



15
16
17
18
19
20
21
22
# File 'lib/asciidoctor/inline.rb', line 15

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

Instance Attribute Details

#targetObject

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



13
14
15
# File 'lib/asciidoctor/inline.rb', line 13

def target
  @target
end

#textObject Also known as: content

Get the text of this inline element



7
8
9
# File 'lib/asciidoctor/inline.rb', line 7

def text
  @text
end

#typeObject (readonly)

Get the type (qualifier) of this inline element



10
11
12
# File 'lib/asciidoctor/inline.rb', line 10

def type
  @type
end

Instance Method Details

#altString

Returns the converted alt text for this inline image.

Returns:

  • (String)

    Returns the String value of the alt attribute.



45
46
47
# File 'lib/asciidoctor/inline.rb', line 45

def alt
  (attr 'alt') || ''
end

#block?Boolean

Returns:

  • (Boolean)


24
25
26
# File 'lib/asciidoctor/inline.rb', line 24

def block?
  false
end

#convertObject Also known as: render



32
33
34
# File 'lib/asciidoctor/inline.rb', line 32

def convert
  converter.convert self
end

#inline?Boolean

Returns:

  • (Boolean)


28
29
30
# File 'lib/asciidoctor/inline.rb', line 28

def inline?
  true
end

#reftextObject

For a reference node (:ref or :bibref), the text is the reftext (and the reftext attribute is not set).

(see AbstractNode#reftext)



59
60
61
# File 'lib/asciidoctor/inline.rb', line 59

def reftext
  (val = @text) ? (apply_reftext_subs val) : nil
end

#reftext?Boolean

For a reference node (:ref or :bibref), the text is the reftext (and the reftext attribute is not set).

(see AbstractNode#reftext?)

Returns:

  • (Boolean)


52
53
54
# File 'lib/asciidoctor/inline.rb', line 52

def reftext?
  @text && (@type == :ref || @type == :bibref)
end

#xreftext(xrefstyle = nil) ⇒ String

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.

Parameters:

  • xrefstyle (defaults to: nil)

    Not currently used (default: nil).

Returns:

  • (String)

    Returns the String reftext to refer to this inline node or nothing if no reftext is defined.



73
74
75
# File 'lib/asciidoctor/inline.rb', line 73

def xreftext xrefstyle = nil
  reftext
end