Adjustable greed in math parsing?

To prove this point – you could (although I don’t recommend it) change the f_n(x) behavior like this:

// replace all attach occurrences (a_b, a^b, etc.)
#show math.attach: it => {
  // we'll need the sequence content type
  let sequence = [].func()
  
  // extract base and bottom attachment
  let (base, b, ..fields) = it.fields()
  // if the bottom attachment is not of the form b(c), don't do anything
  if b == none or b.func() != sequence or b.children.len() != 2 or b.children.last().func() != math.lr {
    return it
  }

  // separate b and (c)
  let (b, next) = b.children
  // recombine to the form a_b (c)
  $attach(base, b: #b, ..fields)next$
}

$f_n(x)$

(made this recently on Discord for someone else)

But adding outright parsing customization, apart from being hard to pull off and definitely impacting performance, seems like it would be too much.

2 Likes