@asciidoctor/core
    Preparing search index...

    Class Inline

    Represents an inline element in an AsciiDoc document.

    Hierarchy (View Summary)

    Index

    Constructors

    • Parameters

      • parent: AbstractNode
      • context: string
      • Optionaltext: string

        The String text of this inline element.

      • Optionalopts: any

        A plain object of options: id - The String id of this inline element. type - The String type qualifier (e.g. 'ref', 'bibref'). target - The String target (e.g. a URI).

      Returns Inline

    Properties

    attributes: any
    context: string
    document: Document
    id: string
    nodeName: string
    passthroughs: any[]
    target: string
    text: string
    type: string

    Accessors

    • get logger(): any

      Provide a default logger. The Logging mixin (logging.js) overrides this getter on the prototype.

      Returns any

    • get reftext(): string

      Get the value of the reftext attribute with substitutions applied. The result is pre-computed during Document.parse() via precomputeReftext. Falls back to the raw reftext attribute if precomputeReftext() has not been called yet.

      Returns string

      the String reftext or null if not set.

    • get role(): string | string[]

      Alias for getRole.

      Returns string | string[]

    • set role(names: string | string[]): void

      Set the value of the role attribute on this node.

      Accepts a single role name, a space-separated String, or an Array.

      Parameters

      • names: string | string[]

        A single role name, a space-separated String, or an Array.

      Returns void

    Methods

    • Add the given role directly to this node.

      Parameters

      • name: string

        The String role name to add.

      Returns boolean

      true if the role was added, false if it was already present.

    • Get the converted content (alias for text).

      Returns string

    • Convert this inline element using the document's converter.

      Returns Promise<string>

    • Generate a data URI that embeds the image at the given local path.

      The image path is cleaned to prevent access outside the jail when the document safe level is SafeMode.SAFE or higher. The image data is read and Base64-encoded. In non-Node environments this method returns an empty data URI with a warning.

      Parameters

      • targetImage: string

        A String path to the target image.

      • OptionalassetDirKey: string

        The String attribute key for the image directory.

      Returns Promise<string>

      a Promise resolving to a String data URI.

    • Read the image data from the specified URI and generate a data URI.

      The image data is fetched and Base64-encoded. The MIME type is taken from the Content-Type response header.

      NOTE: This method is async in JS (the Fetch API is async). When called from imageUri, the caller must await the returned Promise.

      Parameters

      • imageUri: string

        The URI from which to read the image data (http/https/ftp).

      • OptionalcacheUri: boolean

        A Boolean to control caching (not yet supported in JS).

      Returns Promise<string>

      a Promise resolving to a String data URI.

    • Get the alt text for this inline image.

      Returns string

      the value of the alt attribute, or ''.

    • Get the value of the specified attribute.

      Looks for the attribute on this node first. If not found and fallbackName is set, and this node is not the Document node, look for that attribute on the Document node. Otherwise, return defaultValue.

      Parameters

      • name: string

        The attribute name to resolve.

      • OptionaldefaultValue: any

        The value to return if the attribute is not found.

      • OptionalfallbackName: string | boolean

        When truthy, also checks the Document's attributes. Pass true to fall back using the same name, or a string to use a different name.

      Returns any

      the attribute value or defaultValue.

      block.getAttribute('language')           // → 'ruby' or null
      
      block.getAttribute('linenums', false)    // → false if not set
      
      block.getAttribute('source-highlighter', null, true)    // → falls back to doc attribute of same name
      block.getAttribute('linenums', null, 'source-linenums') // → falls back to 'source-linenums' on doc
    • Get the icon URI for the named icon.

      Parameters

      • name: string

        The String icon name.

      Returns Promise<string>

      a Promise resolving to a String URI.

    • Get the image URI for the target image.

      Parameters

      • targetImage: string

        The String target image path or URL.

      • OptionalassetDirKey: string

        The String asset directory attribute key.

      Returns Promise<string>

      a Promise resolving to a String URI.

    • Get the media URI for the target.

      Parameters

      • target: string

        The String target path or URL.

      • OptionalassetDirKey: string

        The String asset directory attribute key.

      Returns string

      a String URI.

    • Retrieve the String role names for this node as an Array.

      Returns string[]

      the role names as a String Array, empty if the role attribute is absent.

    • Return the target (e.g. URI or anchor) of this inline node.

      Returns string

    • Return the text of this inline node.

      Returns string

    • Return the type qualifier of this inline node (e.g. 'ref', 'bibref').

      Returns string

    • Check if the specified attribute is defined on this node, with optional value match and document-level fallback.

      Parameters

      • name: string

        The attribute name.

      • OptionalexpectedValue: any

        When truthy, also checks that the resolved value equals this.

      • OptionalfallbackName: string | boolean

        When truthy, also checks the Document's attributes. Pass true to use the same name, or a string for a different fallback name.

      Returns boolean

      block.hasAttribute('linenums')                       // → true/false
      
      block.hasAttribute('language', 'ruby')               // → true only when language === 'ruby'
      
      block.hasAttribute('source-highlighter', null, true) // → also checks doc-level attribute
      
    • Check if the specified option attribute is enabled on this node. This method checks whether the <name>-option attribute is set.

      Parameters

      • name: string

        The String or Symbol name of the option.

      Returns boolean

      true if the option is enabled, false otherwise.

    • Check if the specified role name is present in this node's role list.

      Parameters

      • name: string

        The String role name to find.

      Returns boolean

    • Check if the role attribute is set on this node, optionally matching an exact value.

      Unlike hasRole, which checks for an individual role name within a space-separated list, this method tests the raw role attribute string as a whole.

      Parameters

      • OptionalexpectedValue: string

        When provided, checks that the role attribute equals this string exactly.

      Returns boolean

      node.hasRoleAttribute()         // → true if role attribute is set at all
      node.hasRoleAttribute('lead') // → true only when role === 'lead' (not 'lead primary')
    • Construct a reference or data URI to an icon image for the given name.

      If the 'icon' attribute is set on this node the name is ignored and the attribute value is used as the target path. Otherwise the icon path is built from 'iconsdir', the name, and 'icontype' (default: 'png').

      Parameters

      • name: string

        The String name of the icon.

      Returns Promise<string>

      a Promise resolving to a String reference or data URI for the icon image.

    • Construct a URI reference or data URI to the target image.

      If the target image is already a URI it is left untouched (unless data-uri conversion is requested). The image is resolved relative to the directory named by assetDirKey. When data-uri is enabled and the safe level permits, the image is embedded as a Base64 data URI.

      NOTE: When the document has both 'data-uri' and 'allow-uri-read' enabled and the resolved image URL is a remote URI, this method returns a Promise rather than a String. Await the result when that combination may be active.

      Parameters

      • targetImage: string

        A String path to the target image.

      • OptionalassetDirKey: string

        The String attribute key for the image directory.

      Returns Promise<string>

      a Promise resolving to a String reference or data URI.

    • Check if the specified attribute is defined with an optional value match. Alias for hasAttribute.

      Parameters

      • name: any
      • OptionalexpectedValue: any

      Returns boolean

    • Check whether this node has reftext — either an explicit 'reftext' attribute or a title that can serve as the cross-reference text. Mirrors Ruby's AbstractNode#reftext?

      Returns boolean

    • Construct a URI reference to the target media.

      Parameters

      • target: string

        A String reference to the target media.

      • OptionalassetDirKey: string

        The String attribute key for the media directory.

      Returns string

      a String reference for the target media.

    • Normalize the asset file or directory to a concrete and rinsed path.

      Delegates to normalizeSystemPath with start set to document.baseDir.

      Parameters

      • assetRef: string

        The String asset reference to normalize.

      • OptionalassetName: string

        The String label for the asset used in messages.

      • Optionalautocorrect: boolean

        A Boolean indicating whether to recover from an illegal path.

      Returns string

      the normalized String path.

    • Resolve and normalize a secure path from the target and start paths.

      Prevents resolving a path outside the jail (defaulting to document.baseDir) when the document safe level is SafeMode.SAFE or higher.

      Parameters

      • target: string

        The String target path.

      • Optionalstart: string

        The String start (parent) path.

      • Optionaljail: string

        The String jail path.

      • Optionalopts: any

        A plain object of options:

        • recover {boolean} - Whether to automatically recover for illegal paths.
        • targetName {string} - Label used in messages for the path being resolved.

      Returns string

      the resolved String path.

      if a jail is specified and the resolved path is outside it.

    • Normalize the web path using the PathResolver.

      Parameters

      • target: string

        The String target path.

      • Optionalstart: string

        The String start (parent) path.

      • OptionalpreserveUriTarget: boolean

        Whether a URI target should be preserved as-is.

      Returns string

      the resolved String path.

    • Pre-compute the reftext with substitutions applied asynchronously. Called during Document.parse() so the synchronous getter works during conversion.

      Returns Promise<void>

    • Read the contents of the file at the specified path.

      This method checks that the file is readable before attempting to read it.

      Parameters

      • path: string

        The String path from which to read the contents.

      • Optionalopts: any

        A plain object of options:

        • warnOnFailure {boolean} - Whether a warning is issued when the file cannot be read (default: false).
        • normalize {boolean} - Whether lines are normalized and coerced to UTF-8 (default: false).
        • label {string} - Label for the file used in warning messages.

      Returns Promise<string>

      a Promise resolving to the file content, or null if not readable.

    • Resolve the URI or system path to the target, then read and return its contents.

      When the resolved path is a URI and allow-uri-read is enabled, the content is fetched via the Fetch API (async). When it is a local path, the file is read via readAsset.

      Parameters

      • target: string

        The URI or local path String from which to read the data.

      • Optionalopts: any

        A plain object of options:

        • label {string} - Label used in warning messages (default: 'asset').
        • normalize {boolean} - Whether the data should be normalized (default: false).
        • start {string} - Relative base path for resolving the target.
        • warnOnFailure {boolean} - Whether warnings are issued on failure (default: true).
        • warnIfEmpty {boolean} - Whether a warning is issued when the target contents are empty (default: false).

      Returns Promise<string>

      a Promise resolving to the content, or null on failure.

    • Remove the attribute from this node.

      Parameters

      • name: string

        The attribute name to remove.

      Returns any

      the previous value, or undefined if the attribute was not present.

    • Remove the given role directly from this node.

      Parameters

      • name: string

        The String role name to remove.

      Returns boolean

      true if the role was removed, false if it was not present.

    • Returns Promise<string>

      Use convert() instead.

    • Set the value of the specified attribute on this node.

      Parameters

      • name: string

        The attribute name to assign.

      • Optionalvalue: any

        The value to assign.

      • Optionaloverwrite: boolean

        When false, does nothing if the attribute already exists.

      Returns string | boolean

      true if the attribute was set, false if blocked by overwrite=false. Subclasses (e.g. Document) may return the resolved value string or null when the attribute is locked.

    • Set the specified option on this node by setting the <name>-option attribute.

      Parameters

      • name: string

        The String name of the option.

      Returns void

    • Set the value of the role attribute on this node.

      Accepts a single role name, a space-separated String, an Array, or spread arguments.

      Parameters

      • ...names: (string | string[])[]

        A single role name, a space-separated String, an Array, or multiple role names as spread arguments.

      Returns string

      the value of the role attribute.

    • Update the attributes of this node with the new values.

      Parameters

      • newAttributes: any

        A plain object of additional attributes to assign.

      Returns any

      the updated attributes object on this node.

    • Generate cross-reference text (xreftext) that can be used to refer to this inline node.

      Uses the explicit reftext for this inline node, if specified, retrieved by calling the reftext method. Otherwise, returns null.

      Parameters

      • Optional_xrefstyle: string

        Not currently used.

      Returns string

      the reftext to refer to this inline node, or null if no reftext is defined.