mar: better HTML-related conversions

This commit is contained in:
Marcus 2023-07-03 19:55:20 -03:00 committed by Pyry Kovanen
parent 6a618aa88f
commit a42b74bc5c
20 changed files with 37 additions and 166 deletions

View File

@ -13,7 +13,6 @@
=> v=.
|%
++ mime => v [/text/plain (as-octs (of-wain pem))]
++ elem => v ;pre: {(trip (of-wain pem))}
--
++ grad %mime
--

View File

@ -3,42 +3,6 @@
::
/? 310
=, html
|%
++ words 1
++ hedtal
=| met=marl
|= a=marl ^- [hed=marl tal=marl]
?~ a [~ ~]
?. ?=(%h1 n.g.i.a)
?: ?=(%meta n.g.i.a)
$(a t.a, met [i.a met])
=+ had=$(a c.i.a)
?^ -.had had
$(a t.a)
[c.i.a (weld (flop met) (limit words t.a))]
::
++ limit
|= [lim=@u mal=marl]
=< res
|- ^- [rem=@u res=marl]
?~ mal [lim ~]
?~ lim [0 ~]
=/ [lam=@u hed=manx]
?: ?=(_;/(**) i.mal)
[lim ;/(tay)]:(deword lim v.i.a.g.i.mal)
[rem ele(c res)]:[ele=i.mal $(mal c.i.mal)]
[rem - res]:[hed $(lim lam, mal t.mal)]
::
++ deword
|= [lim=@u tay=tape] ^- [lim=@u tay=tape]
?~ tay [lim tay]
?~ lim [0 ~]
=+ wer=(dot 1^1 tay)
?~ q.wer
[lim - tay]:[i.tay $(tay t.tay)]
=+ nex=$(lim (dec lim), tay q.q.u.q.wer)
[-.nex [(wonk wer) +.nex]]
--
::
::
=, mimes:html
@ -50,14 +14,18 @@
++ mime
=< mime
|%
++ elem ;div:(h1:"*{hed}" div:"*{tal}") :: convert to %elem
++ hymn ;html:(head:title:"snip" body:"+{elem}") :: convert to %hymn
++ hymn :: convert to %hymn
|^ html
++ div ;div:(h1:"*{hed}" div:"*{tal}")
++ html ;html:(head:title:"snip" body:"+{div}")
--
++ html (crip (en-xml hymn)) :: convert to %html
++ mime [/text/html (as-octs html)] :: convert to %mime
--
++ noun [hed tal]
--
++ grab |% :: convert from
++ noun ,[marl marl] :: clam from %noun
++ elem |=(a=manx (hedtal +.a))
-- --
++ grab :: convert from
|%
++ noun ,[marl marl] :: clam from %noun
--
--

View File

@ -1,12 +0,0 @@
|_ a=manx
++ grad %noun
++ grab
|%
++ noun manx
--
++ grow
|%
++ htm a
++ noun a
--
--

View File

@ -1,11 +0,0 @@
|_ a=manx
++ grad %noun
++ grab
|%
++ noun manx
--
++ grow
|%
++ noun a
--
--

1
pkg/arvo/mar/xhtml.hoon Symbolic link
View File

@ -0,0 +1 @@
../../base-dev/mar/xhtml.hoon

View File

@ -6,11 +6,15 @@
=, mimes:html
|_ mud=@t
++ grow :: convert to
|% ++ mime [/text/css (as-octs mud)] :: convert to %mime
++ elem ;style :: convert to %hymn
;- (trip mud)
==
++ hymn ;html:(head:"{elem}" body)
|%
++ mime [/text/css (as-octs mud)] :: convert to %mime
++ hymn :: convert to %hymn
|^ html
++ style ;style
;- (trip mud)
==
++ html ;html:(head:"{style}" body)
--
--
++ grab
|% :: convert from

View File

@ -8,20 +8,7 @@
++ grow :: convert to
|%
++ mime `^mime`[/text/x-hoon (as-octs:mimes:html own)] :: convert to %mime
++ elem :: convert to %html
;div:pre(urb_codemirror "", mode "hoon"):"{(trip own)}"
:: =+ gen-id="src-{<`@ui`(mug own)>}"
:: ;div
:: ;textarea(id "{gen-id}"):"{(trip own)}"
:: ;script:"""
:: CodeMirror.fromTextArea(
:: window[{<gen-id>}],
:: \{lineNumbers:true, readOnly:true}
:: )
:: """
:: ==
++ hymn
:: ;html:(head:title:"Source" "+{elem}")
;html
;head
;title:"Source"

