diff options
Diffstat (limited to 'scripts/kmd/kmd.close')
-rw-r--r-- | scripts/kmd/kmd.close | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/scripts/kmd/kmd.close b/scripts/kmd/kmd.close new file mode 100644 index 0000000..569e507 --- /dev/null +++ b/scripts/kmd/kmd.close @@ -0,0 +1,34 @@ +import "std"; +import "util"; + +Kmd :: struct +has + Mode :: enum(none, p, ul, ol); + HtmlOptions :: record(br_after_newline: bool); +is + title : str, + date : ?str, + contents : str, +do + new :: construct fn(text: str) -> ?Kmd + do + iter := text.split_iter("\n"); + return construct Kmd // Kmd is coercible to ?Kmd. + as + title = iter.first(), + date = iter.after(), + contents = iter.rest(), + end; + end + + apart :: deconstruct fn(^self) -> (str, str, str) + do + return (self.title, self.date, self.contents); + end + + html :: fn(self, allocator: Allocator, opts: HtmlOptions, req_cap_if_known: ?usize) -> Kmd + do + mode : Mode = .none; + is_strong, is_emph := false, false; + end +end |