chat-cli: render mentions, urls inline

This commit is contained in:
Liam Fitzgerald 2020-12-04 13:05:20 +10:00
parent 62e535196e
commit 56b57a6af7
No known key found for this signature in database
GPG Key ID: D390E12C61D1CFFB

View File

@ -1100,20 +1100,25 @@
^- tape ^- tape
%- zing %- zing
%+ join "\0a" %+ join "\0a"
%+ turn contents %- turn
|= =content:post :_ |=(ls=(list tape) `tape`(zing (join " " ls)))
%+ roll contents
|= [=content:post out=(list (list tape))]
?- -.content ?- -.content
%text (trip text.content) %text (append-inline out (trip text.content))
%mention (scow %p ship.content) ::TODO inline w/o newlines %mention (append-inline out (scow %p ship.content))
%reference "^" %reference (append-inline out "^")
:: ::
%code %code
%+ weld (trip expression.content) %+ snoc out
^- (list tape)
:- (trip expression.content)
?: =(~ output.content) ~ ?: =(~ output.content) ~
:- '\0a' :- "\0a"
~(ram re (snag 0 output.content)) ~(ram re (snag 0 output.content))^~
:: ::
%url %url
%+ append-inline out
=+ wyd=content-width =+ wyd=content-width
=+ ful=(trip url.content) =+ ful=(trip url.content)
:: if the full url fits, just render it. :: if the full url fits, just render it.
@ -1136,6 +1141,25 @@
?~ b (trip a) ?~ b (trip a)
(welp b '.' (trip a)) (welp b '.' (trip a))
== ==
::
++ append-newline
|= [content=(list (list tape)) newline=tape]
^- (list (list tape))
(snoc content ~[newline])
::
++ append-inline
|= [content=(list (list tape)) inline=tape]
^- (list (list tape))
?: =(~ content)
~[~[inline]]
=/ last
(dec (lent content))
=/ old=(list tape)
(snag last content)
=/ new=(list tape)
(snoc old inline)
(snap content last new)
:: +activate: produce sole-effect for printing message details :: +activate: produce sole-effect for printing message details
:: ::
++ render-activate ++ render-activate