Merge branch 'master' into radio

Conflicts:
	urb/urbit.pill
This commit is contained in:
Philip C Monk 2014-12-09 20:39:36 -05:00
commit 9cbb67fc4d
15 changed files with 1582 additions and 378 deletions

View File

@ -440,7 +440,7 @@
vix=(bex +((cut 0 [25 2] mag))) :: width of sender
tay=(cut 0 [27 5] mag) :: message type
==
?> =(4 vez)
?> =(5 vez)
?> =(chk (end 0 20 (mug bod)))
:+ [(end 3 wix bod) (cut 3 [wix vix] bod)]
(kins tay)
@ -460,7 +460,7 @@
=+ tay=(ksin q.kec)
%+ mix
%+ can 0
:~ [3 4]
:~ [3 5]
[20 (mug bod)]
[2 yax]
[2 qax]
@ -1048,7 +1048,7 @@
++ gnaw :: gnaw:am
|= [kay=cape ryn=lane pac=rock] :: process packet
^- [p=(list boon) q=fort]
?. =(4 (end 0 3 pac)) [~ fox]
?. =(5 (end 0 3 pac)) [~ fox]
=+ kec=(bite pac)
?: (goop p.p.kec) [~ fox]
?. (~(has by urb.ton.fox) q.p.kec)

View File

@ -677,14 +677,16 @@
=+ got=(~(has by fat.ruf) his)
=+ luk=?.(?=(%$ -.lot) ~ ((soft case) p.lot))
?~ luk [~ ~]
=+ une=(un his now ruf)
?: =(%$ ren)
[~ ~]
=+ run=((soft care) ren)
?~ run [~ ~]
%+ bind
%. [u.run u.luk tyl]
aver:?.(got (do now [his his] syd ruf) (di:une syd))
=< aver
?: got
(di:(un his now ruf) syd)
(do now [his his] syd ruf)
|=(a=(unit) (bind a |=(b=* [%noun b])))
::
++ stay [%0 ruf]

View File

@ -529,9 +529,7 @@
%n $(kyz [%belt %aro %d])
%o %_ +>.$
mos
:_ :_ :_ mos
[hen %pass / %g %nuke [our /terminal] our]
:: XX LEGACY 2014-12-01
:_ :_ mos
[hen %pass /term-show %g %nuke [our /terminal] our]
[hen %pass /term-show %g %show [our /terminal] our /lines]
==

View File

