blob: 0335e4e3fd724fb9a8d529f9a8fbb7e7b4141de2 (
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
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
|
/- b=boke, tp=trill-post
/+ sr=sortug, plib=trill-utils
/= poll-div /web/components/poll
|_ [s=state:b =bowl:gall]
++ content
|= c=content-map:tp ^- (list manx)
=/ latest (pry:corm:tp c)
?~ latest ~
(content-list +.u.latest)
++ content-list
|= c=content-list:tp ^- (list manx)
(turn c block)
++ block
|= b=block:tp ^- manx
?+ -.b ;p;
%paragraph (pg +.b)
%blockquote (bq +.b)
%heading (heading +.b)
:: %table (table +.b)
%list (htmlist +.b)
%media (media +.b)
%codeblock (codeblock +.b)
%eval (eval +.b)
%ref (refblock +.b)
==
++ eval
|= txt=@t ^- manx
:: Ream can crash if the cord is wrong
:: 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
==
:: ++ table
:: |= rows=(list (list content-list:tp))
:: ;table
:: ;* %+ turn rows
:: |= l=(list content-list:tp)
:: ;tr
:: ;* %+ turn l
:: |= cl=content-list:tp
:: ;td
:: ;* (turn cl block)
:: ==
:: ==
:: ==
++ refblock
|= [app=term src=@p pat=path]
?+ app ;span;
%polls (poll-loader pat)
==
++ poll-loader
|= scry-path=(pole knot) ^- manx
?. ?=([ship=@t id=@t ~] scry-path) ;span;
=/ usip (slaw %p ship.scry-path)
?~ usip ;span;
=/ uid (slaw %da id.scry-path)
?~ uid ;span;
=/ upoll (~(get by polls.s) [u.usip u.uid])
?~ upoll ;span:"Poll not found"
(show:poll-div u.upoll bowl)
++ 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
%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)}"
%link ?. (is-image:web: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));
==
%date
=/ s (time:enjs:format p.l)
?. ?=(%n -.s) ;span;
;span.timestamp(timestamp (trip p.s)):""
%note ;span;
%break ;br;
%underline ;span.underline:"{(trip p.l)}"
%sup ;sup:"{(trip p.l)}"
%sub ;sub:"{(trip p.l)}"
%ruby ;ruby
"{(trip p.l)}"
;rt:"{(trip q.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 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}"
++ is-img
|= t=@ta
=/ img-set %- silt
:~ ~.webp
~.png
~.jpeg
~.jpg
==
(~(has in img-set) t)
--
|