How to display evidence tree using HTML, CSS and / or Javascript?

I want to display a proof tree in a natural inference style in a web page. I will get the data from the JSON file.

What is the best way to display something like this? Is this only possible with css? Or is there a library that can do something like this? Rendering as an image is not possible, because ultimately it must be interactive. I should also mention that this tree can become quite large.

Example: proof tree

Update: the best example of how the final result should look: enter image description here

+4
source share
3 answers

So, after reusing css, I used tables to get a satisfactory result. Since the layout is indeed part of the semantics, I find it acceptable in this case.

A small example would look like this:

<table> <tr> <td> </td> <td class="rulename" rowspan="2"><div class="rulename">add</div></td></tr> <tr><td class="conc">conclusion</td></tr> </table> 

And css:

 td { text-align:center; height: 1em; vertical-align:bottom; } td.conc { border-top: solid 1px; } div.rulename { margin-top:-2em; } 

Big demonstration

0
source

The simplest solution would be mathjax , which is a latex javascript renderer. And there are quite a few other similar rendering options.

Alternatively, you can also look at MathML , which is the w3c standard for writing mathematical equations. Unfortunately, there is support for it is entirely absent, as can be seen here , but in the long run it will be a great solution. In addition, the previously mentioned mathjax can be used as a MathML shim in browsers that do not yet support MathML.

The only problem with MathJax shim will be that when you make it interactive, it will interact differently with your code in browsers, what to do and not support MathML, but despite this, I personally advised MathML, except in those cases when you are already connected with LaTeX.

Based on your update, I'm not sure if this can be expressed in MathML or LaTeX, and I'm afraid that the only thing you could do is draw it on the canvas or set it up in SVG if you need interactivity later. But I can warn you that you already know that this will not be an easy task if you are not used to it.


To add interactivity to Mathjax:

  • Use MathML for input
  • Use HTML / CSS as output
  • Disable the MathJax context menu by adding showMathMenu:false to your MathJax configuration
  • Include an identifier in your MathML markup (e.g. <mo id="someid"> )
  • Use, for example, jQuery to bind to id after completing MathJax (ie $("#someid").on("mousemove",function(){...}) )

A full working demo can be found here , move the equal sign to trigger a warning.

+3
source

Recently, I came across the same thing, and I managed to write CSS, which gives good results. Here is an example html skeleton:

 <div class="proof"> <div class="prems"> <div class="proof"> <div class="prems"> <div class="proof"> <div class="prems"> <div class="proof"> <div class="concl"> <div class="concl-left"></div> <div class="concl-center">bla</div> <div class="concl-right"></div> </div> </div> <div class="inter-proof"></div> <div class="proof"> <div class="concl"> <div class="concl-left"></div> <div class="concl-center">bla</div> <div class="concl-right"></div> </div> </div> </div> <div class="concl"> <div class="concl-left"></div> <div class="concl-center">bla</div> <div class="concl-right"></div> </div> </div> <div class="inter-proof"></div> <div class="proof"> <div class="concl"> <div class="concl-left"></div> <div class="concl-center">bla</div> <div class="concl-right"></div> </div> </div> </div> <div class="concl"> <div class="concl-left"></div> <div class="concl-center">bla</div> <div class="concl-right"></div> </div> </div> </div> <div class="concl"> <div class="concl-left"></div> <div class="concl-center">blabla</div> <div class="concl-right"></div> </div> </div> 

and here's the CSS:

 .proof { display: inline-flex; flex-direction: column; } .prems { display: inline-flex; flex-wrap: nowrap; align-items: flex-end; } .inter-proof { border-bottom: 1px solid black; width: 1em; } .concl { display: inline-flex; margin-top: -1px; } .concl-left { flex-grow: 1; } .concl-center { border-top: 1px solid black; } .concl-right { flex-grow: 1; } .prems > .proof:not(:first-child) > .concl > .concl-left { border-bottom: 1px solid black; } .prems > .proof > .concl > .concl-center { border-bottom: 1px solid black; } .prems > .proof:not(:last-child) > .concl > .concl-right { border-bottom: 1px solid black; } 

see it live here . I just tried with firefox, and for other browsers some settings might be required.

+2
source

All Articles