New script in scripts.leo: web-to-outline

86 views
Skip to first unread message

Edward K. Ream

unread,
Oct 14, 2021, 1:45:46 PM10/14/21
to leo-editor
The web-to-outline script converts the sources for Knuth's TeX system to an outline. The script assumes the file is in ~/tex.web.

The script works, but imo nothing can make up for the sorry state of programming in 1984 :-)  Not outlines, not typesetting.

So this script is just a toy.  Still, I'm happy I wrote it. It was natural to do this after working on the python-to-typescript command.  The script illustrates how easy it is to use patterns to organize programs.

Edward

Edward K. Ream

unread,
Oct 14, 2021, 2:53:34 PM10/14/21
to leo-editor
On Thu, Oct 14, 2021 at 12:45 PM Edward K. Ream <edre...@gmail.com> wrote:
 
nothing can make up for the sorry state of programming in 1984 :-)

Well, maybe typesetting (interactive TeX) plus outlines would work. For example, MathJax v3 can quickly render TeX to svg. Something like this might be good for VR or VR3, if it doesn't already exist :-)

Edward

tbp1...@gmail.com

unread,
Oct 14, 2021, 5:06:33 PM10/14/21
to leo-editor
I don't think it renders general TeX though, just math.  I noticed something on the MathJax site that might interest you:

" MathJax 3 is written using ES6 modules and the Typescript language".

VR3 already can render math with MathJax.  I'll have to see if anything needs to be done about MathJax 3, but really it's up to RsT to do the work.

Edward K. Ream

unread,
Oct 14, 2021, 6:08:44 PM10/14/21
to leo-editor
On Thu, Oct 14, 2021 at 4:06 PM tbp1...@gmail.com <tbp1...@gmail.com> wrote:
I don't think it renders general TeX though, just math. 

I noticed something on the MathJax site that might interest you:

" MathJax 3 is written using ES6 modules and the Typescript language".

Yes. I'll take a look.

VR3 already can render math with MathJax.  I'll have to see if anything needs to be done about MathJax 3, but really it's up to RsT to do the work.

Excellent. Thanks for these comments.

Edward

tbp1...@gmail.com

unread,
Oct 14, 2021, 6:54:44 PM10/14/21
to leo-editor
Here's the rendering of a node I use for testing VR3 with MathJax.
vr3-mathjax-example.zip

jkn

unread,
Oct 15, 2021, 4:25:43 AM10/15/21
to leo-editor
On Thursday, October 14, 2021 at 6:45:46 PM UTC+1 Edward K. Ream wrote:
The web-to-outline script converts the sources for Knuth's TeX system to an outline. The script assumes the file is in ~/tex.web.

The script works, but imo nothing can make up for the sorry state of programming in 1984 :-)  Not outlines, not typesetting.


Hi Edward

I'm curious as to what you mean by this. Are you referring to the design of the TeX language?

If so ... having some a moderate amount under TeX back in the day, I tend to agree.
Some of the design is obviously due to the target use, of typesetting words. But I
have more than once wondered what would have happened if 'TeX' had been written in
something like Python (which came much later, of course)...

    J^n

Edward K. Ream

unread,
Oct 15, 2021, 8:12:28 AM10/15/21
to leo-editor
On Fri, Oct 15, 2021 at 3:25 AM jkn <jkn...@nicorp.f9.co.uk> wrote:

> I'm curious as to what you mean by this. Are you referring to the design of the TeX language?

The short answer: no, but this is an interesting question!

The most important things to know about TeX:

1. It's never going to change.
2. It does what it was intended to do.
3. It is an important de facto standard.
4. LaTex hides the horrendous details.

However, I was referring to the web language, which imo is a horror show. I think I am entitled to this opinion since I have spent about 40 years trying to do better :-)

> I have more than once wondered what would have happened if 'TeX' had been written in something like Python (which came much later, of course)...

The question I have been asking myself lately is whether there are unit tests for TeX that would allow re-implementations in other languages. Unit testing as a concept did not exist when Knuth created TeX, but such tests should be completely feasible. After all the tests would check that, given a TeX input, the text output matches expected output in one of several forms: dvi, svg, pdf, postscript.

These kinds of text-to-text checks are the easiest form of unit tests. However, it would likely take at least a year to create tests that fully cover TeX. But is that a big deal?  I think not, given the importance of TeX in the world.  There may be such tests, but I haven't (yet) found evidence of them.