@ -94,7 +94,7 @@
$: p=cafe :: cache
$= q ::
$% [%0 p=(set beam) q=a] :: depends/product
[%1 p=(set ,[p=beam q=(list tank)])] :: blocks
[%1 p=(set ,[p=care q=beam r=(list tank)])] :: blocks
[%2 p=(list tank)] :: error
== ::
== ::
@ -120,7 +120,7 @@
++ task :: problem in progress
$: nah=duct :: cause
kas=silk :: problem
kig=[p=@ud q=(map ,@ud beam)] :: blocks
kig=[p=@ud q=(map ,@ud ,[p=care q=beam])] :: blocks
== ::
-- ::
|% ::
@ -246,7 +246,7 @@
==
++ camo :: stop requests
^+ .
=+ kiz=(~(tap by q.kig) *(list ,[p=@ud q=beam]))
=+ kiz=(~(tap by q.kig) *(list ,[p=@ud q=[p=care q=beam]]))
|- ^+ +>
?~ kiz +>
%= $
@ -255,19 +255,19 @@
:- hen
:^ %pass [(scot %p our) (scot %ud num) (scot %ud p.i.kiz) ~]
%c
[%warp [our p.q.i.kiz] q.q.i.kiz ~]
[%warp [our p.q.q.i.kiz] q.q.q.i.kiz ~]
==
::
++ camp :: request a file
|= [ren=care bem=beam]
^+ +>
%= +>
kig [+(p.kig) (~(put by q.kig) p.kig bem)]
kig [+(p.kig) (~(put by q.kig) p.kig [ren bem])]
mow :_ mow
:- hen
:^ %pass [(scot %p our) (scot %ud num) (scot %ud p.kig) ~]
%c
[%warp [our p.bem] q.bem [~ %& ren r.bem s.bem]]
[%warp [our p.bem] q.bem [~ %& ren r.bem (flop s.bem)]]
==
::
++ clef :: cache a result
@ -339,22 +339,31 @@
?- -.ton
%2 [%2 p=p.ton]
%0 [%0 p=*(set beam) q=(fun p.ton)]
%1 ~& [%coup-need ((list path) p.ton)]
%1 :: ~& [%coup-need ((list path) p.ton)]
=- ?- -.faw
& [%1 p=(sa (turn p.faw |=(a=beam [a *(list tank)])))]
& :- %1
^= p
%- sa
%+ turn p.faw
|=(a=[care beam] [-.a +.a *(list tank)])
| [%2 p=p.faw]
==
^= faw
|- ^- (each (list beam) (list tank))
|- ^- (each (list (pair care beam)) (list tank))
?~ p.ton [%& ~]
=+ nex=$(p.ton t.p.ton)
=+ pax=(path i.p.ton)
?~ pax [%| (smyt pax) ?:(?=(& -.nex) ~ p.nex)]
?. ?=(%c (end 3 1 i.pax))
[%| leaf/"blocking not clay" (smyt pax) ?:(?=(& -.nex) ~ p.nex)]
=+ ren=((soft care) (rsh 3 1 i.pax))
?~ ren
[%| leaf/"blocking not care" (smyt pax) ?:(?=(& -.nex) ~ p.nex)]
=+ zis=(tome t.pax)
?~ zis
[%| (smyt pax) ?:(?=(& -.nex) ~ p.nex)]
[%| leaf/"blocking not beam" (smyt pax) ?:(?=(& -.nex) ~ p.nex)]
?- -.nex
& [%& u.zis p.nex]
& [%& [u.ren u.zis] p.nex]
| nex
==
==
@ -387,7 +396,7 @@
=< abet
|- ^+ ..exec
?~ zuk ..exec
=+ foo=`_..exec`(camp %x `beam`p.i.zuk)
=+ foo=`_..exec`(camp p.i.zuk q.i.zuk)
$(zuk t.zuk, ..exec foo)
==
::
@ -418,9 +427,10 @@
=+ pax=/door/[for]/mar
=+ ^= bem ^- beam
:_ pax
?: =(p.bek our) bek
?: &(=(p.bek our) =(q.bek %main)) bek
=+ oak=[our %main %da now]
?. =(~ (ska %cy (tope [oak pax]))) oak
?: ?=([~ ~ *] (ska %cy (tope [oak pax])))
oak
bek
(cope (fade cof %hook bem) abut:(meow bem ~))
::
@ -647,7 +657,7 @@
|= [cof=cafe bem=beam]
^- (bolt beam)
=+ von=(ska %cw (tope bem(s ~)))
?~ von [p=cof q=[%1 [bem ~] ~ ~]]
?~ von [p=cof q=[%1 [%w bem ~] ~ ~]]
(fine cof bem(r [%ud ((hard ,@) (need u.von))]))
::
++ lave :: validate
@ -672,7 +682,7 @@
|= [cof=cafe bem=beam]
^- (bolt arch)
=+ von=(ska %cy (tope bem))
?~ von [p=cof q=[%1 [bem ~] ~ ~]]
?~ von [p=cof q=[%1 [%y bem ~] ~ ~]]
(fine cof ((hard arch) (need u.von)))
::
++ liar :: load vase
@ -680,7 +690,7 @@
^- (bolt vase)
=+ von=(ska %cx (tope bem))
?~ von
[p=*cafe q=[%1 [[bem ~] ~ ~]]]
[p=*cafe q=[%1 [[%x bem ~] ~ ~]]]
?~ u.von
(flaw cof (smyt (tope bem)) ~)
(fine cof ?^(u.u.von [%cell %noun %noun] [%atom %$]) u.u.von)
@ -1191,7 +1201,8 @@
^+ ..zo
?> (~(has by q.kig) tik)
?~ rot
amok:(expo [%made %| (smyt (tope (need (~(get by q.kig) tik)))) ~])
=+ `[ren=care bem=beam]`(~(got by q.kig) tik)
amok:(expo [%made %| (smyt ren (tope bem)) ~])
exec(q.kig (~(del by q.kig) tik))
--
--

View File

