"Fossies" - the Fresh Open Source Software Archive

Member "asciidoctor-2.0.10/lib/asciidoctor/inline.rb" (1 Jun 2019, 1841 Bytes) of package /linux/www/asciidoctor-2.0.10.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Ruby source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. See also the last Fossies "Diffs" side-by-side code changes report for "inline.rb": 2.0.8_vs_2.0.9.

    1 # frozen_string_literal: true
    2 module Asciidoctor
    3 # Public: Methods for managing inline elements in AsciiDoc block
    4 class Inline < AbstractNode
    5   # Public: Get the text of this inline element
    6   attr_accessor :text
    7 
    8   # Public: Get the type (qualifier) of this inline element
    9   attr_reader :type
   10 
   11   # Public: Get/Set the target (e.g., uri) of this inline element
   12   attr_accessor :target
   13 
   14   def initialize(parent, context, text = nil, opts = {})
   15     super(parent, context, opts)
   16     @node_name = %(inline_#{context})
   17     @text = text
   18     @id = opts[:id]
   19     @type = opts[:type]
   20     @target = opts[:target]
   21   end
   22 
   23   def block?
   24     false
   25   end
   26 
   27   def inline?
   28     true
   29   end
   30 
   31   def convert
   32     converter.convert self
   33   end
   34 
   35   # Deprecated: Use {Inline#convert} instead.
   36   alias render convert
   37 
   38   # Public: Returns the converted alt text for this inline image.
   39   #
   40   # Returns the [String] value of the alt attribute.
   41   def alt
   42     (attr 'alt') || ''
   43   end
   44 
   45   # For a reference node (:ref or :bibref), the text is the reftext (and the reftext attribute is not set).
   46   #
   47   # (see AbstractNode#reftext?)
   48   def reftext?
   49     @text && (@type == :ref || @type == :bibref)
   50   end
   51 
   52   # For a reference node (:ref or :bibref), the text is the reftext (and the reftext attribute is not set).
   53   #
   54   # (see AbstractNode#reftext)
   55   def reftext
   56     (val = @text) ? (apply_reftext_subs val) : nil
   57   end
   58 
   59   # Public: Generate cross reference text (xreftext) that can be used to refer
   60   # to this inline node.
   61   #
   62   # Use the explicit reftext for this inline node, if specified, retrieved by
   63   # calling the reftext method. Otherwise, returns nil.
   64   #
   65   # xrefstyle - Not currently used (default: nil).
   66   #
   67   # Returns the [String] reftext to refer to this inline node or nothing if no
   68   # reftext is defined.
   69   def xreftext xrefstyle = nil
   70     reftext
   71   end
   72 end
   73 end