Absent such tests, we are stuck with precompiled versions of the original TeX (in pascal!) program. But I could be mistaken about that.

vs-code has a textab extension that's written in rust! I am busy installing lyx (and tex live) so I can see in what language lyx is written. And then there is the whole mathjax tool chain, which I'm guessing is built on top of TeX/LaTex. There are several LaTeX extensions for vs-code.

Summary

There has been tremendous progress in all areas since ca 1980, so without more research it's too early to say how easy it would be to make sense of tex.web :-) And let me emphasize that everything I have said here could be mistaken, in small or large ways!

Edward

Edward K. Ream

unread,
Oct 15, 2021, 8:29:49 AM10/15/21
to leo-editor
On Thu, Oct 14, 2021 at 5:54 PM tbp1...@gmail.com <tbp1...@gmail.com> wrote:
Here's the rendering of a node I use for testing VR3 with MathJax.

Thanks. The rendering looks great as a stand-alone .html file.

And WOW: it looks great rendered in VR3!  I pasted the entire .html file into a Leo file and did vr3-show.

How did you get this example?

Edward

jkn

unread,
Oct 15, 2021, 8:38:53 AM10/15/21
to leo-editor
Hi Edward
    ah, so you are talking about the literate programming aspects of TeX. Fair enough. I came to Leo via that side of things (as did you, I know) but I can't remember what I ever knew about Knuth's tangle and weave etc.

FWIW, although TeX was originally written in Pascal (or SAIL, some sort of derived language IIRC), I think nowadays there is a C version which pretty much everyone uses. I would think that this impliest hat there are plenty of unit tests for the implementation, presumably written after the fact. But I don't know too much about that.

Regards, J^n

Edward K. Ream

unread,
Oct 15, 2021, 8:53:52 AM10/15/21
to leo-editor
On Fri, Oct 15, 2021 at 7:38 AM jkn <jkn...@nicorp.f9.co.uk> wrote:

FWIW, although TeX was originally written in Pascal (or SAIL, some sort of derived language IIRC), I think nowadays there is a C version which pretty much everyone uses. I would think that this impliest hat there are plenty of unit tests for the implementation, presumably written after the fact. But I don't know too much about that.

We'll see.

Edward

tbp1...@gmail.com

unread,
Oct 15, 2021, 9:25:25 AM10/15/21
to leo-editor
Here's a link where many people chime in with factoids about what language it's written in: What language is TeX implemented in?  As to unit tests, I wouldn't be too confident about that!

Edward K. Ream

unread,
Oct 15, 2021, 9:30:14 AM10/15/21
to leo-editor
On Fri, Oct 15, 2021 at 8:25 AM tbp1...@gmail.com <tbp1...@gmail.com> wrote:
Here's a link where many people chime in with factoids about what language it's written in: What language is TeX implemented in?  As to unit tests, I wouldn't be too confident about that!

This page agrees with my general understanding.

Anyway, I'm more interested now in learning how mathJax works.

Edward

tbp1...@gmail.com

unread,
Oct 15, 2021, 11:57:17 AM10/15/21
to leo-editor
You need to set a couple of VR3 settings for it to render MathJax.  They are documented in VR3's docstring.  VR3 can also render MathJax in Markdown nodes.  Here is the node body I used to make the example rendering.  It's one of the nodes I use to test VR3's renderings.

There should be some in line math :math:`a-2b^2` here.

.. math::

    \frac{2\pm\sqrt{7}}{3}

Some text here, and then some more math:

.. math::

    \sum_{n=1}^\infty\frac{-e^{i\pi}}{2^n}+(\frac{5-\frac{1}{x}}{4})

To get this to work right with rst2pdf, we need to put a blank line between each line of math.

.. math::

    α_t(i)=P(O_1,O_2,…O_t,q_t)=S_iλ

    k=\int_{0}^{10}xdx

    E=mc^2

More inline math: :math:`e^x`.


Edward K. Ream

unread,
Oct 16, 2021, 4:47:42 AM10/16/21
to leo-editor
On Fri, Oct 15, 2021 at 10:57 AM tbp1...@gmail.com <tbp1...@gmail.com> wrote:
You need to set a couple of VR3 settings for it to render MathJax.  They are documented in VR3's docstring.  VR3 can also render MathJax in Markdown nodes. 

Thanks for this.

Edward
Reply all
Reply to author
Forward
0 new messages