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
|
module Zettel where
import Text.Pandoc.Class (runIOorExplode)
import Text.Pandoc.Definition (Block (..), Inline (..), Pandoc (..))
import Text.Pandoc.Readers (readOrg)
import Text.Pandoc.Writers (writeHtml5String, writeMarkdown)
import Text.Pandoc.Shared (stringify)
import Text.Pandoc.Walk (walkM)
newtype ZettelId = ZettelId
{ -- | The ZettelId is just Text, however, it should also be possible to convert
-- it to a list of the ID split up into it's parts.
unZettelId :: Text
}
deriving (Show, Eq, Ord)
instance IsString ZettelId where
fromString = ZettelId . fromString
instance ToString ZettelId where
toString = toString . unZettelId
instance Semigroup ZettelId where
ZettelId a <> ZettelId b = ZettelId $ a <> b
instance Monoid ZettelId where
mempty = ZettelId mempty
data Zettel = Zettel
{ -- | The ID that is assigned to the Zettel.
zettelId :: !ZettelId,
-- | The title of the Zettel, which should also be present in the body, however,
-- this is useful to gather metadata about the Zettel.
zettelTitle :: !Text,
-- | The text body of the Zettel, which is stored as a Pandoc document to make it
-- easy to export to other documents.
zettelBody :: Pandoc
}
deriving (Show, Eq)
instance Semigroup Zettel where
Zettel a b c <> Zettel _ _ c' = Zettel a b $ c <> c'
instance Monoid Zettel where
mempty = Zettel mempty mempty mempty
|