Is there a way to use TeXmacs/Mogan in a modular manner?

By the title I mean, that when I build TeXmacs/Mogan, I will get the following:

  1. a CLI executable that can run without X11 and consume a TeXmacs source file and output a PDF/HTML/TeX/… document.
  2. a CLI executable which converts LaTeX source to TeXmacs source
  3. a GUI executable, with which I can edit documents and manipulate them by calling the first executable.

I think this modularity and flexibility would benefit both the developers and the users.

  1. a CLI executable that can run without X11 and consume a TeXmacs source file and output a PDF/HTML/TeX/… document.

tm2html, tm2pdf, … is under development in Mogan, here is the entry of tm2html: https://github.com/XmacsLabs/mogan/blob/branch-1.2/xmake/tm2html.lua

Quite a coincidence, TeXmacs has just received the capability to run in without GUI for conversions, just before the 2.1.4 release, so your wish is already fulfilled! The official builds for this new release should be available soon.

Meanwhile you can get unofficial v 2.1.4 builds for linux as an AppImage or packaged for several distros, or for windows, but not macOS, sorry.

2 Likes

Awsome, I’ll try it now.

And another question:

The tm files is some kind XML-like, i.e., structured data. Is it possible to get the position information(a rectangle) for each node in the tm files where it will be placed when compiled to PDF files?

like, given this node:

  <\with|par-columns|2>
    GNU TeXmacs is a free wysiwyw (what you see is what you want) editing
    platform with special features for scientists. The software aims to
    provide a unified and user friendly framework for editing structured
    documents with different types of content (text, graphics, mathematics,
    interactive content, etc.). The rendering engine uses high-quality
    typesetting algorithms so as to produce professionally looking documents,
    which can either be printed out or presented from a laptop. GNU TeXmacs
    is a free wysiwyw (what you see is what you want) editing platform with
    special features for scientists. The software aims to provide a unified
    and user friendly framework for editing structured documents with
    different types of content (text, graphics, mathematics, interactive
    content, etc.). The rendering engine uses high-quality typesetting
    algorithms so as to produce professionally looking documents, which can
    either be printed out or presented from a laptop.
  </with>

I can get something like this:

{
page: 1,
left_top: [20, 30],
size: [300, 500]
}

Thank you.

I just tried the headless mode with the -C option, basically it works well, but this headless mode still requires an X server:

./texmacs-latest-x86_64.AppImage -h
WARNING: CPU random generator seem to be failing, disable hardware random number generation
WARNING: RDRND generated: 0xffffffff 0xffffffff 0xffffffff 0xffffffff
qt.qpa.xcb: could not connect to display 
qt.qpa.plugin: Could not load the Qt platform plugin "xcb" in "" even though it was found.
This application failed to start because no Qt platform plugin could be initialized. Reinstalling the application may fix this problem.

Available platform plugins are: xcb.

Aborted (core dumped)

Can this restriction be removed?

The scheme function box-info gives the coordinates of the rectangle where a piece (a subtree) of a tm document is typeset (read about boxes in the documentation). So it is definitely possible, but you’ll need to hack in scheme, understand how to navigate the document tree, etc.

That is also certainly possible by hacking and rebuilding TeXmacs so that it would only run headless.

Could you explain in more detail? What prevents the separation between the export to pdf function and the windowing system?

Nothing. The error is about qt complaining it cannot load some module for GUI output. I have not looked into it in details and I guess it’s because when the code was compiled with a dependency on that module it checks it at startup even if it won’t actually be used in that headless mode. If this assumption is correct, recompiling without that explicit dependency would fix that. In any case, I’m confident that should be fixable by hacking a bit.

How do you run texmacs -C? I can run it under TTY where DISPLAY is not set.

2 Likes

I used the AppImage like this:

$ ./texmacs-latest-x86_64.AppImage -c demo.tm demo.pdf
WARNING: CPU random generator seem to be failing, disable hardware random number generation
WARNING: RDRND generated: 0xffffffff 0xffffffff 0xffffffff 0xffffffff
qt.qpa.xcb: could not connect to display
qt.qpa.plugin: Could not load the Qt platform plugin "xcb" in "" even though it was found.
This application failed to start because no Qt platform plugin could be initialized. Reinstalling the application may fix this problem.

Available platform plugins are: xcb.

Aborted (core dumped)

Oh sorry, I mistyped the -C option as -c, I changed it to -C it works now, thank you.