@ -265,7 +265,7 @@
|= [pax=path hen=duct hin=(hypo sign)] ::
^- [p=(list move) q=_..^$]
?: ?=(%crud +<.q.hin)
~& [%gall-crud-error pax hen q.hin]
~& [%gall-crud-error pax hen]
?> ?=(%g -.q.hin)
?~ pax ~& %strange-path [~ ..^$]
=+ lum=(lump t.pax)
@ -274,7 +274,7 @@
=+ sat=(~(get by bum.u.mat) q.p.lum)
?~ sat ~& %no-app [~ ..^$]
:- `(list move)`[hen %give %crud p.q.hin q.q.hin]~
~& [%crud-stuff qic=?~(qic.u.sat ~ [p -.q]:u.qic.u.sat) onz=onz.u.sat]
:: ~& [%crud-stuff qic=?~(qic.u.sat ~ [p -.q]:u.qic.u.sat) onz=onz.u.sat]
%= ..^$ :: XX maybe call work?
pol.all
%+ ~(put by pol.all) p.p.lum
@ -398,7 +398,7 @@
%a
?. ?=(%woot +<.sih)
~& [%gall-bad-gasp-a pax=pax lgsih=+<.sih]
~& [%gall-bad-gasp-b pax=pax sih=sih] !!
~& [%gall-bad-gasp-b pax=pax sih=sih] `..^$
:_ ..^$ :_ ~
?~ q.sih
[hen %give %nice ~]

View File

@ -8578,21 +8578,23 @@
++ hog :: tag head
%+ cook
|= $: a=twig
b=(unit ,@tas)
c=(unit ,@tas)
d=(unit twig)
e=(list twig)
b=(list ,[@tas @tas])
c=$|(~ [p=@tas q=twig])
d=(list twig)
==
^- [twig (list twig)]
=. e ?~(b e [[[%dtzz %tas %class] [%smdq (trip u.b)]] e])
=. e ?~(c e [[[%dtzz %tas %id] [%smdq (trip u.c)]] e])
=. e ?~(d e [[[%dtzz %tas %href] u.d] e])
[a e]
=- [a (welp - ?~(c d [[[%dtzz %tas p.c] q.c] d]))]
=- (~(tap by -))
%. |=(e=(list tank) [%smdq ~(ram re %rose [" " `~] e)])
=< ~(run by f:(reel b .))
|= [e=[p=term q=term] f=(jar twig tank)]
(~(add ja f) [[%dtzz %tas p.e] [%leaf (trip q.e)]])
;~ plug
fry
;~(pose (stag ~ ;~(pfix dot sym)) (easy ~))
;~(pose (stag ~ ;~(pfix hax sym)) (easy ~))
;~(pose (stag ~ ;~(pfix fas (stag %smdq soil))) (easy ~))
=- (star ;~(plug - sym))
;~(pose (cold %class dot) (cold %id hax))
=- ;~(pose ;~(plug - (stag %smdq soil)) (easy ~))
;~(pose (cold %href fas) (cold %src pat))
;~ pose
%+ ifix [pel per]
%+ more ;~(plug com ace)

View File

@ -680,7 +680,7 @@
::
++ poxa :: xml parser
=< |=(a=cord (rush a apex))
|%
|_ ent=_`(map term ,@t)`[[%apos '\''] ~ ~]
++ apex
=+ spa=;~(pose comt whit)
%+ knee *manx |. ~+
@ -706,7 +706,7 @@
::
++ chrd :: character data
%+ cook |=(a=tape ^-(mars :/(a)))
(plus ;~(less soq doq ;~(pose (just `@`10) escp)))
(plus ;~(less doq ;~(pose (just `@`10) escp)))
::
++ comt :: comments
=- (ifix [(jest '<!--') (jest '-->')] (star -))
@ -716,15 +716,19 @@
;~(less (jest '-->') hep)
==
::
++ escp
++ escp ;~(pose ;~(less gal gar pam prn) enty)
++ enty :: entity
%+ ifix pam^sem
;~ pose
;~(less gal gar pam prn)
(cold '>' (jest '&gt;'))
(cold '<' (jest '&lt;'))
(cold '&' (jest '&amp;'))
(cold '"' (jest '&quot;'))
(cold '\'' (jest '&apos;'))
=+ def=`_ent`(mo [%gt '>'] [%lt '<'] [%amp '&'] [%quot '"'] ~)
%+ sear ~(get by (~(uni by def) ent))
(cook crip ;~(plug alf (stun 1^31 aln)))
%+ cook |=(a=@c ?:((gth a 0x10.ffff) '<27>' (tuft a)))
=< ;~(pfix hax ;~(pose - +))
:- (bass 10 (stun 1^8 dit))
(bass 16 ;~(pfix (mask "xX") (stun 1^8 hit)))
==
::
++ empt :: self-closing tag
%+ ifix [gal (jest '/>')]
;~(plug ;~(plug name attr) (cold ~ (star whit)))

