tlaplus / rfcs

RFCs for changes to the TLA+ specification language

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[tool] Pretty Print to HTML

lemmy opened this issue · comments

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.

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:

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

  • Render in the browser (i.e. the page source contains the ASCII, and if JS is enabled it is pretty-printed, otherwise it is shown as ASCII).
  • Copy to ASCII
  • Links (definitions, proof steps)
  • Hover-tooltips
  • Proof-stage collapse/expansion

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

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?

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.