blefloch / latex-unravel

Watching TeX digest tokens
25 stars 1 forks source link

\scantokens should not use \tl_set_rescan:Nnn but rather lower-level code #62

Open blefloch opened 9 months ago

blefloch commented 9 months ago

Currently \scantokens relies on the \tl_set_rescan:Nnn function, but just like \use:x this command uses internal storage, so it is quite dangerous if the user's code itself contains the same function or others using this internal storage. In addition, \tl_set_rescan:Nnn tries to be clever with newlines, which makes it behave slightly differently to \scantokens itself.

The correct approach is to reimplement the little we need in unravel. While doing that we should be very careful about the trailing new line and about dealing with \everyeof.