[main]Notes on TeXmacs

Development resources and ideas

This page contains idea and resources pertaining to the development of TeXmacs.

[Last update 21.4.2022]

1.Random and unsorted resources

2.Syntax highlighting

We need syntax highlighting computations when rendering verbatim code snippets and also when exporting to HTML, for example. Currently there is some parsing library written in C++ inside TeXmacs (see the src/System/Language directory), but this does not cover HTML output and it is quite rudimentary. In this blog for example we achieve syntax-highlighting for HTML via an external JavaScript library. It would be useful just to output the appropriate elaborated text (together with a plain-text version for copy/paste). In general it could be maybe interesting to evaluate the use of external libraries for syntax analysis of programming languages.

3.Parsing Markdown and other languages

It could be useful for us to be able to parse the Markdown format. There are various available parsers which could be integrated as plugins in the codebase, for example PEG-markdown, sundown, libsoldout, md4c and also some native scheme implementations like lowdown for Chicken Scheme. Currently in TeXmacs we do not have a generic way to parse external languages: for example internally the parsing of HTML or TeX is done via C++ code without any common parsing substrate (as far as I can see). There is some support for packrat parsing but it is used only in the semantic checking of math formulas and it seems that the packrat parser is not capable of semantic actions, i.e. can only report if a string (or tree?) belongs to some language or not. Tree-sitter could also be an option as generic parsing mechanism. It could be useful to think how to factor and restructure the parsing mechanisms in TeXmacs to avoid duplicating code/efforts/know-how.

4.Spellchecking and grammar-checking

This could be an area where we can improve substantially over LaTeX-based workflows, probably. We need to check what is done in other text-processing software. Some interesting resources

5.General plugin mechanisms

A strategical goal would be to improve support for general mechanisms to talk to external programs:

6.General attachments to documents and to PDF files

In some circumstances it is useful to transmit both a PDF version of a document and the associated TeXmacs file (eventually with all the needed support files like custom styles and images). This allow usual PDF viewers to open the file and at the same time allows users of TeXmacs to be able to retrieve an editable version of the document for modification. It is useful to augment PDF with additional information to improve the user experience on a variety of platforms which do not allow to access the original TeXmacs documents. The PDF format gives the possibility to embed arbitrary content within the document as “Embedded file” streams. This possibility is exploited by the LaTeX package attachfile which allows to associate to typesetted parts of the document arbitrary attachments with the possibility to recover it. We could introduce a similar features in TeXmacs. Various possible directions:

Useful links

7.Zotero integration

Zotero is a widely used open source bibliographic management tool. It would be interesting to have a good way to import bibliography items from it. There are already various attemps to this:

We maybe want to develop a more organic solution. Interesting links:

8.Incremental computing

Modifications to the documents are incremental, so one would like to take this into account when recomputing both the typesetting and the rendering onscreen. This problem is also relevant when syncronizing live-editing document across a network connection. Some infrastructure is already present in TeXmacs (details?). Here are gathered some approaches to incremental computations in a general context.

9.Peer-to-peer collaboration

What: Help improve the collaborative features of TeXmacs, in particular add user cursors to the live documents and improve performance or add peer-to-peer infrastructure to the live document handling.

Why: TeXmacs has already collaborative capabilities. See e.g. the support in $TEXMACS_PATH/progs/server and $TEXMACS_PATH/progs/client.

We support live documents, chat rooms and shared file server. However these features are still experimental and need testing, some more security handling (authentication, etc…), etc… and they depends on a central server (another TeXmacs instance) which should be publicly visible on the Internet (i.e. have its own IP address).

How: Various directions are possible:

Some references:

10.OpenType math font support

What: Add support for OpenType MATH table & related font features (https://learn.microsoft.com/en-us/typography/opentype/spec/math 1)

investigate the possibility to remove the old TeX fonts and only use modern OpenType font containers (at least for the default fonts).

Why: At the moment TeXmacs is able to use only very few math fonts (like Stix, TeX Gyre) and this support is hardwired in the C++ files and does not take into account all the informations available in the font files.

These fonts file contain the position in the font of extensible brackets or extensible glyphs like arrows, square roots, etc…, and the metrics to correctly position index and subscripts.

Some time ago mgubi started to implement some OpenType font support for TeXmacs, here: https://github.com/mgubi/texmacs/tree/wip-unicode-math 2

TeXmacs still depends very much on old font formats while there are now available many free fonts in OpenType format which make it easier to support professional math typesetting. In particular there are Latin Modern fonts which can replace our old TeX fonts, and possibly improve speed since there will be less font searching.

One side goal could be to get rid of all TeX fonts and distribute only the OpenType variants. This is for example what ConTeXt does.:

https://wiki.contextgarden.net/ConTeXt_distribution's_Fonts 1

For a discussion see here: https://github.com/XmacsLabs/mogan/issues/523 1

How: Study and document the font selection mechanism in TeXmacs, in particular how math glyphs are selected from the various fonts. Possibly write some debugging tools which allow developers to check the workings of which glyphs are selected, which metrics used, etc…

Complete and debug the initial implementation of the MATH table parser here: https://github.com/mgubi/texmacs/tree/wip-unicode-math

A discussion is taking place in the forum here.