bartp5 / libtexprintf

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

Support more constructs #6

Closed larseggert closed 1 year ago

larseggert commented 1 year ago

I would love to give up https://github.com/larseggert/asciiTeX for this! But I think it's still missing a bunch of features that we'd need for IETF documents. A bunch of the examples in https://github.com/larseggert/asciiTeX/tree/main/examples throw errors. Are you planning on adding support for more constructs?

bartp5 commented 1 year ago

I looked through your examples and how libtexprintf handles them. eq6.tex: you use '\-', and in the example output it turned into a hyphen. I am unfamiliar with this command, should it produce a hyphen or a minus sign? eq8: That is a proper bug. It seems libtexprintf cannot handle the nested arrays. I'll have to fix that. eq10.tex: The \mathrm{} command is unknown. I suppose I could easily add it as an alias for \text{} eq12.tex/eq14.tex/eq15.tex: I feel the '\\' on the last lines of the array environments are wrong, it starts a new row but then nothing comes. That is why libtexprintf throws an error, i.e. that was intentional. If you remove the last '\\' in these array environments, all is fine. eq17.tex: libtexprintf does not know the \binom{}{} command. I suppose that could be added with with not too much effort.

larseggert commented 1 year ago

eq6.tex: you use '-', and in the example output it turned into a hyphen. I am unfamiliar with this command, should it produce a hyphen or a minus sign?

I actually don't know - many of these examples are taken from other documents.

eq12.tex/eq14.tex/eq15.tex: I feel the '\' on the last lines of the array environments are wrong, it starts a new row but then nothing comes. That is why libtexprintf throws an error, i.e. that was intentional. If you remove the last '\' in these array environments, all is fine.

That may be, but shouldn't they just be ignored as other tools do?

bartp5 commented 1 year ago

I pushed a new branch (dev). If fixes (at least for me) all your issues. I tried this '\-' thing in a latex file and it did not throw an error. However, I could not see any difference in output either (i.e. it does not render a minus sign, hyphen, or space. I do not know what it is supposed to do. To mimic my latex I implemented it as a dummy command. So this renders things differently from your example files but does not throw an error anymore.

larseggert commented 1 year ago

Excellent! I think we're getting close. I have a one more test cases that fails:

\begin{array}{lll}

ssthresh = &
flight\_size * β_{cubic} &
\text{new } ssthresh \\

cwnd_{prior} = &
cwnd &
\text{save } cwnd \\

cwnd = &
\left\{
\begin{array}{l}
\mathrm{max}(ssthresh, 2) \\
\mathrm{max}(ssthresh, 1) \\
\end{array}
\right. &
\begin{array}{l}
\text{reduction on loss}, cwnd \text{ is at least 2 MSS} \\
\text{reduction on ECE}, cwnd \text{ is at least 1 MSS} \\
\end{array}
\\

ssthresh = &
\mathrm{max}(ssthresh, 2) &
ssthresh \text{ is at least 2 MSS} \\

\end{array}

says "ERROR: Unequal number of columns in different rows (1x)"

larseggert commented 1 year ago

PS: PR to switch the IETF toolchain over to libtexprintf is at https://github.com/cabo/kramdown-rfc/pull/186

bartp5 commented 1 year ago

I pushed a fix.

larseggert commented 1 year ago

Thank you! I'll report more issues if I encounter any. I'm the meantime, are you planning to cut a new release soon?

bartp5 commented 1 year ago

If it works for you I'll close this issue and do a release. Cheers

larseggert commented 1 year ago

Perfect, thanks!

larseggert commented 1 year ago

@bartp5 the 1.15 release is missing a libtexprintf-1.15.tar.gz?

bartp5 commented 1 year ago

For convenience I attached a libtexprintf-1.15.tar.gz, including the configure script and all.

Ps. A source archive was there but it did not contain the configure script. To get that you would have to have autotools installed and then run the autogen script.