shrub/web/unparse.hoon

90 lines
2.4 KiB
Plaintext
Raw Normal View History

2015-07-28 02:21:04 +03:00
:: Twig reprinter
::
:::: /hook/hymn/unparse/pub
::
/= gas /$ fuel
2016-01-06 23:52:30 +03:00
/= src /: /%/mear /hoon/
/= src2 /: /%/ /hoon/
2015-07-28 02:21:04 +03:00
::
:::: ~sondel-forsut
::
2016-01-06 23:52:30 +03:00
// /%/mear
2015-07-28 02:21:04 +03:00
!:
::::
::
=+ inp=`@t`(fall %.(%src ;~(biff ~(get by qix.gas) (slat %t))) '%no-source')
^- manx
;html
;head
;title:"Uneval"
;style:'''
#inp {
height: 40%;
width: 100%;
font-family: Monospace;
}
'''
==
;body
;h3: Abstract
;p: Hoon linter, under construction.
;h3: Input
;textarea#inp(onchange "move()"):"{(trip inp)}"
;h3: Twig (subset)
;pre
;* %- turn :_ |=(a=tape :/((weld a "\0a")))
(wash 0^80 >(flag (ream inp))<)
==
;h3: Rectified output
;pre: {(trip (mear (ream inp)))}
;script:'''
function move(){
document.location = '?src=' + escp(inp.value)
}
function escp(s){
acc = '~~'
while(s.length){
var cha = s[0];
s = s.slice(1)
switch(true){
case /[a-z-]/.test(cha):
acc += cha
break;
case cha === ' ':
acc += '.'
break;
case /[.-]/.test(cha):
acc += '~' + cha
break;
default:
acc += '~' + cha.charCodeAt(0).toString(16) + '.'
} }
return acc
}
'''
:: includes
;* =- (turn `wall`- |=(a=tape ;script(type "text/javascript", src a);))
:~ "//cdnjs.cloudflare.com/ajax/libs/codemirror/4.3.0/codemirror.js"
2015-12-07 23:48:59 +03:00
"/lib/syntax/hoon.js"
2015-07-28 02:21:04 +03:00
==
;link(rel "stylesheet", href "//cdnjs.cloudflare.com/ajax/libs/".
"codemirror/4.3.0/codemirror.min.css");
;style:'''
2015-12-07 23:48:59 +03:00
.CodeMirror {height: 70%}
2015-07-28 02:21:04 +03:00
.cm-s-default .cm-atom {color: #70f}
.cm-s-default .cm-operator {color: #097}
'''
:: sources
;h3: Demo source: algorithm
;textarea#src: {(trip src)}
;script:'''
CodeMirror.fromTextArea(src, {lineNumbers:true, readOnly:true})
'''
;h3: Demo source: page
;textarea#src2: {(trip src2)}
;script:'''
CodeMirror.fromTextArea(src2, {lineNumbers:true, readOnly:true})
'''
==
==