loosing curly brackets

I am writing a piece of Ocaml code which scans html, using
All is fine so far, except fir one particular element which contains curly brackets { and }. To be more specific, the element is:
<span>(page \pageref{listpro})</span>
analysis of the tree built by markup shows that the element has three children containing text elements (page \pageref, listpro and )!!
I have other instances of elements containing curly brackets which do not cause problems.
Am I missing something ??
Thanks for your help.

Its not clear what your three childrens are in:

(page \pageref, listpro and )!!


The three elements are :

  • (page
  • \pageref, listpro
  • )

Can you post a minimal reproducible example with the error message so that we can investigate ?