View File

@ -12,7 +12,7 @@
$% [%$ p=tape]
[%line ~]
[%code p=tape]
[%html p=manx]
[%html p=cord]
==
$&([p=inlik q=kids] inlin)
::

View File

@ -88,3 +88,16 @@ window.urb.unsubscribe = function(params,cb) {
delete $this.cabs[$this.gsig(params)]
})
}
window.urb.util = {
toDate: function (dat){
var mils = Math.floor((0x10000 * dat.getUTCMilliseconds()) / 1000).toString(16)
return '~' + dat.getUTCFullYear() +
'.' + (dat.getUTCMonth() + 1) +
'.' + dat.getUTCDate() +
'..' + dat.getUTCHours() +
'.' + dat.getUTCMinutes() +
'.' + dat.getUTCSeconds() +
'..' + ('0000' + mils).substr(-4, 4)
}
}

View File

@ -6,322 +6,37 @@
::
::::
::
// /%%/parse :: inli donp parse
// /%%/rend :: sing sung sang flat into-inner
:: ~% %utyl +>+>+> ~
|_ don=down
++ grab :: convert from
|%
++ md :: convert from %md
=< |=(src=@t (mark (trip src)))
=< |=(src=@t (mark src))
~% %utyl ..is ~
::~% %utyl +>+>+>+> ~
|%
++ mark
|= p=tape
(scan p apex)
::
++ apex :: markdown parser
|= tub=nail
^- (like down)
=+ sep=(sepa tub)
?~ q.sep [p.sep ~]
:- p.sep
%- some :_ [p.sep ~]
(turn p.u.q.sep |=(a=tape (scan a blos)))
::
++ base %+ stag %par
;~ plug
(stag %tex (plus ;~(pose prn eol)))
(easy ~)
==
::
++ blos :: block element
%+ knee *barb |. ~+
;~ pose
head quot lasd horz
code codf html para base
==
::
++ brek (stag %cut (cold ~ ;~(plug fas fas))) :: line break
++ chrd ;~(pose escp prn (cold ' ' eol)) :: shin character data
++ code :: code block
%+ stag %pre
%- full
%- plus
;~ pfix (stun [4 4] ace)
;~ pose
%+ cook welp
;~(plug (plus prn) (cold "\0a" eol))
(full (plus prn))
==
==
::
++ codf :: fenced code block
%+ stag %pre
%- full
%+ ifix
[;~(plug tec tec tec eol) ;~(plug tec tec tec)]
%- plus
;~ pose
%+ cook welp
;~(plug (star prn) (cold "\0a" eol))
(full (plus ;~(less ;~(plug tec tec tec) prn)))
==
::
++ cods :: code shin
%+ stag %cod
=+ chx=;~(pose (cold ' ' eol) prn)
;~ pose
%+ ifix [(jest '```') (jest '```')]
(plus ;~(less (jest '```') chx))
%+ ifix [(jest '``') (jest '``')]
(plus ;~(less (jest '``') chx))
(ifix [tec tec] (plus ;~(less tec chx)))
==
::
++ dont :: control chars
;~ pose tar tec cab sel
;~(plug sig sig)
;~(plug fas fas)
==
++ spas :: all shin elements
|* res=_rule
%- plus
;~ pose emph stri link
brek cods (text res)
==
::
++ eol (just `@`10) :: newline
++ emph :: emphasis
%+ knee *shin |. ~+
%+ stag %emp
=+ inn=(plus ;~(pose cods stri link (text fail)))
;~ pose
(ifix [(jest '***') (jest '***')] (stag %both inn))
(ifix [(jest '**_') (jest '_**')] (stag %both inn))
(ifix [(jest '*__') (jest '__*')] (stag %both inn))
(ifix [(jest '_**') (jest '**_')] (stag %both inn))
(ifix [(jest '__*') (jest '*__')] (stag %both inn))
(ifix [(jest '___') (jest '___')] (stag %both inn))
(ifix [(jest '**') (jest '**')] (stag %bold inn))
(ifix [(jest '__') (jest '__')] (stag %bold inn))
(ifix [tar tar] (stag %bent inn))
(ifix [cab cab] (stag %bent inn))
==
::
++ escp ;~(pfix bas (mask (trip '`*#-.{}[]\\'))) :: escapable chars
::
++ head :: header
%+ stag %had
=+ ^= hed
;~ pose
;~ plug
;~(pfix wits (spas hax))
(cook some (ifix [;~(plug (star hax) sel hax) ser] (plus alp)))
==
(ifix [wits (star hax)] ;~(plug (spas hax) (easy ~)))
==
=+ ^= sed
;~ pose
;~ plug
(spas ;~(pose eol sel))
(cook some (ifix [;~(plug sel hax) ser] (plus alp)))
==
;~(plug (spas eol) (easy ~))
==
%- full
;~ pose
;~(plug (cook lent (stun [1 6] hax)) hed)
(stag 1 (ifix [wits ;~(plug eol (plus tis))] sed))
(stag 2 (ifix [wits ;~(plug eol (plus hep))] sed))
==
::
++ horz :: horizontal rule
%+ stag %hot
%+ cold ~
%- full
;~ pose
;~(plug (stun [0 3] ace) hep wits hep wits hep (star ;~(pose hep ace)))
;~(plug (stun [0 3] ace) tar wits tar wits tar (star ;~(pose tar ace)))
;~(plug (stun [0 3] ace) cab wits cab wits cab (star ;~(pose cab ace)))
==
::
++ html (stag %hem apex:poxa) :: html barb
++ lasd :: top level list
%+ stag %lit
%- full
;~ pose
(stag & (lisd ;~(plug (star nud) dot)))
(stag | (lisd hep))
(stag | (lisd tar))
(stag | (lisd lus))
==
::
++ lisd :: list funk
|* bus=_rule
|= tub=nail
^- (like down)
=+ chx=;~(plug (plus prn) (cold "\0a" eol))
=- ?~ q.pre pre
:- p.pre %- some
[(turn `wall`p.u.q.pre |=(a=tape [%lie (scan a apex)])) [p.pre ~]]
^= pre %. tub
%+ most ;~(pose ;~(plug wits eol) (easy ~))
%+ cook |=(a=wall `tape`(zing a)) :: XX core dump w/o cast
;~ plug
%+ cook zing
;~ pose
(full ;~(pfix bus ace ;~(plug (plus prn) (easy ~))))
;~(pfix bus ace ;~(plug (plus prn) (cold "\0a" eol) (easy ~)))
==
%- star
;~ pose
;~(plug ;~(sfix eol ace ace) (cook welp chx))
;~(pfix ace ace (cook welp chx))
(full ;~(pfix ace ace (plus prn)))
==
==
::
++ link :: link element
%+ knee *shin |. ~+
%+ stag %lin
;~ plug
(ifix [sel ser] (plus ;~(pose emph stri cods (text ser))))
;~ pose
%+ ifix [pel per]
;~ plug
;~(sfix (cook zing (most eol (plus ;~(less ace prn)))) ace)
(cook some (ifix [doq doq] (plus ;~(less doq ;~(pose prn eol)))))
==
%+ ifix [pel per]
;~(plug (cook zing (most eol (plus ;~(less per prn)))) (easy ~))
==
==
::
++ para (stag %par (full (spas fail))) :: paragraph
++ quot :: blockquotes
%+ stag %quo
%- full
|= tub=nail
^- (like down)
=- ?~ q.pre
[p.pre ~]
(apex [[1 1] (welp p.u.q.pre q.q.u.q.pre)])
^= pre %. tub
%+ cook |=(a=wall `tape`(zing a))
%- plus
;~ pfix ;~(pose ;~(plug gar ace) gar)
;~ pose
(cook welp ;~(plug (star prn) (cold "\0a" eol)))
(full (star prn))
==
==
::
++ sepa :: separate barbs
%+ knee *wall |. ~+
=+ lin=;~(plug eol wits eol)
%- full
%+ ifix [(star whit) (star whit)]
%+ more ;~(plug eol wits (more wits eol))
;~ pose
sepc
(sepl (cold "-" hep))
(sepl (cold "*" tar))
(sepl (cold "+" lus))
(sepl (cook welp ;~(plug (star nud) (cold "." dot))))
(plus ;~(pose prn ;~(less lin eol)))
==
::
++ sepc :: separate code block
=+ tecs=(cold "```" (jest '```'))
%+ cook |=(wall `tape`(zing +<))
;~ plug
tecs
(cook zing (star ;~(plug eol ;~(less tecs (star prn)))))
(cold "\0a" eol)
tecs
(easy ~)
==
++ sepl :: separate list
|* bus=_rule
%+ cook zing
%+ most ;~(pose ;~(plug wits eol) (easy ~))
%+ cook |=(a=wall `tape`(zing a))
;~ plug
%+ cook |=(a=wall `tape`(zing a))
;~ pose
;~(plug bus (cold " " ace) (plus prn) (cold "\0a" eol) (easy ~))
(full ;~(plug bus (cold " " ace) (plus prn) (easy ~)))
==
%- star
;~ pose
;~ pfix wits
;~ plug eol ace ace
(cook welp ;~(plug (plus prn) (cold "\0a" eol)))
==
==
;~(plug ace ace (cook welp ;~(plug (plus prn) (cold "\0a" eol))))
(full ;~(plug ace ace (plus prn)))
==
==
::
++ stri :: strikethrough text
%+ stag %ike
%+ ifix [(jest '~~') (jest '~~')]
(plus ;~(pose emph cods link (text fail)))
::
++ text |*(res=_rule (stag %tex (plus ;~(less ;~(pose res dont) chrd))))
++ whit (mask ~[`@`0x20 `@`0xa]) :: whitespace w/nl
++ wits (star ace)
~/ %dawn
|= p=@t
(normalize (rash p parse))
--
::
++ noun down :: clam from %noun
--
::
++ grow :: convert into
=< |%
|%
++ hymn :: convert to %hymn
;html
;head:title:"Untitled"
;body
;* (apex don)
;* (sing don)
==
==
++ psal :: convert to %psal
;div
;* (apex don)
==
--
|%
++ apex |=(don=down (turn don |=(bol=barb (blok bol))))
++ blok
|= bol=barb
^- manx
?- bol
[%had *]
:_ (turn q.bol sank)
[(cat 3 'h' (scot %ud p.bol)) ?~(r.bol ~ [[%id u.r.bol] ~])]
[%par *] [[%p ~] (turn p.bol sank)]
[%hot *] [[%hr ~] ~]
[%pre *] [[%pre ~] ~[[[%$ [[%$ (zing p.bol)] ~]] ~]]]
[%quo *] [[%blockquote ~] (apex p.bol)]
[%lie *] [[%li ~] (apex p.bol)]
[%lit *] ?: =(& p.bol) [[%ol ~] (apex q.bol)]
[[%ul ~] (apex q.bol)]
[%hem *] p.bol
==
::
++ sank
|= san=shin
^- manx
?- san
[%tex *] [[%$ [[%$ p.san] ~]] ~]
[%cut *] [[%br ~] ~]
[%ike *] [[%del ~] (turn p.san ..$)]
[%cod *] [[%code ~] ~[[[%$ [[%$ p.san] ~]] ~]]]
[%emp *]
?: =(%bent p.san) [[%em ~] (turn q.san ..$)]
?: =(%bold p.san) [[%strong ~] (turn q.san ..$)]
[[%em ~] ~[[[%strong ~] (turn q.san ..$)]]]
[%lin *]
?~ r.san [[%a ~[[%href q.san]]] (turn p.san ..$)]
[[%a ~[[%href q.san] [%title u.r.san]]] (turn p.san ..$)]
;* (sing don)
==
--
--

