shrub/pkg/base-dev/mar/story.hoon

66 lines
2.0 KiB
Plaintext
Raw Normal View History

/- *story
2022-01-31 00:01:45 +03:00
/+ *story
|_ tale=story
2022-01-16 07:37:51 +03:00
++ grad
|%
++ form %story-diff
++ diff
|= tory=story
^- story-diff
2022-01-31 00:03:10 +03:00
:: Given new story (tory), old story (tale), compute the diff
:: additions = new - old
:: deletions = old - new
[(dif-ju tory tale) (dif-ju tale tory)]
2022-01-16 07:37:51 +03:00
++ pact
|= dif=story-diff
:: Compute the new story after applying dif to tale.
::
2022-01-16 07:37:51 +03:00
^- story
2022-01-31 00:03:10 +03:00
=. tale (uni-ju tale additions.dif)
=. tale (dif-ju tale deletions.dif)
tale
2022-01-16 07:37:51 +03:00
++ join
|= [ali=story-diff bob=story-diff]
^- (unit story-diff)
2022-01-31 00:03:10 +03:00
=/ joined-additions (uni-ju additions.ali additions.bob)
=/ joined-deletions (uni-ju deletions.ali deletions.bob)
::
:: In a true join, we'd do a set intersection on the keys.
:: If they're not equal, we have a conflict.
:: In this case, we'd produce null and kick the flow to +mash
::
2022-01-16 07:37:51 +03:00
%- some
2022-01-31 00:03:10 +03:00
[joined-additions joined-deletions]
2022-01-16 07:37:51 +03:00
++ mash
:: called by meld, force merge, annotating conflicts
|= $: [als=ship ald=desk ali=story-diff]
[bos=ship bod=desk bob=story-diff]
==
^- story-diff
(need (join ali bob)) :: XX temporary, only because join doesn't fail
--
::
++ grow :: convert to
|% ::
++ mime :: to %mime
[/text/x-urb-story (as-octs:mimes:html (of-wain:format txt))]
++ txt
^- wain
%- zing
%+ join `wain`~['---']
%+ murn ~(tap by tale)
|= [=tako:clay =proses]
^- (unit wain)
2022-01-26 19:41:08 +03:00
?~ proses ~
(some (chapter-to-text tako proses))
--
++ grab
|% :: convert from
++ noun story :: clam from %noun
++ mime :: retrieve from %mime
|= [p=mite q=octs]
=/ story-text `@t`q.q
2022-02-05 14:16:59 +03:00
`story`(rash story-text parse-story)
--
--