Skip to content

Parse setting macros like lineskip #111

Description

@rrrnld

How would I parse macros like this?

\topskip=40pt
\parskip=10pt
\parindent=0pt
\baselineskip=15pt

I have tried this:

const macrosWithSetting: {
  signature?: string
  argumentParser: ArgumentParser
} = {
  argumentParser: (nodes, startPos) => {
    // parses things like `\lineskip=-\baselineskip`
    // nodes[startPos] is the equality sign
    const value = nodes[startPos + 1]
    const args = [
      value, // value or "-"
      ...(value.type === 'string' && value.content === '-' // actual value if value === '-'
        ? [nodes[startPos + 2]]
        : []),
    ].map((n) => arg(n))
    return {
      args,
      nodesRemoved: args.length,
    }
  },
}

But it doesn't to collect the arguments / remove them from the AST.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions