Some problems with the formatting have been fixed now
Getty Ritter
8 years ago
1 | 1 |
name: inf-dict
|
2 | |
version: 1.0.2
|
| 2 |
version: 1.0.3
|
3 | 3 |
-- synopsis:
|
4 | 4 |
-- description:
|
5 | 5 |
license: BSD3
|
1 | 1 |
module Markup where
|
2 | 2 |
|
| 3 |
import Data.List (intersperse)
|
| 4 |
import Data.Monoid ((<>))
|
3 | 5 |
import Data.Text (Text)
|
4 | 6 |
import qualified Data.Text as T
|
5 | 7 |
import Lucid
|
|
17 | 19 |
-- | Understands a very limited form of markup, and does not understand
|
18 | 20 |
-- nested markup yet.
|
19 | 21 |
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
|
21 | 27 |
|
22 | 28 |
format :: Text -> [Chunk]
|
23 | 29 |
format t = case runParser parseF "[]" t of
|
|
32 | 38 |
<|> Strike <$> delim '~'
|
33 | 39 |
<|> (Chunk . T.pack) <$> pChunk
|
34 | 40 |
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)))
|
36 | 43 |
pChunk = some (noneOf ("*_`~" :: String))
|
37 | 44 |
|
38 | 45 |
build :: [Chunk] -> Html ()
|