Skip to content

PowerShell curly braces and newlines #1579

Closed
@alehaa

Description

Name of the lexer
powershell

Code sample

Select-Object -Property `
    Id,
    @{
        Name       = 'Test'
        Expression = {
            # To avoid errors (as we check for them later in the script), only
            # parse the string if it's a non-empty.
            if (![String]::IsNullOrEmpty($_.Expires)) {
                [DateTime]::ParseExact($_.Expires, $dateFormat, $null)
            }
        }
    }

Sample on rouge.jneen.net.

Additional context
Newlines between curly braces confuse the lexer, so its contents will not be recognized properly (e.g. the comment in the sample above is not highlighted as comment).

Metadata

Assignees

No one assigned

    Labels

    bugfix-requestA request for a bugfix to be developed.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions