Options
All
  • Public
  • Public/Protected
  • All
Menu

Represents the source CSS.

const root  = postcss.parse(css, { from: file })
const input = root.source.input

Hierarchy

  • Input_

Index

Constructors

Properties

Accessors

Methods

Constructors

  • Parameters

    Returns Input_

Properties

css: string

Input CSS source.

const input = postcss.parse('a{}', { from: file }).input
input.css //=> "a{}"
file?: string

The absolute path to the CSS source file defined with the from option.

const root = postcss.parse(css, { from: 'a.css' })
root.source.input.file //=> '/home/ai/a.css'
hasBOM: boolean

The flag to indicate whether or not the source code has Unicode BOM.

id?: string

The unique ID of the CSS source. It will be created if from option is not provided (because PostCSS does not know the file path).

const root = postcss.parse(css)
root.source.input.file //=> undefined
root.source.input.id //=> "<input css 8LZeVF>"

The input source map passed from a compilation step before PostCSS (for example, from Sass compiler).

root.source.input.map.consumer().sources //=> ['a.sass']

Accessors

  • get from(): string
  • The CSS source identifier. Contains Input#file if the user set the from option, or Input#id if they did not.

    const root = postcss.parse(css, { from: 'a.css' })
    root.source.input.from //=> "/home/ai/a.css"

    const root = postcss.parse(css)
    root.source.input.from //=> "<input css 1>"

    Returns string

Methods

  • error(message: string, start: { column: number; line: number } | { offset: number }, end: { column: number; line: number } | { offset: number }, opts?: { plugin?: string }): CssSyntaxError_
  • error(message: string, line: number, column: number, opts?: { plugin?: string }): CssSyntaxError_
  • error(message: string, offset: number, opts?: { plugin?: string }): CssSyntaxError_
  • Parameters

    • message: string
    • start: { column: number; line: number } | { offset: number }
    • end: { column: number; line: number } | { offset: number }
    • Optional opts: { plugin?: string }
      • Optional plugin?: string

    Returns CssSyntaxError_

  • Returns CssSyntaxError with information about the error and its position.

    Parameters

    • message: string
    • line: number
    • column: number
    • Optional opts: { plugin?: string }
      • Optional plugin?: string

    Returns CssSyntaxError_

  • Parameters

    • message: string
    • offset: number
    • Optional opts: { plugin?: string }
      • Optional plugin?: string

    Returns CssSyntaxError_

  • fromOffset(offset: number): null | { col: number; line: number }
  • Converts source offset to line and column.

    Parameters

    • offset: number

      Source offset.

    Returns null | { col: number; line: number }

  • origin(line: number, column: number, endLine?: number, endColumn?: number): false | FilePosition
  • Reads the input source map and returns a symbol position in the input source (e.g., in a Sass file that was compiled to CSS before being passed to PostCSS). Optionally takes an end position, exclusive.

    root.source.input.origin(1, 1) //=> { file: 'a.css', line: 3, column: 1 }
    root.source.input.origin(1, 1, 1, 4)
    //=> { file: 'a.css', line: 3, column: 1, endLine: 3, endColumn: 4 }

    Parameters

    • line: number

      Line for inclusive start position in input CSS.

    • column: number

      Column for inclusive start position in input CSS.

    • Optional endLine: number

      Line for exclusive end position in input CSS.

    • Optional endColumn: number

      Column for exclusive end position in input CSS.

    Returns false | FilePosition

    Position in input source.