View File

@ -2,14 +2,5 @@
:::: /hoon/htm/mar
::
/? 310
|_ own=manx
::
++ grad %noun
++ grow :: convert to
|%
++ noun own
++ hymn own
--
++ grab |% :: convert from
++ noun manx :: clam from %noun
-- --
/= htm /mar/html
htm

View File

@ -8,10 +8,13 @@
++ grow
|%
++ mime [/application/javascript (as-octs:mimes:html (@t mud))]
++ elem ;script
;- (trip (@t mud))
==
++ hymn ;html:(head:"+{elem}" body)
++ hymn :: convert to %hymn
|^ html
++ script ;script
;- (trip (@t mud))
==
++ html ;html:(head:"{script}" body)
--
--
++ grab
|% :: convert from

View File

@ -16,11 +16,6 @@
%& a+p.result
%| a+[a+[%s '[[output rendering error]]']~]~
==
::
++ elem
=- ;pre:code:"{(of-wall -)}"
^- wall %- zing ^- (list wall)
(turn (flop tan) |=(a=tank (wash 0^160 a)))
--
++ grab :: convert from
|%

View File

@ -18,7 +18,6 @@
=> v=.
|%
++ mime => v [/text/plain (as-octs (of-wain txt))]
++ elem => v ;pre: {(trip (of-wain txt))}
--
++ grad
|%

View File

@ -9,10 +9,6 @@
++ mime [/text/x-unmark (as-octs:mimes:html mud)]
++ txt
(to-wain:format mud)
++ elem
^- manx
=, cram
elm:(static (ream mud))
++ front :: XX performance, types
^- (map term knot)
%- ~(run by inf:(static:cram (ream mud)))

View File

@ -9,10 +9,6 @@
++ mime [/text/x-unmark (as-octs:mimes:html mud)]
++ txt
(to-wain:format mud)
++ elem
^- manx
=, cram
elm:(static (ream mud))
++ front :: XX performance, types
^- (map term knot)
%- ~(run by inf:(static:cram (ream mud)))

View File

@ -1,5 +1,5 @@
::
:::: /hoon/elem/urb/mar
:::: /hoon/urb/mar
::
/? 310
=, mimes:html

View File

@ -0,0 +1,5 @@
::
:::: /hoon/xhtml/mar
::
/= xhtml /mar/html
xhtml

View File

@ -1,21 +0,0 @@
::
:::: /hoon/css/mar
::
/? 310
=, eyre
=, mimes:html
|_ mud=@t
++ grow :: convert to
|% ++ mime [/text/css (as-octs mud)] :: convert to %mime
++ elem ;style :: convert to %hymn
;- (trip mud)
==
++ hymn ;html:(head:"{elem}" body)
--
++ grab
|% :: convert from
++ mime |=([p=mite q=octs] (@t q.q))
++ noun @t :: clam from %noun
--
++ grad %mime
--

1
pkg/landscape/mar/css.hoon Symbolic link
View File

@ -0,0 +1 @@
../../base-dev/mar/css.hoon

View File

@ -1,18 +0,0 @@
::
:::: /hoon/elem/mar
::
/? 310
=, mimes:html
=, html
|_ own=manx
::
++ grad %noun
++ grow :: convert to
|%
++ hymn ;html:(head body:"+{own}") :: convert to %hymn
++ html (crip (en-xml hymn)) :: convert to %html
++ mime [/text/html (as-octs html)] :: convert to %mime
--
++ grab |% :: convert from
++ noun manx :: clam from %noun
-- --

View File

@ -18,5 +18,4 @@
--
++ grab |% :: convert from
++ noun (map knot cord) :: clam from %noun
:: ++ elem ,~
-- --

View File

@ -1,12 +0,0 @@
|_ a=manx
++ grad %noun
++ grab
|%
++ noun manx
--
++ grow
|%
++ htm a
++ noun a
--
--

View File

@ -0,0 +1 @@
../../base-dev/mar/xhtml.hoon