artisticat1 / obsidian-tikzjax

Render LaTeX and TikZ diagrams in your notes
MIT License
454 stars 27 forks source link

Building with patched tikzjax.js #11

Open LivingCodeX opened 2 years ago

LivingCodeX commented 2 years ago

I am currently trying to build the plugin but whenever I try to display a block of TikZ code, I get an error and the graphic only gets displayed if it has been cached before. I would like to be able to use a patched tikzjax.js in order to add, replace and remove packages.

The steps I took for building the plugin:

  1. Clone artisticat1/tikzjax and switch to output-single-file branch
  2. Run 'npm install' and 'npm run build'
  3. Clone artisticat1/obsidian-tikzjax
  4. Copy tikzjax.js from artisticat1/tikzjax/dist to the root of artisticat1/obsidian-tikzjax
  5. Run 'npm install' and 'npm run build'
  6. Create new plugin directory in VAULT/.obsidian/plugins and copy main.js, manifest.json and styles.css into that directory

The error and debug messages

The second error message appears every time an uncached TikZ block tries to render.

artisticat1 commented 2 years ago

I'll look into this when I have time.

Does building the plugin with the pre-built tikzjax.js included in the repo work?

LivingCodeX commented 2 years ago

Yes it does and I actually found a fix for it: In run-tex.js loadDecompress, I had to change Buffer.from(gzippedString, 'base64') to Buffer.from(gzippedString.substring(29), 'base64') to strip the "data:application/gzip;base64," part of gzippedString. Now it builds your fork of tikzjax and obsidian-tikzjax successfully.

However, I have another question: Did you build tex.wasm and core.dump yourself? If so, is there anything special you have to do or keep in mind? If I follow the guide, I get an error when running "npm run initex" or "node initex.js". It fails with "! LaTeX Error: LaTeX requires the e-TeX primitives and additional functionality available in the engines".

artisticat1 commented 2 years ago

In run-tex.js loadDecompress, I had to change Buffer.from(gzippedString, 'base64') to Buffer.from(gzippedString.substring(29), 'base64') to strip the "data:application/gzip;base64," part of gzippedString.

I see! I'll look into including this fix in the repo.

However, I have another question: Did you build tex.wasm and core.dump yourself? If so, is there anything special you have to do or keep in mind? If I follow the guide, I get an error when running "npm run initex" or "node initex.js". It fails with "! LaTeX Error: LaTeX requires the e-TeX primitives and additional functionality available in the engines".

I did build them myself. I never encountered that error, though. I'm not certain what's gone wrong there but I'd try installing the full tex-live package (sudo apt install texlive-full) to ensure that no necessary files are missing.

LivingCodeX commented 2 years ago

I did build them myself. I never encountered that error, though. I'm not certain what's gone wrong there but I'd try installing the full tex-live package (sudo apt install texlive-full) to ensure that no necessary files are missing.

I have now set up a VM running Ubuntu 22.04 LTS and I have installed texlive-full along with some other dependencies like libkpathsea-dev and I either get the same error message if I set the variable TEXMFCNF in my shell or I get the error message "I can't read TEX.POOL". Would you mind sharing the operating system and the TeX Live version you were using to generate the core dump?

The funny thing is that I am able to generate a core dump on Raspberry Pi OS... Maybe it only works with an older version of tex? This method yields a core.dump of size 69M, core.dump.gz of size 4.0M, tex.wasm of size 501K and tex.wasm.gz of size 126K which looks accurate.

The problem with that is that when I build obsidian-tikzjax with that tex.wasm.gz and core.dump.gz and try do draw chemfig molecules in Obsidian, TikZJax is trying to load chemfig.sty, chemfig.tex and simplekv.tex (which are all available in tex_files) but also tikz.tex which is a mistake because it should already be loaded because of the core dump and it is not even available in tex_files. If I include a copy of tikz.tex in tex_files, it complains about even more missing tex files which tikz.tex is most likely trying to load. Using this method, the molecules don't render.

If I use your tex.wasm.gz and core.dump.gz, tikz.tex isn't trying to be loaded. Instead, pgflibraryarrows.meta.code.tex is loaded and the molecules render just fine.

Do you have any idea why this is happening? Did you do anything special with the tex.wasm and core.dump you got from web2js? If not, would you mind writing a short and concise list of instructions to generate the core dump and what to do with it before building TikZJax with it?

artisticat1 commented 2 years ago

Thank you for the solution involving stripping data:application/gzip;base64,! I've now added this fix to my fork.

Would you mind sharing the operating system and the TeX Live version you were using to generate the core dump?

I generated the core.dump on Ubuntu 20.04.2 LTS, running on WSL. Unfortunately I've since updated my installation and I don't remember what version of TeX Live I was running.

Actually, since updating (to Ubuntu 22.04 LTS), I'm also no longer able to generate the core.dump, failing with the error

**Sorry, I can't find that format; will try PLAIN.
I can't find the PLAIN format file!

when running node initex.js.

Do you have any idea why this is happening? Did you do anything special with the tex.wasm and core.dump you got from web2js? If not, would you mind writing a short and concise list of instructions to generate the core dump and what to do with it before building TikZJax with it?

No idea, sorry! No, I didn't do anything special at all to generate tex.wasm or core.dump, or modify them after generation. I only followed the instructions in the readme, and did a lot of troubleshooting when errors arose.

This included

It sounds like you've already done the first two, and the last wasn't necessary in your case.

Is there a particular reason you want to generate your own tex.wasm and core.dump?

LivingCodeX commented 2 years ago

Thank you for the solution involving stripping data:application/gzip;base64,! I've now added this fix to my fork.

