Note that there are some explanatory texts on larger screens.

plurals
  1. POHow can I parse ASCII Art to HTML using Java or Javascript?
    primarykey
    data
    text
    <p>I saw that the Neo4j API uses ASCII Art very cleverly with its API:</p> <p><a href="http://jaxenter.com/getting-started-with-neo4j-the-java-graph-database-47955.html">http://jaxenter.com/getting-started-with-neo4j-the-java-graph-database-47955.html</a></p> <p>I want to try something similar, but with ASCI Art to HTML. How can ASCII art be parsed, so for example, given an ASCII Art input something like:</p> <pre><code>-------------------------------- I I I ------- ------- I I I I I I I I I A I I B I I I I I I I I I ------- ------- I I I I I -------------------------------- </code></pre> <p>: could result in HTML output something like:</p> <pre><code>&lt;div&gt; &lt;div style='display:inline;'&gt; A &lt;/div&gt; &lt;div style='display:inline;'&gt; B &lt;/div&gt; &lt;/div&gt; </code></pre> <h1>Update</h1> <p>The question was closed citing that I need to "demonstrate a minimal understanding of the problem being solved.". I do have an understanding of the problem to be solved. The problem is that I want to solve is to make templated HTML easier to understand in source code for the following web framework:</p> <p><a href="https://github.com/zubairq/coils">https://github.com/zubairq/coils</a></p> <p>: although the solution could be applied to any web framework. I have since seen someone attempt to make an initial version in C++ here:</p> <p><a href="https://github.com/h3nr1x/asciidivs2html/blob/master/asciidivs2html.cpp">https://github.com/h3nr1x/asciidivs2html/blob/master/asciidivs2html.cpp</a></p> <p>: very impressive! If you can get it to work in Java or Clojure then if we can get the question reopened I will nominate a bounty so you can get more points for the solution :)</p> <p>I ran the Java solution provided by @meewok and here is the result:</p> <pre><code>$ java AsciiToDIVs.RunConverter Created a box(ID=0,X=0,Y=0,width=33,height=10) Created a box(ID=1,X=2,Y=4,width=8,height=5,parent=0) Created a char(Char=A,X=4,Y=7,parent=1) Created a box(ID=2,X=2,Y=21,width=8,height=5,parent=0) Created a char(Char=B,X=4,Y=24,parent=2) &lt;div&gt;&lt;div&gt;&lt;div&gt;A&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;div&gt;B&lt;/div&gt;&lt;/div&gt;&lt;/div&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload