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

add texsymbols_str #15

Closed Suavesito-Olimpiada closed 1 year ago

Suavesito-Olimpiada commented 1 year ago

This adds a new API function char *texsymbols_str(), which return a formatted list of command:symbol; which need to be freed with texfree.

I added this functionality to be able to call it as a library in a higher-level language (from LibTeXPrintf.jl), because it is tricky and unreliable to capture stdout output. cc @stevengj

Also added a small test script testtexsymbols.sh that check the first two symbols, in principle I would like to check all of them, but if the order or some are added/deleted it won't work.

bartp5 commented 1 year ago

I think we should check all symbols. I do not expect we will often change the symbol table. If we do it should be deliberate and we can generate a new reference table for the test.

Suavesito-Olimpiada commented 1 year ago

Perfect, I'll update it accordingly.

stevengj commented 1 year ago

Seems like it would be nicer to simply export the Symbols array?

Suavesito-Olimpiada commented 1 year ago

I thought about it, but I want to have the same rendering of symbols from the lib without needing to change something in the Julia side if the lib is updated (maybe more effort than needed, as the only thing affecting this is the dotted circle for substitution).

stevengj commented 1 year ago

I thought about it, but I want to have the same rendering of symbols from the lib

It's just a table mapping LaTeX names to unicode codepoints. Why does the caller need it in a particular text format?

(Julia has an even bigger table that it might be useful to crib a few more symbols from here.)

Suavesito-Olimpiada commented 1 year ago

I also added access to Symbols.

Suavesito-Olimpiada commented 1 year ago

Fixed that texstring was not exported in the shared library.

bartp5 commented 1 year ago

I wrote a script to generate the list of symbols to export from texprintf.h (it is not the first time it was forgotten to add new symbols to the list). Cheers!