Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Serve the docco correspondance file with the parse tree

some more doc too
  • Loading branch information...
commit a37e8ffceac2f42cd30d388171fcd2aabedb421b 1 parent 20be989
@cognominal authored
View
89 README.html
@@ -122,6 +122,7 @@
<h1>An attempt to integrate code-viewer into (SFW) Small Federated Wiki</h1>
<p>At this point, we do hilite a single file data/package.json
+Touch interface devices are supported.
Static hiliting works, dynamic does not yet.
Integration in SFW not done.
Run make, serve the directory with some web server and access i.html</p>
@@ -135,22 +136,86 @@
<h1>Next steps yet to be done</h1>
<ul>
+<li>Display the rule used to reduce the current text (still need css)</li>
<li>Bug jnthn/pmichaud to get parse tree dumping in Perl 6</li>
-<li>Display the rule used to reduce the current text</li>
+<li>Install zbrew on MBP and open a NTA port</li>
+<li>Setup a github page.</li>
+<li>Parse path bar need to be scrollable</li>
<li>Serve the docco correspondance file with the parse tree</li>
<li>Support many highlighted view ports (use class instead if id to identify relevant HTML elements</li>
<li>Use express to serve the files (SFW will use express anyway)</li>
<li>Dynamically generate the parse according to the suffix</li>
+<li>Support json parse trees for different parse engines</li>
<li>Split bin/matchToJson into a library and code calling it</li>
<li>implement a recorder and a demo mode</li>
<li>maybe create a .dot file to document the information flow</li>
-<li>make it a SFW plugin (the previous steps are preparatory one)</li>
+<li>make it a SFW plugin (the previous steps are preparatory ones)</li>
<li>create an IRC like plugin in SFW</li>
<li>Embed rakudo in nodejs.</li>
+<li>tests!! don't know yet how to do browser side tests. Probably stuff based on jsdom.</li>
+<li>Better doc</li>
</ul>
<p>Note: to install SFW, I created a gist https://gist.github.com/2887964</p>
+<h1>User interface</h1>
+
+<p>We call <code>lite</code> the code viewport. Lite stands for literate editor.
+Lite has two modes, the folded mode and the full mode. So we say
+a "folded lite" or a "full lite" to denote such a viewport depending
+on its mode. In folded lite, only the code pane is visible.
+The code pane may splitted in to à la docco with comments in left, and
+code proper in right. (worked with static data).
+One should be able to show the code pane with or without docco. In the second
+case he should be able to hide comments</p>
+
+<p>So far, only the full lite mode is implemented.</p>
+
+<p>In full lite, from top to bottom, the view port is constituted of 3 panes.
+The parse path pane (P3), the rule pane and the code pane.
+At any given time, some text chunk in the code panel is current. When the
+code was parsed, according to the grammar for that code, some sequence of rules was used to reduce that current text chunk. The last rule of that sequence is the leaf rule.</p>
+
+<p>When moving the mouse over the code panel, or clicking in it, the currrent
+text chunk changes so the parse path and the rule panes are updated
+accordingly.</p>
+
+<h1>API</h1>
+
+<p>The loading of a lite is done thru an ajax call that brings a json object
+constitued of thre subobjects. We call it a lite object.
+The <code>parseTree</code> subobject is the parse tree,
+the <code>rules</code> subobject is the grammar broken in rules, the <code>docco</code> subobject is
+the partial mapping of rule names to docco css names for highlighting.</p>
+
+<p>Note that the rules subobject may eventually be a lite object as well so
+that the rule pane will be a folded lite viewport with a partial view of
+a grammar; The view being the current rule. Clicking on that pane will
+bring the grammar as code in the enclosing viewport. Clicking again will bring
+the grammar of the grammar. An history mechanism
+should be implemented so that we can bring back the original code.</p>
+
+<p>Note that, for highlighting purposes, the relevant rule may be a parent of the
+leaf rule. Say, that the code panel contains json code and the current text
+chunk has been reduced by the <code>str</code> rule. The static highlighting will likely be associated with the string <code>rule</code>, not <code>str</code>. Too much granularity for SH would be detrimental.</p>
+
+<p><code>token string { \" ~ \" ( &lt;str&gt; | \\ &lt;str_escape&gt; )* }</code>
+ <code>token str { &lt;-["\\\t\n]&gt;+ }</code></p>
+
+<p>We eventually want to support the ST2 API because it is simple and clean.
+Apparently ST2 does not support chording sequence à la emacs.
+As a user I (may) regret it.
+As an implementer it will make easier the binding between chords and actions
+Plugins would be written in JS or run-server side.</p>
+
+<p>We may revert to textareas for edition because the <code>editing</code> class
+attribute is supported only in webkit and behave wildly.</p>
+
+<h2>data</h2>
+
+<p>HTML5 allows to store a string in customs html element attributes which names
+starts by the "data" string. Like SFW, we use that feature. Note that we need to serialize js object into json before storing it. Serialization is done thru JSON.stringify; deserialization thru <code>JSON.parse</code>. Such an object cannot have cycles. If so we will need YAML. See http://ejohn.org/blog/html-5-data-attributes/</p>
+
<h1>Highlighting</h1>
<p>We will support two kinds of highlighting. The traditional one is
@@ -164,8 +229,7 @@
HV denote a viewport that show HC.</p>
<p>A file is parsed and a json tree is generated that represents the corresponding
-parse tree. Depending on options, one can get either a full parse tree or just a
-sequence of tokens. The full parse tree is necessary for dynamic highlighting
+parse tree. Depending on options, one can get either a full parse tree or just a sequence of tokens. The full parse tree is necessary for dynamic highlighting
but a full file displayed this way would result on gigantic web pages.</p>
<p>In the client <code>src/hilite.coffee</code>, the json file is pulled using ajax. When the
@@ -174,8 +238,8 @@
<p>So with the following docco object</p>
-<p><code>docco =
- string: 's'</code></p>
+<p><code>docco =</code>
+ <code>string: 's'</code></p>
<p>An element generated for a reduction caused by the rule <code>string</code> will look like</p>
@@ -187,11 +251,12 @@
only part of the code will be displayed as such and the rest will
be in DH. But we want to be able to instantly convert in SH.</p>
-<p>HTML5 allows to store anything in s html element attribute which names starts by "data". We will divide the HC in chunks. Each chunks will store the corresponding
-json deep parse in its data attribute. When mousing out a DH chunks, it will be
-converted back in SH. WHen mousing in a SH chunk it will be converted in DH.</p>
+<p>We will divide the HC in chunks. Each chunks will store the
+corresponding json deep parse in its data attribute. When mousing out a DH
+chunks, it will be converted back in SH. WHen mousing in a SH chunk it will be
+converted in DH.</p>
-<p>This can be done in the client. The server will just say what sub parse trees should be chunks. </p>
+<p>This can be done in the client. The server will just say what sub parse trees should be chunks.</p>
<h1>Multiple goals</h1>
@@ -210,12 +275,12 @@
<li>SublimeServer : We need to serve the files with a web server (versus acessing them thru the file system) so as to serve some of them using ajax</li>
</ul>
-<h2>Stuff to present</h2>
+<h3>Stuff to present</h3>
<p>How SublimeServer serves all the folder of the current projet.
linters that run in background.</p>
-<h2>License</h2>
+<h1>License</h1>
<p>Dual licensed under the MIT or GPL Version 2 licenses.</p>
</body>
View
36 README.md
@@ -20,7 +20,6 @@ Coffeescript is used to convert `.coffee` files in `.js` ones.
* Install zbrew on MBP and open a NTA port
* Setup a github page.
* Parse path bar need to be scrollable
-* Serve the docco correspondance file with the parse tree
* Support many highlighted view ports (use class instead if id to identify relevant HTML elements
* Use express to serve the files (SFW will use express anyway)
* Dynamically generate the parse according to the suffix
@@ -41,8 +40,13 @@ Note: to install SFW, I created a gist https://gist.github.com/2887964
We call `lite` the code viewport. Lite stands for literate editor.
Lite has two modes, the folded mode and the full mode. So we say
a "folded lite" or a "full lite" to denote such a viewport depending
-on its mode. In folded lite, only the code pane is visile.
-So far, only the full mode is implemented.
+on its mode. In folded lite, only the code pane is visible.
+The code pane may splitted in to à la docco with comments in left, and
+code proper in right. (worked with static data).
+One should be able to show the code pane with or without docco. In the second
+case he should be able to hide comments
+
+So far, only the full lite mode is implemented.
In full lite, from top to bottom, the view port is constituted of 3 panes.
The parse path pane (P3), the rule pane and the code pane.
@@ -69,23 +73,36 @@ bring the grammar as code in the enclosing viewport. Clicking again will bring
the grammar of the grammar. An history mechanism
should be implemented so that we can bring back the original code.
-Note that, for highlighting purpose, the relevant rule may be a parent of the
+Note that, for highlighting purposes, the relevant rule may be a parent of the
leaf rule. Say, that the code panel contains json code and the current text
-chunk has been reduced by the `str` rule. The static highlighting will be associated with the string `rule`, not `str`.
-
+chunk has been reduced by the `str` rule. The static highlighting will likely be associated with the string `rule`, not `str`. Too much granularity for SH would be detrimental.
`token string { \" ~ \" ( <str> | \\ <str_escape> )* }`
`token str { <-["\\\t\n]>+ }`
+We eventually want to support the ST2 API because it is simple and clean.
+Apparently ST2 does not support chording sequence à la emacs.
+As a user I (may) regret it.
+As an implementer it will make easier the binding between chords and actions
+Plugins would be written in JS or run-server side.
+
+We may revert to textareas for edition because the `editing` class
+attribute is supported only in webkit and behave wildly.
+
+## data
+
+HTML5 allows to store a string in customs html element attributes which names
+starts by the "data" string. Like SFW, we use that feature. Note that we need to serialize js object into json before storing it. Serialization is done thru JSON.stringify; deserialization thru `JSON.parse`. Such an object cannot have cycles. If so we will need YAML. See http://ejohn.org/blog/html-5-data-attributes/
+
-## Highlighting
+# Highlighting
We will support two kinds of highlighting. The traditional one is
called SH (Static Hilighting). With SH you can readily identify
token by some CSS attribute, usually a color. DH (Dynamic Hilighting)
is proper to brews and show how a file is parsed. DH comes in addition to SH and changes with user interaction, so its name.
-### Highlighting internals
+## Highlighting internals
HC is short for the highlighted code in a given viewport.
HV denote a viewport that show HC.
@@ -114,8 +131,7 @@ DH will be very costly in term of browser ressources. So at a given time
only part of the code will be displayed as such and the rest will
be in DH. But we want to be able to instantly convert in SH.
-HTML5 allows to store anything in an html element attribute which names starts
-by "data". We will divide the HC in chunks. Each chunks will store the
+ We will divide the HC in chunks. Each chunks will store the
corresponding json deep parse in its data attribute. When mousing out a DH
chunks, it will be converted back in SH. WHen mousing in a SH chunk it will be
converted in DH.
View
11 bin/jsonParseTree
@@ -20,7 +20,16 @@ my $match = JSON::Tiny::Grammar.parse: slurp $fnm;
# say $match.perl;
die unless $match;
-say qq|\{"rules":{to-json %ruleNms}, "parseTree":{deepToJSON $match}\}|;
+# translate rule name into CSS name.
+my %docco = {
+ TOP => 'TOP',
+ string => 's',
+ number => 'm'
+};
+
+
+say qq|\{"rules":{to-json %ruleNms}, "parseTree":{deepToJSON $match},
+ "docco":{to-json %docco}\}|;
# say deepToJSON $match;
# say shallowToJSON $match;
View
3  data/parsed.json
@@ -1 +1,2 @@
-{"rules":{ "TOP" : "rule TOP { ^[ <object> | <array> ]$ }\n", "object" : "rule object { '{' ~ '}' <pairlist> }\n", "pairlist" : "rule pairlist { <pair>* % \\, }\n", "pair" : "rule pair { <string> ':' <value> }\n", "array" : "rule array { '[' ~ ']' <arraylist> }\n", "arraylist" : "rule arraylist { <value>* % [ \\, ] }\n\n", "value" : "token value:sym<string> { <string> }\n\n", "string" : "token string {\n \\\" ~ \\\" ( <str> | \\\\ <str_escape> )*\n}\n\n", "str" : "token str {\n <-[\"\\\\\\t\\n]>+\n}\n\n", "str_escape" : "token str_escape {\n <[\"\\\\/bfnrt]> | u <xdigit>**4\n}\n\n" }, "parseTree":{"TOP":[{"object":["{\n ",{"pairlist":[{"pair":[{"string":["\"",{"0":[{"str":["name"]}]},"\""]},": ",{"value":[{"string":["\"",{"0":[{"str":["coffee-script"]}]},"\""]}]}]},",",{"pair":["\n ",{"string":["\"",{"0":[{"str":["description"]}]},"\""]},": ",{"value":[{"string":["\"",{"0":[{"str":["Unfancy JavaScript"]}]},"\""]}]}]},",",{"pair":["\n ",{"string":["\"",{"0":[{"str":["keywords"]}]},"\""]},": ",{"value":[{"array":["[",{"arraylist":[{"value":[{"string":["\"",{"0":[{"str":["javascript"]}]},"\""]}]},", ",{"value":[{"string":["\"",{"0":[{"str":["language"]}]},"\""]}]},", ",{"value":[{"string":["\"",{"0":[{"str":["coffeescript"]}]},"\""]}]},", ",{"value":[{"string":["\"",{"0":[{"str":["compiler"]}]},"\""]}]}]},"]"]}]}]},",",{"pair":["\n ",{"string":["\"",{"0":[{"str":["author"]}]},"\""]},": ",{"value":[{"string":["\"",{"0":[{"str":["Jeremy Ashkenas"]}]},"\""]}]}]},",",{"pair":["\n ",{"string":["\"",{"0":[{"str":["version"]}]},"\""]},": ",{"value":[{"string":["\"",{"0":[{"str":["1.3.3"]}]},"\""]}]}]},",",{"pair":["\n ",{"string":["\"",{"0":[{"str":["a-number-for-hiligitng-sake"]}]},"\""]},": ",{"value":["666"]}]},",",{"pair":["\n ",{"string":["\"",{"0":[{"str":["licenses"]}]},"\""]},": ",{"value":[{"array":["[",{"arraylist":[{"value":[{"object":["{\n ",{"pairlist":[{"pair":[{"string":["\"",{"0":[{"str":["type"]}]},"\""]},": ",{"value":[{"string":["\"",{"0":[{"str":["MIT"]}]},"\""]}]}]},",",{"pair":["\n ",{"string":["\"",{"0":[{"str":["url"]}]},"\""]},": ",{"value":[{"string":["\"",{"0":[{"str":["https://raw.github.com/jashkenas/coffee-script/master/LICENSE"]}]},"\""]}]},"\n "]}]},"}"]}]}]},"]"]}]}]},",",{"pair":["\n ",{"string":["\"",{"0":[{"str":["engines"]}]},"\""]},": ",{"value":[{"object":["{\n ",{"pairlist":[{"pair":[{"string":["\"",{"0":[{"str":["node"]}]},"\""]},": ",{"value":[{"string":["\"",{"0":[{"str":[">=0.4.0"]}]},"\""]}]},"\n "]}]},"}"]}]}]},",",{"pair":["\n ",{"string":["\"",{"0":[{"str":["directories"]}]},"\""]}," : ",{"value":[{"object":["{\n ",{"pairlist":[{"pair":[{"string":["\"",{"0":[{"str":["lib"]}]},"\""]}," : ",{"value":[{"string":["\"",{"0":[{"str":["./lib/coffee-script"]}]},"\""]}]},"\n "]}]},"}"]}]}]},",",{"pair":["\n ",{"string":["\"",{"0":[{"str":["main"]}]},"\""]}," : ",{"value":[{"string":["\"",{"0":[{"str":["./lib/coffee-script/coffee-script"]}]},"\""]}]}]},",",{"pair":["\n ",{"string":["\"",{"0":[{"str":["bin"]}]},"\""]},": ",{"value":[{"object":["{\n ",{"pairlist":[{"pair":[{"string":["\"",{"0":[{"str":["coffee"]}]},"\""]},": ",{"value":[{"string":["\"",{"0":[{"str":["./bin/coffee"]}]},"\""]}]}]},",",{"pair":["\n ",{"string":["\"",{"0":[{"str":["cake"]}]},"\""]},": ",{"value":[{"string":["\"",{"0":[{"str":["./bin/cake"]}]},"\""]}]},"\n "]}]},"}"]}]}]},",",{"pair":["\n ",{"string":["\"",{"0":[{"str":["homepage"]}]},"\""]},": ",{"value":[{"string":["\"",{"0":[{"str":["http://coffeescript.org"]}]},"\""]}]}]},",",{"pair":["\n ",{"string":["\"",{"0":[{"str":["bugs"]}]},"\""]},": ",{"value":[{"string":["\"",{"0":[{"str":["https://github.com/jashkenas/coffee-script/issues"]}]},"\""]}]}]},",",{"pair":["\n ",{"string":["\"",{"0":[{"str":["repository"]}]},"\""]},": ",{"value":[{"object":["{\n ",{"pairlist":[{"pair":[{"string":["\"",{"0":[{"str":["type"]}]},"\""]},": ",{"value":[{"string":["\"",{"0":[{"str":["git"]}]},"\""]}]}]},",",{"pair":["\n ",{"string":["\"",{"0":[{"str":["url"]}]},"\""]},": ",{"value":[{"string":["\"",{"0":[{"str":["git://github.com/jashkenas/coffee-script.git"]}]},"\""]}]},"\n "]}]},"}"]}]}]},",",{"pair":["\n ",{"string":["\"",{"0":[{"str":["devDependencies"]}]},"\""]},": ",{"value":[{"object":["{\n ",{"pairlist":[{"pair":[{"string":["\"",{"0":[{"str":["uglify-js"]}]},"\""]},": ",{"value":[{"string":["\"",{"0":[{"str":[">=1.0.0"]}]},"\""]}]}]},",",{"pair":["\n ",{"string":["\"",{"0":[{"str":["jison"]}]},"\""]},": ",{"value":[{"string":["\"",{"0":[{"str":[">=0.2.0"]}]},"\""]}]},"\n "]}]},"}\n"]}]}]}]},"}\n"]}]}}
+{"rules":{ "TOP" : "rule TOP { ^[ <object> | <array> ]$ }\n", "object" : "rule object { '{' ~ '}' <pairlist> }\n", "pairlist" : "rule pairlist { <pair>* % \\, }\n", "pair" : "rule pair { <string> ':' <value> }\n", "array" : "rule array { '[' ~ ']' <arraylist> }\n", "arraylist" : "rule arraylist { <value>* % [ \\, ] }\n\n", "value" : "token value:sym<string> { <string> }\n\n", "string" : "token string {\n \\\" ~ \\\" ( <str> | \\\\ <str_escape> )*\n}\n\n", "str" : "token str {\n <-[\"\\\\\\t\\n]>+\n}\n\n", "str_escape" : "token str_escape {\n <[\"\\\\/bfnrt]> | u <xdigit>**4\n}\n\n" }, "parseTree":{"TOP":[{"object":["{\n ",{"pairlist":[{"pair":[{"string":["\"",{"0":[{"str":["name"]}]},"\""]},": ",{"value":[{"string":["\"",{"0":[{"str":["coffee-script"]}]},"\""]}]}]},",",{"pair":["\n ",{"string":["\"",{"0":[{"str":["description"]}]},"\""]},": ",{"value":[{"string":["\"",{"0":[{"str":["Unfancy JavaScript"]}]},"\""]}]}]},",",{"pair":["\n ",{"string":["\"",{"0":[{"str":["keywords"]}]},"\""]},": ",{"value":[{"array":["[",{"arraylist":[{"value":[{"string":["\"",{"0":[{"str":["javascript"]}]},"\""]}]},", ",{"value":[{"string":["\"",{"0":[{"str":["language"]}]},"\""]}]},", ",{"value":[{"string":["\"",{"0":[{"str":["coffeescript"]}]},"\""]}]},", ",{"value":[{"string":["\"",{"0":[{"str":["compiler"]}]},"\""]}]}]},"]"]}]}]},",",{"pair":["\n ",{"string":["\"",{"0":[{"str":["author"]}]},"\""]},": ",{"value":[{"string":["\"",{"0":[{"str":["Jeremy Ashkenas"]}]},"\""]}]}]},",",{"pair":["\n ",{"string":["\"",{"0":[{"str":["version"]}]},"\""]},": ",{"value":[{"string":["\"",{"0":[{"str":["1.3.3"]}]},"\""]}]}]},",",{"pair":["\n ",{"string":["\"",{"0":[{"str":["a-number-for-hiligitng-sake"]}]},"\""]},": ",{"value":["666"]}]},",",{"pair":["\n ",{"string":["\"",{"0":[{"str":["licenses"]}]},"\""]},": ",{"value":[{"array":["[",{"arraylist":[{"value":[{"object":["{\n ",{"pairlist":[{"pair":[{"string":["\"",{"0":[{"str":["type"]}]},"\""]},": ",{"value":[{"string":["\"",{"0":[{"str":["MIT"]}]},"\""]}]}]},",",{"pair":["\n ",{"string":["\"",{"0":[{"str":["url"]}]},"\""]},": ",{"value":[{"string":["\"",{"0":[{"str":["https://raw.github.com/jashkenas/coffee-script/master/LICENSE"]}]},"\""]}]},"\n "]}]},"}"]}]}]},"]"]}]}]},",",{"pair":["\n ",{"string":["\"",{"0":[{"str":["engines"]}]},"\""]},": ",{"value":[{"object":["{\n ",{"pairlist":[{"pair":[{"string":["\"",{"0":[{"str":["node"]}]},"\""]},": ",{"value":[{"string":["\"",{"0":[{"str":[">=0.4.0"]}]},"\""]}]},"\n "]}]},"}"]}]}]},",",{"pair":["\n ",{"string":["\"",{"0":[{"str":["directories"]}]},"\""]}," : ",{"value":[{"object":["{\n ",{"pairlist":[{"pair":[{"string":["\"",{"0":[{"str":["lib"]}]},"\""]}," : ",{"value":[{"string":["\"",{"0":[{"str":["./lib/coffee-script"]}]},"\""]}]},"\n "]}]},"}"]}]}]},",",{"pair":["\n ",{"string":["\"",{"0":[{"str":["main"]}]},"\""]}," : ",{"value":[{"string":["\"",{"0":[{"str":["./lib/coffee-script/coffee-script"]}]},"\""]}]}]},",",{"pair":["\n ",{"string":["\"",{"0":[{"str":["bin"]}]},"\""]},": ",{"value":[{"object":["{\n ",{"pairlist":[{"pair":[{"string":["\"",{"0":[{"str":["coffee"]}]},"\""]},": ",{"value":[{"string":["\"",{"0":[{"str":["./bin/coffee"]}]},"\""]}]}]},",",{"pair":["\n ",{"string":["\"",{"0":[{"str":["cake"]}]},"\""]},": ",{"value":[{"string":["\"",{"0":[{"str":["./bin/cake"]}]},"\""]}]},"\n "]}]},"}"]}]}]},",",{"pair":["\n ",{"string":["\"",{"0":[{"str":["homepage"]}]},"\""]},": ",{"value":[{"string":["\"",{"0":[{"str":["http://coffeescript.org"]}]},"\""]}]}]},",",{"pair":["\n ",{"string":["\"",{"0":[{"str":["bugs"]}]},"\""]},": ",{"value":[{"string":["\"",{"0":[{"str":["https://github.com/jashkenas/coffee-script/issues"]}]},"\""]}]}]},",",{"pair":["\n ",{"string":["\"",{"0":[{"str":["repository"]}]},"\""]},": ",{"value":[{"object":["{\n ",{"pairlist":[{"pair":[{"string":["\"",{"0":[{"str":["type"]}]},"\""]},": ",{"value":[{"string":["\"",{"0":[{"str":["git"]}]},"\""]}]}]},",",{"pair":["\n ",{"string":["\"",{"0":[{"str":["url"]}]},"\""]},": ",{"value":[{"string":["\"",{"0":[{"str":["git://github.com/jashkenas/coffee-script.git"]}]},"\""]}]},"\n "]}]},"}"]}]}]},",",{"pair":["\n ",{"string":["\"",{"0":[{"str":["devDependencies"]}]},"\""]},": ",{"value":[{"object":["{\n ",{"pairlist":[{"pair":[{"string":["\"",{"0":[{"str":["uglify-js"]}]},"\""]},": ",{"value":[{"string":["\"",{"0":[{"str":[">=1.0.0"]}]},"\""]}]}]},",",{"pair":["\n ",{"string":["\"",{"0":[{"str":["jison"]}]},"\""]},": ",{"value":[{"string":["\"",{"0":[{"str":[">=0.2.0"]}]},"\""]}]},"\n "]}]},"}\n"]}]}]}]},"}\n"]}]},
+ "docco":{ "TOP" : "TOP", "string" : "s", "number" : "m" }}
View
29 src/hilite.coffee
@@ -124,14 +124,8 @@ $ ->
crumbElt.append $("<td class='parse-crumb'>#{crumbhtml}</td>")
+ insertParseTree = (elt, data, id=0, prefix='') ->
-# translate rule name into CSS name.
- docco =
- TOP: 'TOP'
- string: 's'
- number: 'm'
-
- insertParseTree = (elt, parseTree, id=0, prefix='') ->
# append is just a turd :(
appendElt = (elt, s, klass) ->
elt.append '<span>'
@@ -143,17 +137,22 @@ $ ->
e.attr('id', prefix + id++)
return e
- for k, v of parseTree
- elt = appendElt elt, null, k
- for m in v
- if $.type(m) == "string"
- appendElt elt, m
- else
- insertParseTree elt, m, id
+ insertSubtree = (elt, subtree) ->
+ for k, v of subtree
+ elt = appendElt elt, null, k
+ for obj in v
+ if $.type(obj) == "string"
+ appendElt elt, obj
+ else
+ insertSubtree elt, obj, id
+
+ parseTree = data.parseTree
+ docco = data.docco
+ insertSubtree elt, parseTree
generateView = (elt, data, id=0, prefix='') ->
- insertParseTree elt, data.parseTree;
+ insertParseTree elt, data;
$('#current-rule').attr('data', JSON.stringify(data.rules))
Please sign in to comment.
Something went wrong with that request. Please try again.