bartp5 / libtexprintf

Library providing printf-style formatted output routines with tex-like syntax support.
GNU General Public License v3.0
27 stars 2 forks source link

\% is not supported and breaks things #27

Closed mementum closed 4 months ago

mementum commented 5 months ago

\% is not supported.

Example:

utftex 'A = 25\% \frac{b}{c}'

        b
A = 25

Without the \%

utftex 'A = 25 \frac{b}{c}'

       b
A = 25 ─
       c
bartp5 commented 5 months ago

I cannot reproduce your issue. Actually libtexprintf does not handle a % as a special character at all (at this point I do not consider this a bug, but it could be, if there is a use case for comments within the context of libtexprintf). Anyway, I get: utftex 'A = 25\% \frac{b}{c}' b A = 25% ─ c Just the same as leaving out the slash: utftex 'A = 25% \frac{b}{c}' b A = 25% ─ c

mementum commented 5 months ago
  / / / /_  __/ ____/_  __/__ | |/ /
 / / / / / / / /_    / / / _ \|   /
/ /_/ / / / / __/   / / /  __/   |
\____/ /_/ /_/     /_/  \___/_/|_|
This is utftex version 1.16
Powered by libtexprintf 1.25

Given I use the latest release and the patches I see after that do not seem touch that area I wonder if environmental issues are in place. I have tried changing fonts and LANG but with no success.

I will try some more things.

Thanks for looking into it.

stevengj commented 4 months ago

Could it be a shell thing? i.e. maybe your shell is doing something funny with the \% before it gets to utftex

bartp5 commented 4 months ago

Are you by any chance on windows? The windows shell requires a % character to be escaped even in a quoted string. The proper escape would be '%%'.

mementum commented 4 months ago

bash and the input string is quoted with ' to avoid any shell substitution.

I will compile the latest sources and see what happens.

bartp5 commented 4 months ago

bash on windows, right? At least I can reproduce your issue on a windows box. Not sure what happens. I can get the '%' if I escape with %% but the output after the % character is still gone. The number of lines in the output is correct though! Somehow, beyond the '%', only the end-line characters make it to stdout. Intermediate results are also correct, i.e. the string is parsed correctly and all data structures are fine. The problem pops up either when generating the output string, or when sending this string to stdout. I will see if I can figure out more in the coming days (unfortunately I cannot reproduce it with wine, so I need access to an actual windows machine to debug this).

mementum commented 4 months ago

bash on Ubuntu 22.04

I have cloned the repository, compiled the current HEAD and it works

./src/utftex -- 'a = 25\% \times \frac{a}{b}'
         a
a = 25% ×─
         b      
mementum commented 4 months ago

I have then checked out the official 1.25 at 399d8e7 and the result is ...

./src/utftex -- 'a = 25\% \times \frac{a}{b}'
         a
a = 25

One of the commits in between HEAD and the tag 1.25 cures the problem.

bartp5 commented 4 months ago

I see the bug. It was fixed in commit 8a3f061239ac12e5c7c3fba875605a63441a8d6f. I should push out a new release..

bartp5 commented 4 months ago

Thanks!