gdritter repos inf-dict / 55babf9
Some problems with the formatting have been fixed now Getty Ritter 8 years ago
2 changed file(s) with 10 addition(s) and 3 deletion(s). Collapse all Expand all
11 name: inf-dict
2 version: 1.0.2
2 version: 1.0.3
33 -- synopsis:
44 -- description:
55 license: BSD3
11 module Markup where
22
3 import Data.List (intersperse)
4 import Data.Monoid ((<>))
35 import Data.Text (Text)
46 import qualified Data.Text as T
57 import Lucid
1719 -- | Understands a very limited form of markup, and does not understand
1820 -- nested markup yet.
1921 markup :: Text -> Html ()
20 markup = div_ . sequence_ . map (build . format) . T.lines
22 markup = div_
23 . sequence_
24 . intersperse (br_ [])
25 . map (build . format)
26 . T.lines
2127
2228 format :: Text -> [Chunk]
2329 format t = case runParser parseF "[]" t of
3238 <|> Strike <$> delim '~'
3339 <|> (Chunk . T.pack) <$> pChunk
3440 delim :: Char -> Parser Text
35 delim c = T.pack <$> (char c *> manyTill anyChar (try (char c >> space)))
41 delim c = (T.pack . (<> " ")) <$>
42 (char c *> manyTill anyChar (try (char c >> space)))
3643 pChunk = some (noneOf ("*_`~" :: String))
3744
3845 build :: [Chunk] -> Html ()