No problem, I am glad that I can contribute to this project since I plan on using this plugin a lot in the near future.

installing different versions of binaryen until the wasm-opt command was able to run successfully.

I also had to do that on my Raspberry Pi because of the outdated repositories.

Actually, since updating (to Ubuntu 22.04 LTS), I'm also no longer able to generate the core.dump, failing with the error [...]

I think I had the exact same error message when I first tried it on Arch Linux. I guess there are some issues with the newer software that cause problems with web2js.

Is there a particular reason you want to generate your own tex.wasm and core.dump?

Yes, there is. In fact, I want to fix a known issue (latest version of chemfig not working) by updating tex.wasm and core.dump. I am not entirely sure if this would be a working solution, but I want to try it nonetheless or are the files provided on the repo already up-to-date?

Did you choose the latest working release of chemfig or did you just randomly pick an older version, it happened to work and you settled with it? Also, where did you obtain a copy of the older version?

artisticat1 commented 2 years ago

No problem, I am glad that I can contribute to this project since I plan on using this plugin a lot in the near future.

I see! Looking forward to your contributions.

Yes, there is. In fact, I want to fix a known issue (latest version of chemfig not working) by updating tex.wasm and core.dump. I am not entirely sure if this would be a working solution, but I want to try it nonetheless or are the files provided on the repo already up-to-date?

Oh, I see! Yes, I think updating tex.wasm and core.dump would solve the issue (and probably improve compatibility with other packages too). It's why I updated my installation in the first place. However, as you say, it seems there might be an issue that prevents us from generating the core.dump on newer software.

Did you choose the latest working release of chemfig or did you just randomly pick an older version, it happened to work and you settled with it? Also, where did you obtain a copy of the older version?

I chose the latest working version of chemfig. It's the last version that doesn't require the \expanded primitive according to CTAN.

I discovered that somebody uploaded an archive of TeX Live releases here: https://github.com/jfine2358/temp-texlive-texmf-dist-tex, and I found the older version of chemfig there.

benrbray commented 1 year ago

