Options
All
  • Public
  • Public/Protected
  • All
Menu

Class TMPElement

Hierarchy

  • TMPElement

Index

Properties

Static SINGLES

SINGLES: TMPTag[] = ...

Readonly attributes

attributes: Record<string, string | number>

children

children: TMPNode[]

Readonly tagName

tagName: TMPTag

Methods

align

alpha

bold

clone

  • Deep clone the tree.

    example
    const formatted = tb(color("blue"), italics())
      .text("Deep clone!!!");
    
    const clone = formatted.clone();
    

    Returns TMPElement

color

  • color(clr: string | [number, number, number, number], ...content: TMPNode[]): TMPElement
  • Set the colour of the text

    example
    const formatted = tb().color("ff0000ff", "Red text.");
    

    Or using RGBA:

    const formatted = tb().color([255, 0, 0, 255], "RGBA red text.");
    

    Parameters

    • clr: string | [number, number, number, number]
    • Rest ...content: TMPNode[]

    Returns TMPElement

font

  • Change the font face of the text.

    example
    const formatted = tb().font("Comic Sans MS", "funeral service.");
    

    Parameters

    • face: string
    • Rest ...content: TMPNode[]

    Returns TMPElement

getAttributes

  • getAttributes(): string

getClosing

  • getClosing(): string

getInner

  • getInner(): string
  • Get the inner representation of the element structure as a string.

    Returns string

getOuter

  • getOuter(): string
  • Get the outer representation of the element structure as a string.

    Returns string

getTag

  • getTag(): string

highlight

  • highlight(color: string | [number, number, number, number], ...content: TMPNode[]): void
  • Change the background colour of the text.

    example
    const formatted = tb().highlight("00ff00aa", "This text has a green background.");
    

    Or using RGBA:

    const formatted = tb().highlight([0, 255, 0, 255], "This text has a green background.");
    

    Parameters

    • color: string | [number, number, number, number]
    • Rest ...content: TMPNode[]

    Returns void

indent

  • Change the left indentation of the text.

    example
    const formatted = tb().indent("5em", "I am indented by 5.");
    

    Parameters

    • indentation: string | number
    • Rest ...content: TMPNode[]

    Returns TMPElement

italics

link

  • link(resource: string, ...content: TMPNode[]): boolean
  • Create a link to a resource (Not necessarily related to anything).

    example
    const formatted = tb().link("https://google.com", "click here to get tracked.");
    

    Parameters

    • resource: string
    • Rest ...content: TMPNode[]

    Returns boolean

lnheight

  • lnheight(height: string | number, ...content: TMPNode[]): boolean
  • Change the line height of the text.

    example
    const formatted = tb().indent("2em", "I have huge line spacing like a boss.");
    

    Parameters

    • height: string | number
    • Rest ...content: TMPNode[]

    Returns boolean

lnindent

  • lnindent(indentation: string | number, ...content: TMPNode[]): boolean
  • Change only the indentation for the first line of the text.

    example
    const formatted = tb().indent("2em", "Only this line is indented, any other line will not be indented as displayed by this long piece of text.");
    

    Parameters

    • indentation: string | number
    • Rest ...content: TMPNode[]

    Returns boolean

lowercase

  • Force the text to be rendered as lowercase.

    example
    const formatted = tb().lowercase("THIS TEXT WILL BE IN LOWERCASE."):
    

    Parameters

    Returns TMPElement

margin

  • margin(amount: string | number, ...content: TMPNode[]): void
  • Change the margin of the text.

    example
    const formatted = tb().margin("5em", "Margin text."):
    

    Parameters

    • amount: string | number
    • Rest ...content: TMPNode[]

    Returns void

mark

  • mark(color: string | [number, number, number, number], ...content: TMPNode[]): void
  • Change the background colour of the text.

    example
    const formatted = tb().mark("00ff00aa", "This text has a green background.");
    

    Or using RGBA:

    const formatted = tb().mark([0, 255, 0, 255], "This text has a green background.");
    

    Parameters

    • color: string | [number, number, number, number]
    • Rest ...content: TMPNode[]

    Returns void

mono

  • Force the text to be rendered monospace.

    example
    const formatted = tb().mono("1em", "console.log('Code block.').");
    

    Parameters

    • spacing: string | number
    • Rest ...content: TMPNode[]

    Returns TMPElement

nbspace

  • Stop spaces from breaking up text.

    example
    const formatted = tb().nbspace("This text does not B R E A K U P")
    

    Parameters

    Returns TMPElement

nextpage

  • Move to the next page.

    example
    const formatted = tb().text("This text").nextpage().text("goes across two pages");
    

    Returns TMPElement

pos

  • Change the position of the text on the x axis.

    example
    const formatted = tb().pos("50%", "I am in the middle of the box.");
    

    Parameters

    • x: string | number
    • Rest ...content: TMPNode[]

    Returns TMPElement

s

size

  • Change the size of the font.

    example
    const formatted = tb().size("150%", "This text is rather large.");
    

    Parameters

    • size: string | number
    • Rest ...content: TMPNode[]

    Returns TMPElement

smallcaps

  • Force the text to be rendered as small caps.

    example
    const formatted = tb().smallcaps("This Text Will Be In Small Caps"):
    

    Parameters

    Returns TMPElement

space

  • Create a space of a specified size.

    example
    const formatted = tb().text("Huge").space("5em").text("space");
    

    Parameters

    • space: string | number

    Returns TMPElement

spacing

  • Change the spacing relative to normal character spacing.

    example
    const formatted = tb().spacing("0.5em", "Spaced out text moment.");
    

    Parameters

    • space: string | number
    • Rest ...content: TMPNode[]

    Returns TMPElement

st

strike

strikethrough

subscript

superscript

text

toString

  • toString(): string
  • Get the representation of the element structure as a string.

    Returns string

underline

uppercase

  • Force the text to be rendered as uppercase.

    example
    const formatted = tb().uppercase("this text will be in lowercase."):
    

    Parameters

    Returns TMPElement

voffset

  • Change the vertical offset of the text.

    example
    const formatted = tb().voffset("5em", "This text is high up.").voffset(" and this one is low down.");
    

    Parameters

    • offset: string | number
    • Rest ...content: TMPNode[]

    Returns TMPElement

width

  • Change the maximum width of the text before wrapping.

    example
    const formatted = tb().width("25%", "This text doesn't go that far :(");
    

    Parameters

    • width: string | number
    • Rest ...content: TMPNode[]

    Returns TMPElement

Constructors

constructor

Generated using TypeDoc