beancount
    Preparing search index...

    Function parse

    • Parses a complete Beancount file string into a ParseResult containing Entry objects.

      This is the main entry point for parsing Beancount files. It handles:

      • Splitting the input into individual entries
      • Parsing each entry into its appropriate type
      • Managing the tag stack for pushtag/poptag directives
      • Applying tags from the stack to transactions

      Parameters

      • input: string

        The complete Beancount file content as a string

      • options: ParseOptions = {}

        Optional parsing configuration

        Options for configuring the parse function behavior.

        • OptionalskipBlanklines?: boolean

          If true, blank lines in the input are skipped and not included in the result. If false, blank lines are preserved as Blankline entries. Defaults to true.

      Returns ParseResult

      A ParseResult instance containing all parsed entries

      This is the primary function you'll use from this library. It takes a Beancount file as a string and returns a structured ParseResult object containing all parsed entries.

      Basic usage:

      import { parse } from 'beancount'

      const content = `
      2024-01-01 open Assets:Checking
      2024-01-02 * "Payee" "Narration"
      Assets:Checking 100.00 USD
      Income:Salary -100.00 USD
      `

      const result = parse(content)
      // result.entries contains parsed Entry objects

      With options:

      // Preserve blank lines in output
      const result = parse(content, { skipBlanklines: false })