File diff suppressed because one or more lines are too long

1219
main/mar/down/parse.hoon Normal file

File diff suppressed because it is too large Load Diff

222
main/mar/down/rend.hoon Normal file
View File

@ -0,0 +1,222 @@
:: ++down rendering arms
::
::::
::
|%
++ into-inner
|= [a=marl b=manx]
?~ c.b b(c a)
$(b i.c.b)
::
++ flat
|= a=marl
^- tape
?~ a ~
%- weld :_ $(a t.a)
^- tape
?~ n.g.i.a
?>(?=(_:/(**) i.a) v.i.a.g.i.a)
?+ n.g.i.a $(a c.i.a)
%img
%- zing ^- wall
%+ murn a.g.i.a |= [a=mane b=tape]
^- (unit tape)
?+ a ~
%alt [~ b]
==
==
::
++ sang :: tight item children
|= a=(list elem)
^- marl
?~ a ~
%- weld :_ $(a t.a)
?. ?=(%para -.i.a)
(sing i.a ~)
(sung p.i.a)
::
++ sing :: elem to manx
=> |%
++ first-word
|= a=tape
=. a (trip (crip a)) :: XX valid tapes
^- (unit tape)
=. a q.q:(need q:((star ace) [1 1] a))
=+ vex=((plus ;~(less ace prn)) [1 1] a)
?~ q.vex ~
(some (wonk vex))
--
=+ [tig=| had=*(unit mane)]
|= lum=(list elem)
|^ ^- marl
=+ a=apex
?~ q.a
p.a
(weld p.a $(lum q.a))
::
++ apex
^- [p=marl q=_lum]
?~ lum
?~ had [~ ~]
(lose "unclosed {<u.had>}")
=> [ele=i.lum .(lum t.lum)]
?. ?=(%html -.ele)
(push (reso ele) ~)
=+ tex=(trip (role p.ele))
=^ mar tex [p q.q]:(need q:(many:poxa 1^1 tex))
?^ mar
(push mar)
=^ hed lum (chomp tex head:poxa)
?^ hed
=+ max=`marx`u.hed
(push(lum q) [max p] ~):[apex(had `n.max) .]
=^ tal lum (chomp tex tail:poxa)
?~ tal
(push ;lost:"{tex}" ~)
?: =(had tal)
[~ lum]
?^ had
=. lum [ele lum]
(lose "unclosed {<u.had>}")
(lose "close {<u.tal>}")
::
++ lose |=(a=tape [[;lost:"{a}"]~ lum])
++ chomp
|* [tap=tape fel=_rule]
^- [(unit ,_(wonk *fel)) _lum]
=+ vex=(fel 1^1 tap)
?~ q.vex [~ lum]
:- [~ (wonk vex)]
?~(q.q.u.q.vex lum [[%html (crip q.q.u.q.vex) ~] lum])
::
++ push
|= a=marl
^+ apex
?~ a apex
[[b p] q]:[b=i.a (push t.a)]
::
++ reso
|= a=elem
?^ -.a
=. tig ?.(?=(%list -.p.a) tig p.p.a)
?: &(tig ?=(%item -.p.a))
[/li (sang q.a)]
%+ into-inner ^$(lum q.a)
?- -.p.a
%bloq ;blockquote;
%item ;li;
%list ?@ q.p.a ;ul;
?: =(1 p.q.p.a) ;ol;
=+ num=(pojo (jone p.q.p.a))
;ol(start num);
==
?- -.a :: :/("unimplemented {<p.a>}")
%html !! :: handled earlier XX do type stuff
%para [/p (sung p.a)]
%head [/(add %h0 (lsh 3 1 p.a)) (sung q.a)]
%hrul ;hr;
:: %html
::=+ tex=(role (turn p.a crip))
::=+ (poxa tex)
::?^ - u.-
::=+ (rush tex (star ;~(pose gah comt:poxa)))
::?^ - :/(~)
::;lost: {<p.a>}
:: :/([(role (turn p.a crip))]~) :: XX haaaaaaack
%defn :/(~)
%code =+ lan=?~(p.a ~ (first-word r.u.p.a))
=+ tex=(trip (role q.a))
?~ lan ;pre:code:"{tex}"
;pre:code(class "language-{u.lan}"):"{tex}"
==
--
::
++ sung
|= lim=kids
=+ had=*(unit mane)
|^ ^- marl
=+ a=apex
?~ q.a
p.a
(weld p.a $(lim q.a))
::
++ apex
^- [p=marl q=_lim]
?~ lim
?~ had [~ ~]
(lose "unclosed {<u.had>}")
=> [ele=i.lim .(lim t.lim)]
?. ?=(%htmt -.ele)
:: ?: &(?=(%$ -.ele) ?=([[%$ *] *] lim))
:: apex(p.i.lim (weld p.ele p.i.lim))
(push (reso ele) ~)
=+ tex=(trip p.ele)
=^ emo lim (chomp tex empt:poxa)
?^ emo
=+ man=`manx`u.emo
(push man ~)
=^ hed lim (chomp tex head:poxa)
?^ hed
=+ max=`marx`u.hed
(push(lim q) [max p] ~):[apex(had `n.max) .]
=^ tal lim (chomp tex tail:poxa)
?~ tal
(push ;lost:"{tex}" ~)
?: =(had tal)
[~ lim]
?^ had
=. lim [ele lim]
(lose "unclosed {<u.had>}")
(lose "close {<u.tal>}")
::
++ lose |=(a=tape [[;lost:"{a}"]~ lim])
++ chomp
|* [tap=tape fel=_rule]
^- [(unit ,_(wonk *fel)) _lim]
=+ vex=(fel 1^1 tap)
?~ q.vex [~ lim]
:- [~ (wonk vex)]
?~(q.q.u.q.vex lim [[%htmt (crip q.q.u.q.vex)] lim])
::
++ push
|= a=marl
^+ apex
?~ a apex
[[b p] q]:[b=i.a (push t.a)]
::
++ urly
|= a=tape ^- tape
?~ a ~
:: ?: (gth i.a 0xff) "XX" :: XX
?: ?| [?=(^ q)]:(alp 1^1 a)
(~(has in (sa "!*'();:@&=+$,/?#%.~_")) i.a) :: XX reparse
==
[i.a $(a t.a)]
(weld (urle (trip i.a)) $(a t.a))
::
++ reso
|= b=inline
^- manx
?@ -.b
?- -.b
%$ =.(p.b (trip (crip p.b)) :/(p.b)) :: XX valid tapes
%line ;br;
%code ;code:"{p.b}"
%htmt !! ::p.b :: handled earlier :: XX do type stuff
==
?: ?=(%blot -.p.b)
=+ res=`manx`;img(src (urly p.p.b), alt (flat (turn q.b ..$)));
:: ;img@"{p.p.b}";
?~ q.p.b res
res(a.g (welp a.g.res title/u.q.p.b ~))
%+ into-inner (sung q.b)
?- p.b
[%emph ?] ?.(p.p.b ;em; ;strong;)
[%delt ~] ;del;
[%link ^] =+ url=(urly p.p.b)
?~ q.p.b ;a/"{url}";
;a/"{url}"(title u.q.p.b);
==
--
--

