]> hydra-www.ietfng.org Git - dyna2/commitdiff
()
authortimv <tim.f.vieira@gmail.com>
Thu, 13 Dec 2012 03:20:54 +0000 (22:20 -0500)
committertimv <tim.f.vieira@gmail.com>
Thu, 13 Dec 2012 03:20:54 +0000 (22:20 -0500)
bin/prototype.py
examples/matrixops.dyna

index 3c4500d399c36202d7c2ab643c2df6686a585c27..5389a8d665ea3b522daf99a9ff58cb5a94743329 100644 (file)
@@ -206,9 +206,6 @@ def graph_styles(g):
 
 def main(dynafile):
 
-    with file(dynafile) as f:
-        code = f.read()
-
     d = dynafile + '.d'
     os.system('mkdir -p %s' % d)
 
@@ -255,21 +252,20 @@ function selectline(lineno) {
 </head>
 """
 
-#        print >> html, '<h1>%s</h1>' % dynafile
-#        print >> html, '<h2>Dyna source</h2>'
-
         print >> html, '<div id="dyna-source">'
         print >> html, '  <pre>'
+
         with file(dynafile) as f:
+            code = f.read().strip()
 
-            lexer = get_lexer_by_name("haskell", stripall=True)
-            formatter = HtmlFormatter(linenos=False)
-            c = re.sub('%', '--', f.read())
-            pretty_code = highlight(c, lexer, formatter)
-            pretty_code = re.sub('--', '%', pretty_code)
+        lexer = get_lexer_by_name("haskell")
+        formatter = HtmlFormatter(linenos=False)
+        c = re.sub('%', '--', code)
+        pretty_code = highlight(c, lexer, formatter)
+        pretty_code = re.sub('--', '%', pretty_code)
 
-            for lineno, line in enumerate(pretty_code.split('\n'), start=1):
-                print >> html, '<a onclick="selectline(%s)">%s</a>' % (lineno, line.rstrip())
+        for lineno, line in enumerate(pretty_code.split('\n'), start=1):
+            print >> html, '<a onclick="selectline(%s)">%s</a>' % (lineno, line.rstrip())
 
         print >> html, '  </pre>'
         print >> html, '</div>'
index fe9ee986f1ed912590038307e6e511827322a60d..9cf7d915b1d588309ab1d992db0eaef256b5b29c 100644 (file)
@@ -1,4 +1,5 @@
 
+
 % A and B are names of matricies
 times(A, B, I, J)    += m(A, I, K) * m(B, K, J).
 times(A, B, C, I, L) += m(A, I, K) * m(B, K, J) * m(C, J, L).