I made some progress on rebuilding core.dump. Whether or not the node initex.js script succeeds or fails seems to depend very much on which packages you have installed. It will fail if there are not enough packages, but it will also fail if there are too many. (I don't quite understand how web2js works, but this makes me think it is pulling in all available packages, which causes some problems. So we need to be careful not to install any of the "broken" packages.)

Working Dockerfile for web2js

The following Dockerfile works, in the sense that a tex.wasm and core.dump file are successfully created as part of the build process in the /code/web2js folder. I have not yet tested these files with tizkjax -- that will be the next step. I imagine using texlive instead of texlive-full omits some important packages that I will need to manually add back in in order for tikzjax to work.

FROM ubuntu:20.04

RUN apt update

RUN apt-get update && \
    apt-get install -yq tzdata && \
    ln -fs /usr/share/zoneinfo/Asia/Tokyo /etc/localtime && \
    dpkg-reconfigure -f noninteractive tzdata

RUN apt install -y make build-essential curl openssh-client git
RUN apt install -y libkpathsea-dev

#### TEXLIVE ###############################################

RUN apt install -y texlive
RUN apt install -y texlive-latex-extra

#### NODEJS ################################################

# needed for installing nvm (see https://stackoverflow.com/a/57344191/1444650)
SHELL ["/bin/bash", "--login", "-c"]

WORKDIR /code

# https://stackoverflow.com/a/57546198/1444650
ENV NODE_VERSION=16.16.0
RUN curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.3/install.sh | bash
ENV NVM_DIR=/root/.nvm
RUN . "$NVM_DIR/nvm.sh" && nvm install ${NODE_VERSION}
RUN . "$NVM_DIR/nvm.sh" && nvm use v${NODE_VERSION}
RUN . "$NVM_DIR/nvm.sh" && nvm alias default v${NODE_VERSION}
ENV PATH="/root/.nvm/versions/node/v${NODE_VERSION}/bin/:${PATH}"
RUN node --version
RUN npm --version

#### WEB2JS ################################################

# clone web2js and switch to ww-modifications branch
RUN git clone https://github.com/drgrice1/web2js.git
WORKDIR /code/web2js
RUN git checkout d78ef1f3ec94520c88049b1de36ecf6be2a65c10

# switch to https:// protocol because github deprecated git://
# https://github.com/npm/cli/issues/4896#issuecomment-1128472004
RUN npm install --save https://github.com/kisonecat/node-kpathsea.git
RUN npm install --save-dev wasm-opt

# generate tex.wasm and core.dump files
RUN npm install --loglevel verbose
RUN npm run build
RUN npm run generate-wasm
RUN ./node_modules/wasm-opt/bin/wasm-opt --asyncify --pass-arg=asyncify-ignore-indirect --pass-arg=asyncify-imports@library.reset -O4 out.wasm -o tex.wasm
RUN node initex.js

Details of Debugging

I was lucky enough to have a pre-existing install of texlive on my machine for which I could successfully compile web2js and produce the core.dump, but I don't at all remember how I installed texlive so my goal was to write a reproducible Dockerfile.

As far as I can tell, the versions are the same both locally and in the container:

# local
$ tex --version
TeX 3.14159265 (TeX Live 2019/Debian)
kpathsea version 6.3.1
Copyright 2019 D.E. Knuth.
There is NO warranty.  Redistribution of this software is
covered by the terms of both the TeX copyright and
the Lesser GNU General Public License.
For more information about these matters, see the file
named COPYING and the TeX source.
Primary author of TeX: D.E. Knuth.
# docker container
$ tex --version
TeX 3.14159265 (TeX Live 2019/Debian)
kpathsea version 6.3.1
Copyright 2019 D.E. Knuth.
There is NO warranty.  Redistribution of this software is
covered by the terms of both the TeX copyright and
the Lesser GNU General Public License.
For more information about these matters, see the file
named COPYING and the TeX source.
Primary author of TeX: D.E. Knuth.

Initially, the Dockerfile used apt install texlive-full, but I noticed that the Docker container had quite a lot more packages than my local machine:

(local, building core.dump succeeds) installed tex packages
$ apt list --installed | grep tex
317:fonts-texgyre/focal,focal,now 20180621-3 all [installed,automatic]
388:gedit-plugin-synctex/focal,now 3.36.2-1 amd64 [installed,automatic]
397:gettext-base/focal,now 0.19.8.1-10build1 amd64 [installed,automatic]
398:gettext/focal,now 0.19.8.1-10build1 amd64 [installed,automatic]
875:libdjvulibre-text/focal-updates,focal-updates,focal-security,focal-security,now 3.5.27.1-14ubuntu0.1 all [installed,automatic]
942:libexttextcat-2.0-0/focal,now 3.4.5-1 amd64 [installed,automatic]
943:libexttextcat-data/focal,focal,now 3.4.5-1 all [installed,automatic]
1254:liblocale-gettext-perl/focal,now 1.07-4 amd64 [installed,automatic]
1356:libmono-system-data-datasetextensions4.0-cil/stable-focal,vs-focal,now 6.12.0.182-0xamarin1+ubuntu2004b1 all [installed,automatic]
1395:libmono-system-reflection-context4.0-cil/stable-focal,vs-focal,now 6.12.0.182-0xamarin1+ubuntu2004b1 all [installed,automatic]
1635:libptexenc1/focal,now 2019.20190605.51237-3build2 amd64 [installed,automatic]
1810:libsynctex2/focal,now 2019.20190605.51237-3build2 amd64 [installed,automatic]
1828:libtexlua53/focal,now 2019.20190605.51237-3build2 amd64 [installed,automatic]
1829:libtexluajit2/focal,now 2019.20190605.51237-3build2 amd64 [installed,automatic]
1830:libtext-charwidth-perl/focal,now 0.04-10 amd64 [installed,automatic]
1831:libtext-iconv-perl/focal,now 1.7-7 amd64 [installed,automatic]
1832:libtext-wrapi18n-perl/focal,focal,now 0.06-9 all [installed,automatic]
2258:plymouth-theme-ubuntu-text/focal-updates,now 0.9.4git20200323-0ubuntu6.2 amd64 [installed,automatic]
2270:preview-latex-style/focal,focal,now 11.91-2ubuntu2 all [installed,automatic]
2505:tex-common/focal,focal,now 6.13 all [installed,automatic]
2506:tex-gyre/focal,focal,now 20180621-3 all [installed,automatic]
2507:texlive-base/focal,focal,now 2019.20200218-1 all [installed]
2508:texlive-binaries/focal,now 2019.20190605.51237-3build2 amd64 [installed,automatic]
2509:texlive-extra-utils/focal,focal,now 2019.202000218-1 all [installed]
2510:texlive-fonts-extra-links/focal,focal,now 2019.202000218-1 all [installed,automatic]
2511:texlive-fonts-extra/focal,focal,now 2019.202000218-1 all [installed]
2512:texlive-fonts-recommended/focal,focal,now 2019.20200218-1 all [installed]
2513:texlive-lang-greek/focal,focal,now 2019.20200218-1 all [installed,automatic]
2514:texlive-latex-base/focal,focal,now 2019.20200218-1 all [installed,automatic]
2515:texlive-latex-extra/focal,focal,now 2019.202000218-1 all [installed]
2516:texlive-latex-recommended/focal,focal,now 2019.20200218-1 all [installed,automatic]
2517:texlive-pictures/focal,focal,now 2019.20200218-1 all [installed,automatic]
2518:texlive-plain-generic/focal,focal,now 2019.202000218-1 all [installed,automatic]
2519:texlive-science/focal,focal,now 2019.202000218-1 all [installed]
2520:texlive/focal,focal,now 2019.20200218-1 all [installed]
(docker, building core.dump fails) installed tex packages
$ apt list --installed | grep tex    

WARNING: apt does not have a stable CLI interface. Use with caution in scripts.

chktex/focal,now 1.7.6-3 amd64 [installed,automatic]
context-modules/focal,now 20190710-1 all [installed,automatic]
context/focal,now 2019.03.21.20190425-2 all [installed,automatic]
fonts-texgyre/focal,now 20180621-3 all [installed,automatic]
latex-cjk-all/focal,now 4.8.4+git20170127-2 all [installed,automatic]
latex-cjk-chinese-arphic-bkai00mp/focal,now 1.23 all [installed,automatic]
latex-cjk-chinese-arphic-bsmi00lp/focal,now 1.23 all [installed,automatic]
latex-cjk-chinese-arphic-gbsn00lp/focal,now 1.23 all [installed,automatic]
latex-cjk-chinese-arphic-gkai00mp/focal,now 1.23 all [installed,automatic]
latex-cjk-chinese/focal,now 4.8.4+git20170127-2 amd64 [installed,automatic]
latex-cjk-common/focal,now 4.8.4+git20170127-2 amd64 [installed,automatic]
latex-cjk-japanese-wadalab/focal,now 0.20050817-17 all [installed,automatic]
latex-cjk-japanese/focal,now 4.8.4+git20170127-2 amd64 [installed,automatic]
latex-cjk-korean/focal,now 4.8.4+git20170127-2 all [installed,automatic]
latex-cjk-thai/focal,now 4.8.4+git20170127-2 all [installed,automatic]
latexdiff/focal,now 1.3.0-2 all [installed,automatic]
latexmk/focal,now 1:4.67-0.1 all [installed,automatic]
libdjvulibre-text/focal-updates,focal-security,now 3.5.27.1-14ubuntu0.1 all [installed,automatic]
liblocale-gettext-perl/focal,now 1.07-4 amd64 [installed,automatic]
libptexenc1/focal,now 2019.20190605.51237-3build2 amd64 [installed,automatic]
libsynctex2/focal,now 2019.20190605.51237-3build2 amd64 [installed,automatic]
libtexlua53/focal,now 2019.20190605.51237-3build2 amd64 [installed,automatic]
libtexluajit2/focal,now 2019.20190605.51237-3build2 amd64 [installed,automatic]
libtext-bibtex-perl/focal,now 0.88-3build1 amd64 [installed,automatic]
libtext-csv-perl/focal,now 2.00-1 all [installed,automatic]
libtext-csv-xs-perl/focal,now 1.41-1 amd64 [installed,automatic]
libtext-glob-perl/focal,now 0.10-1 all [installed,automatic]
libtext-iconv-perl/focal,now 1.7-7 amd64 [installed,automatic]
libtext-roman-perl/focal,now 3.5-2 all [installed,automatic]
libtext-unidecode-perl/focal,now 1.30-1 all [installed,automatic]
preview-latex-style/focal,now 11.91-2ubuntu2 all [installed,automatic]
tex-common/focal,now 6.13 all [installed,automatic]
tex-gyre/focal,now 20180621-3 all [installed,automatic]
texinfo/focal,now 6.7.0.dfsg.2-5 amd64 [installed,automatic]
texlive-base/focal,now 2019.20200218-1 all [installed,automatic]
texlive-bibtex-extra/focal,now 2019.202000218-1 all [installed,automatic]
texlive-binaries/focal,now 2019.20190605.51237-3build2 amd64 [installed,automatic]
texlive-extra-utils/focal,now 2019.202000218-1 all [installed,automatic]
texlive-font-utils/focal,now 2019.202000218-1 all [installed,automatic]
texlive-fonts-extra-doc/focal,now 2019.202000218-1 all [installed,automatic]
texlive-fonts-extra-links/focal,now 2019.202000218-1 all [installed,automatic]
texlive-fonts-extra/focal,now 2019.202000218-1 all [installed,automatic]
texlive-fonts-recommended-doc/focal,now 2019.20200218-1 all [installed,automatic]
texlive-fonts-recommended/focal,now 2019.20200218-1 all [installed,automatic]
texlive-formats-extra/focal,now 2019.202000218-1 all [installed,automatic]
texlive-full/focal,now 2019.20200218-1 all [installed]
texlive-games/focal,now 2019.202000218-1 all [installed,automatic]
texlive-humanities-doc/focal,now 2019.202000218-1 all [installed,automatic]
texlive-humanities/focal,now 2019.202000218-1 all [installed,automatic]
texlive-lang-arabic/focal,now 2019.20200218-1 all [installed,automatic]
texlive-lang-chinese/focal,now 2019.20200218-1 all [installed,automatic]
texlive-lang-cjk/focal,now 2019.20200218-1 all [installed,automatic]
texlive-lang-cyrillic/focal,now 2019.20200218-1 all [installed,automatic]
texlive-lang-czechslovak/focal,now 2019.20200218-1 all [installed,automatic]
texlive-lang-english/focal,now 2019.20200218-1 all [installed,automatic]
texlive-lang-european/focal,now 2019.20200218-1 all [installed,automatic]
texlive-lang-french/focal,now 2019.20200218-1 all [installed,automatic]
texlive-lang-german/focal,now 2019.20200218-1 all [installed,automatic]
texlive-lang-greek/focal,now 2019.20200218-1 all [installed,automatic]
texlive-lang-italian/focal,now 2019.20200218-1 all [installed,automatic]
texlive-lang-japanese/focal,now 2019.20200218-1 all [installed,automatic]
texlive-lang-korean/focal,now 2019.20200218-1 all [installed,automatic]
texlive-lang-other/focal,now 2019.20200218-1 all [installed,automatic]
texlive-lang-polish/focal,now 2019.20200218-1 all [installed,automatic]
texlive-lang-portuguese/focal,now 2019.20200218-1 all [installed,automatic]
texlive-lang-spanish/focal,now 2019.20200218-1 all [installed,automatic]
texlive-latex-base-doc/focal,now 2019.20200218-1 all [installed,automatic]
texlive-latex-base/focal,now 2019.20200218-1 all [installed,automatic]
texlive-latex-extra-doc/focal,now 2019.202000218-1 all [installed,automatic]
texlive-latex-extra/focal,now 2019.202000218-1 all [installed,automatic]
texlive-latex-recommended-doc/focal,now 2019.20200218-1 all [installed,automatic]
texlive-latex-recommended/focal,now 2019.20200218-1 all [installed,automatic]
texlive-luatex/focal,now 2019.20200218-1 all [installed,automatic]
texlive-metapost-doc/focal,now 2019.20200218-1 all [installed,automatic]
texlive-metapost/focal,now 2019.20200218-1 all [installed,automatic]
texlive-music/focal,now 2019.202000218-1 all [installed,automatic]
texlive-pictures-doc/focal,now 2019.20200218-1 all [installed,automatic]
texlive-pictures/focal,now 2019.20200218-1 all [installed,automatic]
texlive-plain-generic/focal,now 2019.202000218-1 all [installed,automatic]
texlive-pstricks-doc/focal,now 2019.202000218-1 all [installed,automatic]
texlive-pstricks/focal,now 2019.202000218-1 all [installed,automatic]
texlive-publishers-doc/focal,now 2019.202000218-1 all [installed,automatic]
texlive-publishers/focal,now 2019.202000218-1 all [installed,automatic]
texlive-science-doc/focal,now 2019.202000218-1 all [installed,automatic]
texlive-science/focal,now 2019.202000218-1 all [installed,automatic]
texlive-xetex/focal,now 2019.20200218-1 all [installed,automatic]
example of failed core.dump build in docker container
root@071d5d05854a:/code/web2js# node initex.js
This is e-TeX, Version 3.14159265-2.6 (INITEX)
**entering extended mode
(latex.ltx (texsys.cfg)
./texsys.aux found

\@currdir set to: ./.

Assuming \openin and \input 
have the same search path.

Defining UNIX/DOS style filename parser.

catcodes, registers, parameters,
LaTeX2e <2020-02-02> patch level 2
hacks, control, par, spacing, files, font encodings, lengths,
====================================

Local config file fonttext.cfg used

====================================
("fonttext.cfg" ("fonttext.ltx"
=== Don't modify this file, use a .cfg file instead ===

("omlenc.def") ("omsenc.def") ("ot1enc.def") ("t1enc.def") ("ts1enc.def")
("ts1cmr.fd") ("t1cmr.fd") ("ot1cmr.fd") ("ot1cmss.fd") ("ot1cmtt.fd")))
====================================

Local config file fontmath.cfg used

====================================
("fontmath.cfg" ("fontmath.ltx"
=== Don't modify this file, use a .cfg file instead ===

("omlcmm.fd") ("omscmsy.fd") ("omxcmex.fd") ("ucmr.fd")))
====================================

Local config file preload.cfg used

=====================================
("preload.cfg" ("preload.ltx")) page nos., x-ref, environments, center,
verbatim, math definitions, boxes, title, sectioning, contents, floats,
footnotes, index, bibliography, output,
===========================================
Local configuration file hyphen.cfg used
===========================================
("hyphen.cfg" (switch.def) (hyphen.tex) (dumyhyph.tex) (zerohyph.tex)
(loadhyph-is.tex EC Icelandic hyphenation patterns (conv-utf8-ec.tex)
(hyph-is.tex)) (loadhyph-kn.tex
No Kannada hyphenation patterns - only for Unicode engines) (loadhyph-lt.tex
L7X Lithuanian hyphenation patterns (conv-utf8-l7x.tex) (hyph-lt.tex))
(loadhyph-eu.tex EC Basque hyphenation patterns (conv-utf8-ec.tex) (hyph-eu.tex
)) (loadhyph-cu.tex
No Church Slavonic hyphenation patterns - only for Unicode engines)
(loadhyph-nl.tex EC Dutch hyphenation patterns (conv-utf8-ec.tex) (hyph-nl.tex)
) (loadhyph-gu.tex No Gujarati hyphenation patterns - only for Unicode engines)
(loadhyph-ru.tex T2A Russian hyphenation patterns (ruhyphen.tex (catkoi.tex)
(koi2t2a.tex) (ruhyphal.tex) (cyryoal.tex) (hypht2.tex))) (loadhyph-cop.tex
Coptic hyphenation patterns (copthyph.tex)) (loadhyph-hr.tex
EC Croatian hyphenation patterns (conv-utf8-ec.tex) (hyph-hr.tex))
(loadhyph-sl.tex EC Slovenian hyphenation patterns (conv-utf8-ec.tex)
(hyph-sl.tex)) (zerohyph.tex) (loadhyph-da.tex EC Danish hyphenation patterns
(conv-utf8-ec.tex) (hyph-da.tex)) (loadhyph-sr-cyrl.tex
T2A Serbian hyphenation patterns in Cyrillic script (conv-utf8-t2a.tex)
(hyph-sh-cyrl.tex)) (loadhyph-mr.tex
No Marathi hyphenation patterns - only for Unicode engines)
(loadhyph-el-monoton.tex
Hyphenation patterns for uni-accent (monotonic) Modern Greek (grmhyph5.tex
Hyphenation patterns for uni-accent (monotonic) Modern Greek)) (loadhyph-ro.tex
 EC Romanian hyphenation patterns (conv-utf8-ec.tex) (hyph-ro.tex))
(loadhyph-bn.tex No Bengali hyphenation patterns - only for Unicode engines)
(loadhyph-sk.tex EC Slovak hyphenation patterns (conv-utf8-ec.tex) (hyph-sk.tex
)) (dehyphn-x-2019-04-04.tex dehyph-exptl: using an 8-bit TeX engine.
(dehyphn-x-2019-04-04.pat
German Hyphenation Patterns (Reformed Orthography, 2006) `dehyphn-x' 2019-04-04
 (WL))) (loadhyph-be.tex T2A Belarusian hyphenation patterns (conv-utf8-t2a.tex
) (hyph-be.tex)) (loadhyph-hsb.tex EC Upper Sorbian hyphenation patterns
(conv-utf8-ec.tex) (hyph-hsb.tex)) (loadhyph-de-1996.tex
EC German hyphenation patterns (reformed orthography) (dehyphn.tex
New German Hyphenation Patterns `dehyphn' Rev.31 <2001-05-07> (WaS)))
(loadhyph-pi.tex No Pali hyphenation patterns - only for Unicode engines)
(loadhyph-cy.tex EC Welsh hyphenation patterns (conv-utf8-ec.tex) (hyph-cy.tex)
) (loadhyph-id.tex ASCII Indonesian hyphenation patterns (hyph-id.tex))
(loadhyph-tk.tex EC Turkmen hyphenation patterns (conv-utf8-ec.tex)
(hyph-tk.tex)) (loadhyph-pa.tex
No Panjabi hyphenation patterns - only for Unicode engines) (loadhyph-tr.tex
EC Turkish hyphenation patterns (conv-utf8-ec.tex) (hyph-tr.tex))
(loadhyph-ka.tex T8M Georgian hyphenation patterns (conv-utf8-t8m.tex)
(hyph-ka.tex)) (loadhyph-cs.tex EC Czech hyphenation patterns (conv-utf8-ec.tex
) (hyph-cs.tex)) (loadhyph-mn-cyrl-x-lmc.tex
LMC Mongolian hyphenation patterns (conv-utf8-lmc.tex) (hyph-mn-cyrl-x-lmc.tex)
) (loadhyph-gl.tex EC Galician hyphenation patterns (conv-utf8-ec.tex)
(hyph-gl.tex)) (loadhyph-ml.tex
No Malayalam hyphenation patterns - only for Unicode engines)
(loadhyph-en-gb.tex ASCII Hyphenation patterns for British English
(hyph-en-gb.tex)) (loadhyph-fi.tex EC Finnish hyphenation patterns
(conv-utf8-ec.tex) (hyph-fi.tex)) (loadhyph-et.tex
EC Estonian hyphenation patterns (conv-utf8-ec.tex) (hyph-et.tex))
(dehypht-x-2019-04-04.tex dehyph-exptl: using an 8-bit TeX engine.
(dehypht-x-2019-04-04.pat
German Hyphenation Patterns (Traditional Orthography) `dehypht-x' 2019-04-04 (W
L))) (loadhyph-sv.tex EC Swedish hyphenation patterns (conv-utf8-ec.tex)
(hyph-sv.tex)) (loadhyph-la.tex EC Latin hyphenation patterns (conv-utf8-ec.tex
) (hyph-la.tex)) (loadhyph-hy.tex
No Armenian hyphenation patterns - only for Unicode engines) (loadhyph-nb.tex
EC Norwegian Bokmal hyphenation patterns (conv-utf8-ec.tex) (hyph-nb.tex
(hyph-no.tex))) (ibyhyph.tex
Greek hyphenation patterns for Ibycus encoding, v3.0) (loadhyph-pt.tex
EC Portuguese hyphenation patterns (conv-utf8-ec.tex) (hyph-pt.tex))
(loadhyph-el-polyton.tex
Hyphenation patterns for multi-accent (polytonic) Modern Greek (grphyph5.tex
Hyphenation patterns for multi-accent (polytonic) Modern Greek))
(loadhyph-or.tex No Oriya hyphenation patterns - only for Unicode engines)
(loadhyph-th.tex LTH Thai hyphenation patterns (conv-utf8-lth.tex) (hyph-th.tex
)) (loadhyph-as.tex
No Assamese hyphenation patterns - only for Unicode engines) (loadhyph-fur.tex
EC Friulan hyphenation patterns (conv-utf8-ec.tex) (hyph-fur.tex))
(loadhyph-kmr.tex EC Kurmanji hyphenation patterns (conv-utf8-ec.tex)
(hyph-kmr.tex)) (zerohyph.tex) (loadhyph-hi.tex
No Hindi hyphenation patterns - only for Unicode engines) (loadhyph-fr.tex
EC French hyphenation patterns (conv-utf8-ec.tex) (hyph-fr.tex))
(loadhyph-zh-latn-pinyin.tex
EC Pinyin Hyphenation Patterns (with tone markers) 2018-11-25 (WL)
(hyph-zh-latn-pinyin.ec.tex)) (loadhyph-ga.tex EC Irish hyphenation patterns
(conv-utf8-ec.tex) (hyph-ga.tex)) (loadhyph-grc.tex
Hyphenation patterns for Ancient Greek (grahyph5.tex
Hyphenation patterns for Ancient Greek)) (loadhyph-af.tex
EC Afrikaans hyphenation patterns (conv-utf8-ec.tex) (hyph-af.tex))
(loadhyph-eo.tex IL3 Esperanto hyphenation patterns (conv-utf8-il3.tex)
(hyph-eo.tex)) (loadhyph-it.tex ASCII Italian hyphenation patterns (hyph-it.tex
)) (loadhyph-ia.tex ASCII Hyphenation patterns for Interlingua (hyph-ia.tex))
(loadhyph-oc.tex EC Occitan hyphenation patterns (conv-utf8-ec.tex)
(hyph-oc.tex)) (loadhyph-pl.tex QX Polish hyphenation patterns
(conv-utf8-qx.tex) (hyph-pl.tex)) (loadhyph-mul-ethi.tex
No Pan-Ethiopic hyphenation patterns - only for Unicode engines)
(loadhyph-de-1901.tex EC German hyphenation patterns (traditional orthography)
(dehypht.tex
German Traditional Hyphenation Patterns `dehypht' Version 3.2a <1999/03/03>
(Formerly known under the name `ghyph31' and `ghyphen'.))) (loadhyph-es.tex
EC Spanish hyphenation patterns (conv-utf8-ec.tex) (hyph-es.tex))
(loadhyph-rm.tex ASCII Romansh hyphenation patterns (hyph-rm.tex))
(loadhyph-hu.tex EC Hungarian hyphenation patterns (conv-utf8-ec.tex)
(hyph-hu.tex)) (loadhyph-te.tex
No Telugu hyphenation patterns - only for Unicode engines)
(loadhyph-la-x-liturgic.tex EC Liturgical Latin hyphenation patterns
(hyph-la-x-liturgic.ec.tex)) (loadhyph-mn-cyrl.tex
T2A (New) Mongolian hyphenation patterns (conv-utf8-t2a.tex) (hyph-mn-cyrl.tex)
) (loadhyph-ca.tex EC Catalan hyphenation patterns (conv-utf8-ec.tex)
(hyph-ca.tex)) (loadhyph-sa.tex
No Sanskrit hyphenation patterns - only for Unicode engines) (loadhyph-lv.tex
L7X Latvian hyphenation patterns (conv-utf8-l7x.tex) (hyph-lv.tex))
(loadhyph-la-x-classic.tex ASCII Classical Latin hyphenation patterns
(hyph-la-x-classic.tex)) (loadhyph-de-ch-1901.tex
EC Swiss-German hyphenation patterns (traditional orthography)
(conv-utf8-ec.tex) (hyph-de-ch-1901.tex
Swiss-German Hyphenation Patterns (Traditional Orthography) `dehyphts-x' 2019-0
4-04 (WL))) (loadhyph-bg.tex T2A Bulgarian hyphenation patterns
(conv-utf8-t2a.tex) (hyph-bg.tex
Bulgarian hyphenation patterns (options: --safe-morphology --standalone-tex, ve
rsion 21 October 2017))) (loadhyph-ta.tex
No Tamil hyphenation patterns - only for Unicode engines) (loadhyph-uk.tex
T2A Ukrainian hyphenation patterns (ukrhyph.tex
Ukrainian hyphenation patterns in t2a encoding (catlcy.tex) (lcy2t2a.tex)
(ukrhypmp.tex) (hypht2.tex))) (loadhyph-pms.tex
ASCII Piedmontese hyphenation patterns (hyph-pms.tex)) (loadhyph-en-us.tex
ASCII Hyphenation patterns for American English (hyph-en-us.tex))
(loadhyph-sr-latn.tex EC Serbian hyphenation patterns in Latin script
(conv-utf8-ec.tex) (hyph-sh-latn.tex)) (loadhyph-nn.tex
EC Norwegian Nynorsk hyphenation patterns (conv-utf8-ec.tex) (hyph-nn.tex
(hyph-no.tex
! TeX capacity exceeded, sorry [pattern memory=600000].
l.24681 uma8ge.

This is e-TeX, Version 3.14159265-2.6 (INITEX)
**Sorry, I can't find that format; will try PLAIN.
I can't find the PLAIN format file!

Building core.dump in the docker container usually failed with this error:

! TeX capacity exceeded, sorry [pattern memory=600000].
l.24681 uma8ge.

This is e-TeX, Version 3.14159265-2.6 (INITEX)
**Sorry, I can't find that format; will try PLAIN.
I can't find the PLAIN format file!

I looked into ways to increase the memory limit, but I couldn't find anything. There's tex.ch in the web2js repo with some parameters like trie_size, but from what I can tell that's an output file not an input file.

So, I tried manually apt removeing and apt autoremoveing packages from the docker container until it matched my local machine. At one point, I received this error:

This is e-TeX, Version 3.14159265-2.6 (INITEX)
**entering extended mode
LaTeX2e <2020-02-02> patch level 2

! LaTeX Error: File `standalone.cls' not found.

Type X to quit or <RETURN> to proceed,
or enter new name. (Default extension: cls)

Enter file name: ! Undefined control sequence.
\filename@simple ... \edef \filename@base 
                                          {#1}\else \filename@dots {#...
<*> ...ntclass[margin=0pt]{standalone}\def
                                          \pgfsysdriver{pgfsys-ximera...
? ! Undefined control sequence.
\filename@simple ... \edef \filename@base 
                                          {#1}\else \filename@dots {#...
<*> ...ntclass[margin=0pt]{standalone}\def
                                          \pgfsysdriver{pgfsys-ximera...
? 

Googling told me that standalone.cls comes from texlive-latex-extra, so I apt installed it. Finally, I was successful producing core.dump in the docker container:

successful core.dump from docker

root@26e218c65c1d:/code/web2js# node initex.js
This is e-TeX, Version 3.14159265-2.6 (INITEX)
**entering extended mode
(latex.ltx (texsys.cfg)
./texsys.aux found

\@currdir set to: ./.

Assuming \openin and \input 
have the same search path.

Defining UNIX/DOS style filename parser.

catcodes, registers, parameters,
LaTeX2e <2020-02-02> patch level 2
hacks, control, par, spacing, files, font encodings, lengths,
====================================

Local config file fonttext.cfg used

====================================
("fonttext.cfg" ("fonttext.ltx"
=== Don't modify this file, use a .cfg file instead ===

("omlenc.def") ("omsenc.def") ("ot1enc.def") ("t1enc.def") ("ts1enc.def")
("ts1cmr.fd") ("t1cmr.fd") ("ot1cmr.fd") ("ot1cmss.fd") ("ot1cmtt.fd")))
====================================

Local config file fontmath.cfg used

====================================
("fontmath.cfg" ("fontmath.ltx"
=== Don't modify this file, use a .cfg file instead ===

("omlcmm.fd") ("omscmsy.fd") ("omxcmex.fd") ("ucmr.fd")))
====================================

Local config file preload.cfg used

=====================================
("preload.cfg" ("preload.ltx")) page nos., x-ref, environments, center,
verbatim, math definitions, boxes, title, sectioning, contents, floats,
footnotes, index, bibliography, output,
===========================================
Local configuration file hyphen.cfg used
===========================================
("hyphen.cfg" (switch.def) (hyphen.tex) (dumyhyph.tex) (zerohyph.tex))
("utf8.def" (utf8-2018.def ("omsenc.dfu") ("ot1enc.dfu") ("t1enc.dfu")
("ts1enc.dfu"))) ("ltexpl.ltx" Skipping expl3-dependent extensions)
 )
Beginning to dump on file latex.fmt
 (preloaded format=latex 2023.4.21)
6485 strings of total length 79730
62819 memory locations dumped; current usage is 148&62444
5287 multiletter control sequences
\font\nullfont=nullfont
\font\OMX/cmex/m/n/10=cmex10
\font\tenln=line10
\font\tenlnw=linew10
\font\tencirc=lcircle10
\font\tencircw=lcirclew10
\font\OT1/cmr/m/n/5=cmr5
\font\OT1/cmr/m/n/7=cmr7
\font\OT1/cmr/m/n/10=cmr10
\font\OML/cmm/m/it/5=cmmi5
\font\OML/cmm/m/it/7=cmmi7
\font\OML/cmm/m/it/10=cmmi10
\font\OMS/cmsy/m/n/5=cmsy5
\font\OMS/cmsy/m/n/7=cmsy7
\font\OMS/cmsy/m/n/10=cmsy10
3633 words of font info for 14 preloaded fonts
14 hyphenation exceptions
Hyphenation trie of length 6081 has 183 ops out of 10000
  2 for language 1
  181 for language 0
No pages of output.
Transcript written on latex.log.
This is e-TeX, Version 3.14159265-2.6 (INITEX)
**entering extended mode
LaTeX2e <2020-02-02> patch level 2
("standalone.cls"
Document Class: standalone 2018/03/26 v1.3a Class to compile TeX sub-files stan
dalone
("shellesc.sty"

Package shellesc Warning: Shell escape disabled on input line 73.

) ("ifluatex.sty" ("iftex.sty")) ("xkeyval.sty" (xkeyval.tex (xkvutils.tex
(keyval.tex)))) ("standalone.cfg") ("article.cls"
Document Class: article 2019/12/20 v1.4l Standard LaTeX document class
("size10.clo")))
*("xcolor.sty" ("color.cfg") ("dvips.def") ("svgnam.def"))
*("tikz.sty" ("pgf.sty" ("pgfrcs.sty" (pgfutil-common.tex
(pgfutil-common-lists.tex)) (pgfutil-latex.def ("everyshi.sty"))
("pgfrcs.code.tex" (pgf.revision.tex))) ("pgfcore.sty" ("graphicx.sty"
("graphics.sty" ("trig.sty") ("graphics.cfg"))) ("pgfsys.sty"
("pgfsys.code.tex" (pgfkeys.code.tex (pgfkeysfiltered.code.tex)) (pgf.cfg)
(pgfsys-ximera.def (pgfsys-common-svg.def))) ("pgfsyssoftpath.code.tex")
("pgfsysprotocol.code.tex")) ("pgfcore.code.tex" (pgfmath.code.tex
(pgfmathcalc.code.tex (pgfmathutil.code.tex) (pgfmathparser.code.tex)
(pgfmathfunctions.code.tex (pgfmathfunctions.basic.code.tex)
(pgfmathfunctions.trigonometric.code.tex) (pgfmathfunctions.random.code.tex)
(pgfmathfunctions.comparison.code.tex) (pgfmathfunctions.base.code.tex)
(pgfmathfunctions.round.code.tex) (pgfmathfunctions.misc.code.tex)
(pgfmathfunctions.integerarithmetics.code.tex))) (pgfmathfloat.code.tex))
(pgfint.code.tex) (pgfcorepoints.code.tex) (pgfcorepathconstruct.code.tex)
(pgfcorepathusage.code.tex) (pgfcorescopes.code.tex)
(pgfcoregraphicstate.code.tex) (pgfcoretransformations.code.tex)
(pgfcorequick.code.tex) (pgfcoreobjects.code.tex)
(pgfcorepathprocessing.code.tex) (pgfcorearrows.code.tex)
(pgfcoreshade.code.tex) (pgfcoreimage.code.tex (pgfcoreexternal.code.tex))
(pgfcorelayers.code.tex) (pgfcoretransparency.code.tex)
(pgfcorepatterns.code.tex) (pgfcorerdf.code.tex))) (pgfmoduleshapes.code.tex)
(pgfmoduleplot.code.tex) ("pgfcomp-version-0-65.sty")
("pgfcomp-version-1-18.sty")) ("pgffor.sty" ("pgfkeys.sty" ("pgfkeys.code.tex")
) ("pgfmath.sty" ("pgfmath.code.tex")) ("pgffor.code.tex" (pgfmath.code.tex)))
("tikz.code.tex" (pgflibraryplothandlers.code.tex) (pgfmodulematrix.code.tex)
(tikzlibrarytopaths.code.tex)))
(Please type a command or say `\end')
*

Afterwards, I made a few guesses as to what to include in the Dockerfile.

benrbray commented 1 year ago

Working Dockerfile for tikzjax

In the develop branch of my fork of tikzjax, I've been able to put together a Docker container which successfully compiles both web2js and tikzjax to produce both fonts.css and tikzjax.js. I had to make a few small updates to package.json and webpack.config.js, but otherwise building tikzjax was very easy compared to web2js.

mayurankv commented 9 months ago

That's really helpful knowledge @benrbray, thanks! It will definitely be useful for me.

mayurankv commented 9 months ago

In terms of updating packages, does the script have to be rebundled anytime a package updates and that needs to be added?

thecodechemist99 commented 4 months ago

In terms of updating packages, does the script have to be rebundled anytime a package updates and that needs to be added?

As the package data is pulled from a TeXLive installation when running the build script, I believe that’s necessary. At least unless another mechanism is implemented, maybe to also allow people to add packages themselves more easily.