View File

@ -20,7 +20,7 @@ questions it does not answer:
1. How much indentation is needed for a sublist? The spec says that
continuation paragraphs need to be indented four spaces, but is
not fully explicit about sublists. It is natural to think that
not fully <emph>explicit</emph> about sublists. It is natural to think that
they, too, must be indented four spaces, but `Markdown.pl` does
not require that. This is hardly a "corner case," and divergences
between implementations on this issue often lead to surprises for

View File

@ -1,22 +1,39 @@
|%
++ down (list barb) :: markdown structure
++ barb :: block elements
$% [%had p=@ud q=(list shin) r=(unit tape)] :: depth, contents, id
[%hem p=manx] :: html tag
[%hot ~] :: horizontal rule
[%lie p=down] :: list element
[%lit p=? q=down] :: list
[%par p=(list shin)] :: paragraph
[%pre p=wall] :: preformatted text
[%quo p=down] :: blockquote
== ::
++ shin :: span elements
$% [%cod p=tape] :: inline code
[%cut ~] :: break
[%emp p=?(%bent %bold %both) q=(list shin)] :: emphasis
[%ike p=(list shin)] :: strikethrough
[%lin p=(list shin) q=tape r=(unit tape)] :: link
[%tex p=tape] :: text
== ::
++ down (list elem)
++ kids (list inline)
++ inline
=+ ^= inlik
$% [%emph p=?] :: strong?
[%delt ~] :: strikethrough
[%link p=tape q=(unit tape)]
[%blot p=tape q=(unit tape)] :: image
==
=+ ^= inlin
$% [%$ p=tape]
[%line ~]
[%code p=tape]
[%htmt p=cord] :: XX (each marx mane)
==
$&([p=inlik q=kids] inlin)
::
::
++ elem $&(tops node)
++ tops :: childful block
$: $= p
$% [%bloq ~]
[%list p=? q=$|(char [p=@u q=char])] :: tight, ordered?
[%item ~]
==
q=down
==
:: ++ mist |*(a=_,* ,[i=a t=$|(~ (mist a))]) :: .=(%mist +(%list))
++ node :: childless block
$% [%para p=kids]
[%hrul ~]
[%head p=@u q=kids]
[%code p=(unit ,[p=char q=@u r=tape]) q=wain] :: info, contents
[%html p=wain]
[%defn ~] :: empty para
==
--