tlaplus / rfcs

RFCs for changes to the TLA+ specification language
MIT License
13 stars 0 forks source link

[tool] Pretty Print to HTML #2

Open lemmy opened 3 years ago

lemmy commented 3 years ago

TLA+ has a great pretty-printer to TeX (tla2tex), but HTML is becoming a de-facto document standard, especially for content shared online. HTML also has other advantages, such as the ability to automatically add hyperlinks from symbols to their definitions, and allow for collapsing and expanding proofs. The existing tla2tex code already contains most of the necessary parsing and typesetting pre-processing (like alignment), and could serve as a basis for an HTML pretty-printer. A prototype already exists.

Copied from: https://github.com/tlaplus/tlaplus/blob/master/general/docs/contributions.md#pretty-print-to-html-difficulty-easy-skills-java-html. Originally proposed by @pron.

xxyzzn commented 3 years ago

HTML may be a de facto standard for displaying cat videos and their literary equivalents, but the de facto standard for displaying math and documents in many other scientific fields is pdf. And Web browsers display it. It may be possible to display math formulas decently in HTML, but not in any standard way; and I wouldn't know how to do it. (As near as I can tell MathHTML is dead.)

If you want to display TLA+ in HTML, you should display the ASCII version. And, as I recall, TLA+ users never look at the pretty-printed version anyway. It shouldn't be too hard to duplicate the appropriate features of the Toolbox editor (clicking to reach a symbol's definition/declaration and collapsing/expanding proofs) on an HTML page. In fact, that could become part of the front-end for a web-based Toolbox.

muenchnerkindl commented 3 years ago

For what it's worth, established proof assistants usually produce both HTML and PDF versions of logical theories. Whereas the PDFs tend to have good pretty-printing (through LaTeX), the HTMLs are more or less souped-up versions of the ASCII sources but include links to resources they depend on.

Examples:

pron commented 3 years ago

HTML output can look pretty much identical to the PDF output, with the following benefits:

As a demonstration of what's possible, here's a screenshot of a prototype HTML pretty-printer output, that renders in the browser and has copy-as-ASCII.

Screen Shot 2019-07-17 at 7 09 57 PM
xxyzzn commented 3 years ago

That looks pretty good. I have two questions: What are the odds that your html file will still work in 20 years? Is it easy to display a snippet of TLA+ or PlusCal inside an ordinary HTML document?

pron commented 3 years ago

What are the odds that your html file will still work in 20 years?

The file is just the ASCII representation and a link to the JS renderer, so it will work 100%, but might, in the worst-case show just the ASCII.

Is it easy to display a snippet of TLA+ or PlusCal inside an ordinary HTML document?

That would be the vision. My very partial POC required that any TLA+ block be a complete module.