Options
All
  • Public
  • Public/Protected
  • All
Menu

Class Transformer

Transform HTML stream

Hierarchy

Index

Constructors

constructor

  • new Transformer(option?: stream.TransformOptions): Transformer

Properties

Protected beforeCloseTags

beforeCloseTags: object

Type declaration

  • [key: string]: function[]
      • (): string
      • Returns string

Protected buffer

buffer: string = ""

Protected parser

parser: Parser

Protected tagModifier

tagModifier: object

Type declaration

Protected textTransforms

textTransforms: Transforms = []

Methods

Protected _flush

  • _flush(callback: function): void
  • Parameters

    • callback: function
        • (): void
        • Returns void

    Returns void

Protected _onCloseTag

  • _onCloseTag(name: string): void
  • Parameters

    • name: string

    Returns void

Protected _onOpenTag

  • _onOpenTag(name: string, attrib: object): void
  • Parameters

    • name: string
    • attrib: object
      • [key: string]: string

    Returns void

Protected _onProcessCloseTag

  • _onProcessCloseTag(name: string): void
  • Parameters

    • name: string

    Returns void

Protected _onText

  • _onText(text: string): void
  • Parameters

    • text: string

    Returns void

Protected _transform

  • _transform(chunk: string | Buffer, encoding: string, callback: function): void
  • Parameters

    • chunk: string | Buffer
    • encoding: string
    • callback: function
        • (error?: Error, data?: string): void
        • Parameters

          • Optional error: Error
          • Optional data: string

          Returns void

    Returns void

onBeforeClosingTag

  • onBeforeClosingTag(tagname: string, transformer: function): this
  • Insert some value before closing tag

    Parameters

    • tagname: string

      Target tag name. Can't use '*'

    • transformer: function

      Generator that returns inserted before closing tag

        • (): string
        • Returns string

    Returns this

onTag

  • onTag(tagname: string, attribute: string, pattern: RegExp, transformer: StringTransformer): this
  • Append transform for tag attribute value.

    Parameters

    • tagname: string

      Target tag name. can use '*' for any tag

    • attribute: string

      Attribute name. can use '*' for any attribute

    • pattern: RegExp

      Attribute pattern to transform

    • transformer: StringTransformer

      Transform function.

    Returns this

onText

  • Append text node transform

    Parameters

    • pattern: RegExp

      Text pattern to find

    • transformer: StringTransformer

      text node content transform function

    Returns this

Static Protected _transformString

  • _transformString(text: string, transforms: Transforms): string

Generated using TypeDoc