blob: f4b574f908d02bfe90b63aa38153b9a005e3630d (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
|
/- tp=post
/+ sr=sortug
|%
++ content
|= c=content-list:tp
^- marl
(turn c block)
::
++ block
|= b=block:tp
^- manx
?+ -.b ;p;
%paragraph (pg +.b)
%blockquote (bq +.b)
%heading (heading +.b)
%list (htmlist +.b)
%media (media +.b)
%codeblock (codeblock +.b)
%eval (eval +.b)
==
++ eval
|= txt=@t
^- manx
:: +ream can crash if the cord is wrong, so soften instead
=/ uhoon (rush txt vest)
?~ uhoon ;p:"The hoon you tried to run ({(trip txt)}) is invalid."
=/ run (mule |.((slap !>(..zuse) u.uhoon)))
?: ?=(%.n -.run) :: if virtualization fails get a (list tank)
;p
;span:"Evaluation of {(trip txt)} failed:"
;br;
;* %+ turn p.run |= t=tank ;span:"{~(ram re t)}"
==
;p:"{(text p.run)}"
++ pg
|= l=(list inline:tp)
^- manx
;p
;* %+ turn l inline
==
++ bq
|= l=(list inline:tp)
^- manx
;blockquote
;* %+ turn l inline
==
++ htmlist
|= [l=(list content-list:tp) ordered=?]
?: ordered
;ol
;* %+ turn l li
==
;ul
;* %+ turn l li
==
++ li
|= l=content-list:tp ^- manx
;li
;* (turn l block)
==
++ media
|= m=media:tp
^- manx
?- -.m
%video ;video@"{(trip p.m)}";
%audio ;audio@"{(trip p.m)}";
%images ;div.images
;* %+ turn p.m
|= [url=@t caption=@t]
;img@"{(trip url)}"(alt (trip caption));
==
==
++ codeblock
|= [code=@t lang=@t] :: TODO lang suff
;pre
;code:"{(trip code)}"
==
++ heading
|= [pp=@t q=@]
^- manx
=/ p (trip pp)
?: .=(1 q) ;h1:"{p}"
?: .=(2 q) ;h2:"{p}"
?: .=(3 q) ;h3:"{p}"
?: .=(4 q) ;h4:"{p}"
?: .=(5 q) ;h5:"{p}"
?: .=(6 q) ;h6:"{p}"
;p:""
++ inline
|= l=inline:tp
^- manx
?+ -.l ;span;
%text (parse-text p.l)
%italic ;i:"{(trip p.l)}"
%bold ;strong:"{(trip p.l)}"
:: %strike ;del:"{(trip p.l)}"
%ship ;span.ship:"{(trip (scot %p p.l))}"
%codespan ;code:"{(trip p.l)}"
%break ;br;
%img ;a/"{(trip src.l)}"
;img@"{(trip src.l)}"(alt (trip alt.l));
==
%link ?. (is-image:parsing:sr href.l)
;a/"{(trip href.l)}"(target "_blank"):"{(trip show.l)}"
;a/"{(trip href.l)}"
=target "_blank"
;img@"{(trip href.l)}"(alt (trip show.l));
==
==
++ parse-text
|= txt=@t
^- manx
=/ tpe (trip txt)
=/ youtube (rush txt youtube:parsing:sr)
?^ youtube
:: ;a/"{tpe}"
:: ;img@"https://i.ytimg.com/vi/{u.youtube}/hqdefault.jpg";
:: ==
;iframe.youtube-frame@"https://www.youtube.com/embed/{u.youtube}";
=/ twatter-status (rush txt twatter:parsing:sr)
?^ twatter-status
;div :: goddamn twatter embeds insert themselves as last child
;a.parsed-twatter(status u.twatter-status):"{tpe}"
==
=/ trimmed (rush txt trim:parsing:sr)
?~ trimmed ~& parsing-error=txt ;span.parsing-error;
=/ link=(unit purl:eyre) (rust u.trimmed link:parsing:sr)
?^ link
?^ p.q.u.link
?: (is-img:parsing:sr u.p.q.u.link) ;img@"{u.trimmed}";
;a.parsed-link/"{tpe}"(target "_blank"):"{tpe}" :: normal link
;a.parsed-link/"{tpe}"(target "_blank"):"{tpe}" :: normal link
;span:"{tpe}"
--
|