Upon trying to typeset the following TeX I get the error:
Too many }'s. …handleClick } >Button component}
TeX:
\lstinline{<Button onClick=\{this.handleClick\}>Button component</Button>}
What am I doing wrong?
braceserrorslistings
Upon trying to typeset the following TeX I get the error:
Too many }'s. …handleClick } >Button component}
TeX:
\lstinline{<Button onClick=\{this.handleClick\}>Button component</Button>}
What am I doing wrong?
Best Answer
Using curly braces for the source code argument of
\lstinline
is marked as experimental in the documentation of packagelistings
. The normal form with a character to delimit the argument works without the need to escape braces inside the code:The expression
with or without the backslash does not work, because the source code argument is scanned in a special way as verbatim with changed category codes. The first
}
ends the argument:<Button onClick=\{this.handleClick\
the remaining part>Button component</Button>}
is set outside of\lstinline
and the closing curly brace without counterpart causes the error.