JavaScript and TypeScript syntax highlighting

I was thinking the same, somehow we have a problem with pipes in Qt 5.15, I should give a look at it…

This seems only to say that TEXMACS_HOME_PATH is not defined in the environment. You can try to set it (check a shell session in TeXmacs to see the correct value) and try manually again, but I guess that @jeroen is right.

The Shell session is also crashing… seems that only the Scheme session is able to run. I will try @jeroen suggestion (the generic tar.gz) today! Thanks for your support :+1:

2 Likes

I just had a look at the highlighting already in TeXmacs and there is in fact a JavaScript highlighter there as well. It just doesn’t seem to be very well accessible from the menus.

You can insert it either by doing \javascript-code followed by the Enter key, or you can insert a code block for another language (e.g. “Fortran code”) and then change the language to JavaScript from the toolbar.

2 Likes

Oh wow, yes, this is the result that I was looking for! And it looks even okay with added type annotations (TypeScript).

1 Like

There is still the issue of showing line numbers, for which there are two solutions none of which I have tried myself


How to add line numbering? (refers to https://savannah.nongnu.org/projects/fangle)

1 Like

For code blocks you could also use \numbered

2 Likes

Today I installed the generic package of TeXmacs and everything works now! Thanks a lot for your support! TeXmacs is a great software :+1:

2 Likes

can anyone help me to get it working
I get “Busy…” all the time

Can you be more specific? What is the operation that you are performing? I guess there should be some problem running Python maybe? We also need to know the OS and the version of TeXmacs.

You could also try running a Python session, to see if TeXmacs can find your Python executable.

From there, try “import pygments”. It could be that TeXmacs uses a different Python than the one for which you have installed Pygments.

But some more details are definitely necessary.

I had the same problem and was able to avoid it by installing the generic TeXmacs package, see my answer above.

thanks for reply!

here some informations:

  • OS: macOS
  • TexMacs version: 2.1.1

I can use a python session in TexMacs (Executable > Python)
there I can run a "print(“hello world”), but when I try to execute
“import pygments”, it is telling me that there is no module called “import pygments”

but pygements is already installed:
“Requirement already satisfied: pygments in /opt/homebrew/lib/python3.9/site-packages (2.11.2)”

I installed TexMacs with brew and by downloading the dmg

where can I get the “generic package of TeXmacs” ?

hope that helps

On Mac there are several versions of python installed usually. You would have to be sure that you installed pygments for the python system that got run by TeXmacs. Maybe TeXmacs picks up the system python while you installed pygments for the Homebrew’s python installation.

here is what I have so far:

I created a python executable
(Insert > Fold > Executable > Python)

There I added this code:

import sys
print(sys.version)

output:

3.8.9 (default, Oct 26 2021, 07:25:54) 
[Clang 13.0.0 (clang-1300.0.29.30)]

On another python executable I did this:

import pip
pip.main(['install', 'pygments'])

output:

WARNING: pip is being invoked by an old script wrapper. This will fail in a future version of pip.
Please see https://github.com/pypa/pip/issues/5599 for advice on fixing the underlying issue.

To avoid this problem you can invoke Python with '-m pip' instead of running pip directly.
WARNING: The script pygmentize is installed in '/Users/peter/Library/Python/3.8/bin' which is not on PATH.

Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.

WARNING: You are using pip version 20.2.3; however, version 22.0.4 is available.
You should consider upgrading via the '/Library/Developer/CommandLineTools/usr/bin/python3 -m pip install --upgrade pip' command.

In the OS-Terminal I executed this:

python3 -m pip install --upgrade pip

output:

DEPRECATION: Configuring installation scheme with distutils config files is deprecated and will no longer work in the near future.
If you are using a Homebrew or Linuxbrew Python, please see discussion at https://github.com/Homebrew/homebrew-core/issues/76621

Requirement already satisfied: pip in /opt/homebrew/lib/python3.9/site-packages (22.0.4)
DEPRECATION: Configuring installation scheme with distutils config files is deprecated and will no longer work in the near future.

If you are using a Homebrew or Linuxbrew Python, please see discussion at https://github.com/Homebrew/homebrew-core/issues/76621

Not sure what to do next

Your output indicates indeed that TeXmacs is using a different version of Python (3.8) than what is used from the command line (3.9). You can check which one TeXmacs finds by doing (url-resolve-in-path (python-command)) in a Scheme session.

in a Scheme Session I used this:

(url-resolve-in-path (python-command))

output:

Scheme]  (url-resolve-in-path (python-command))

<url /usr/bin/python3>

what can I do next?

You can try to install pygments for the Python version that TeXmacs uses:

/usr/bin/python3 -m pip install pygments
1 Like

I installed pyenv and this solved my problem

there is another problem, and thats the line breaks
all of them are ignored

can anyone help out?

I made some changes to the plugin recently, did you pull the most recent commits?

If yes, please share the input you inserted and I’ll have a look.